Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
AM_MoveInstalled.cs
Go to the documentation of this file.
1using UnityEngine;
2
3public class AM_MoveInstalled : AM_Designation<TaskMoveInstalled>
4{
5 public Card target;
6
7 public Card moldCard;
8
9 public bool onetime;
10
11 public override int hitW
12 {
13 get
14 {
15 if (target != null)
16 {
17 return moldCard.W;
18 }
19 return 1;
20 }
21 }
22
23 public override int hitH
24 {
25 get
26 {
27 if (target != null)
28 {
29 return moldCard.H;
30 }
31 return 1;
32 }
33 }
34
35 public override int CostMoney
36 {
37 get
38 {
39 if (target != null)
40 {
41 return 0;
42 }
43 return 0;
44 }
45 }
46
48
49 public override bool AllowMiddleClickFunc => target == null;
50
52
54
55 public override bool ShouldHideBuildMenu => target != null;
56
57 public override bool IsRoofEditMode(Card c = null)
58 {
60 }
61
63 {
64 return HitResult.Invalid;
65 }
66
67 public override bool CanInstaComplete(TaskMoveInstalled t)
68 {
70 }
71
72 public override MeshPass GetGuidePass(Point point)
73 {
75 }
76
77 public void Activate(Thing t)
78 {
79 Activate();
80 SetTarget(t);
81 onetime = true;
82 EClass.ui.hud.hint.UpdateText();
83 }
84
85 public override void OnActivate()
86 {
87 onetime = false;
88 list = base.Designations.moveInstalled;
89 target = (moldCard = null);
90 base.OnActivate();
91 }
92
93 public override void OnDeactivate()
94 {
95 target = (moldCard = (mold.target = null));
96 }
97
98 public override void OnCreateMold(bool processing)
99 {
100 mold.target = target;
101 }
102
103 public override HitResult HitTest(Point point, Point start)
104 {
105 if (EClass.debug.enable)
106 {
107 switch (EInput.hotkey)
108 {
109 case 0:
110 EClass._map.SetDecal(point.x, point.z);
111 break;
112 case 1:
113 EClass._map.AddDecal(point.x, point.z, 2);
114 break;
115 }
116 }
117 if (target == null)
118 {
120 {
121 return HitResult.Warning;
122 }
123 if (GetTarget(point) != null)
124 {
125 return HitResult.Valid;
126 }
127 return HitResult.Default;
128 }
129 if (target.isChara && CheckEnemyNearBy(target, point, msg: false))
130 {
131 return HitResult.Invalid;
132 }
133 moldCard.ignoreStackHeight = Input.GetKey(KeyCode.LeftControl);
135 {
136 if (target.isChara && (point.IsBlocked || point.HasChara))
137 {
138 return HitResult.Invalid;
139 }
140 if (!EClass._map.bounds.Contains(point))
141 {
142 return HitResult.Invalid;
143 }
144 }
145 return base.HitTest(point, start);
146 }
147
148 public void SetTarget(Card _target)
149 {
151 foreach (TaskMoveInstalled taskMoveInstalled in array)
152 {
153 if (taskMoveInstalled.target == _target)
154 {
155 taskMoveInstalled.Destroy();
156 }
157 }
158 target = (mold.target = _target);
159 if (target.isThing)
160 {
162 moldCard.placeState = PlaceState.installed;
163 }
164 else
165 {
166 moldCard = CharaGen.Create(_target.id);
167 moldCard.bio.SetGender(_target.bio.gender);
168 moldCard.idSkin = target.idSkin;
169 }
170 EClass.ui.hud.hint.UpdateText();
171 }
172
173 public Card GetTarget(Point point)
174 {
176 }
177
178 public bool CanPutAway()
179 {
181 {
182 return true;
183 }
184 if (target == null || target.isChara || target.trait.CanOnlyCarry)
185 {
186 return false;
187 }
188 return true;
189 }
190
191 public bool TryPutAway()
192 {
193 if (!CanPutAway())
194 {
195 return false;
196 }
198 {
199 SE.Beep();
200 return false;
201 }
202 SE.Click();
203 target = null;
204 EClass.ui.hud.hint.UpdateText();
205 return true;
206 }
207
208 public bool CheckEnemyNearBy(Card t, Point p, bool msg = true)
209 {
211 {
212 bool flag = true;
213 foreach (Chara chara in EClass._map.charas)
214 {
215 if (chara.hostility <= Hostility.Enemy && chara.Dist(p) <= 6)
216 {
217 flag = false;
218 }
219 }
220 if (!flag)
221 {
222 if (msg)
223 {
224 SE.BeepSmall();
225 EClass.ui.Say("enemyInMap".langGame());
226 }
227 return true;
228 }
229 }
230 return false;
231 }
232
233 public override void OnProcessTiles(Point point, int dir)
234 {
235 if (target == null)
236 {
237 Card t = GetTarget(point);
238 if (CheckEnemyNearBy(t, t.pos))
239 {
240 return;
241 }
243 {
244 ActPlan actPlan = new ActPlan
245 {
246 pos = point.Copy(),
247 ignoreAddCondition = true,
248 input = ActInput.AllAction,
249 altAction = true
250 };
251 t.trait.TrySetAct(actPlan);
252 if (actPlan.list.Count > 0)
253 {
254 UIContextMenu uIContextMenu = EClass.ui.CreateContextMenuInteraction();
255 uIContextMenu.AddButton("move", delegate
256 {
257 SetTarget(t);
258 SE.Click();
259 });
260 foreach (ActPlan.Item i in actPlan.list)
261 {
262 uIContextMenu.AddButton(i.GetTextContext(showName: false), delegate
263 {
264 i.act.Perform();
265 });
266 }
267 uIContextMenu.Show();
268 return;
269 }
270 }
271 SetTarget(t);
272 SE.Click();
273 }
274 else
275 {
276 if (CheckEnemyNearBy(target, point))
277 {
278 return;
279 }
280 mold.dir = moldCard.dir;
281 mold.altitude = moldCard.altitude;
282 if (target.isChara)
283 {
284 target.Chara.orgPos?.Set(point);
285 }
286 base.OnProcessTiles(point, dir);
287 target.ignoreStackHeight = moldCard.ignoreStackHeight;
288 target.freePos = moldCard.freePos;
289 target.fx = (FreePos ? moldCard.fx : 0f);
290 target.fy = (FreePos ? moldCard.fy : 0f);
291 if (target.isChara && (bool)EClass.debug)
292 {
293 foreach (Thing thing in point.Things)
294 {
295 if (thing.trait is TraitShackle traitShackle)
296 {
297 traitShackle.Restrain(target.Chara);
298 }
299 }
300 }
301 if (target.isThing)
302 {
303 target.isRoofItem = IsRoofEditMode();
304 if (target.isRoofItem)
305 {
307 }
308 if (!target.isRoofItem)
309 {
310 target.ForeachPoint(delegate(Point p, bool center)
311 {
312 if (p.IsBlocked && p.HasChara)
313 {
314 foreach (Chara item in p.ListCharas())
315 {
316 EClass.pc.Kick(item, ignoreSelf: true, karmaLoss: false, show: false);
317 }
318 }
319 });
320 }
321 }
322 SE.Click();
324 {
326 }
327 target = null;
328 }
329 }
330
331 public override void OnRenderTile(Point point, HitResult result, int dir)
332 {
333 if (target == null)
334 {
335 Card card = GetTarget(point);
336 if (card != null && card.isThing)
337 {
338 card.Thing.RenderMarker(point, active: true, result, main: true, -1, useCurrentPosition: true);
339 }
340 base.OnRenderTile(point, (result != HitResult.Valid) ? result : (EClass.scene.mouseTarget.CanCycle() ? HitResult.Warning : HitResult.Default), dir);
341 return;
342 }
343 if (moldCard == null)
344 {
345 base.OnRenderTile(point, result, dir);
346 return;
347 }
348 moldCard.SetFreePos(point);
349 if (result != HitResult.Valid && result != HitResult.Warning)
350 {
351 base.OnRenderTile(point, result, dir);
352 }
353 else
354 {
355 int desiredDir = target.TileType.GetDesiredDir(point, moldCard.dir);
356 if (desiredDir != -1)
357 {
358 int num2 = (moldCard.dir = desiredDir);
359 dir = num2;
360 }
361 bool flag = !base.tileSelector.multisize || (base.tileSelector.firstInMulti && base.Summary.count == base.Summary.countValid);
362 moldCard.RenderMarker(point, active: false, result, flag, -1);
363 if (flag)
364 {
365 target.trait.OnRenderTile(point, result, dir);
366 }
367 }
368 EClass.screen.guide.DrawLine(target.pos.PositionCenter(), point.PositionCenter());
369 }
370
371 public override void RotateUnderMouse()
372 {
373 if (target != null)
374 {
375 SE.Rotate();
376 moldCard.Rotate();
377 }
378 else
379 {
380 base.RotateUnderMouse();
381 }
382 }
383
384 public override void InputWheel(int wheel)
385 {
387 {
388 if (target != null && target.TileType.MaxAltitude > 0)
389 {
390 moldCard.ChangeAltitude(wheel);
391 }
392 else if (EClass.scene.mouseTarget.CanCycle())
393 {
395 }
396 else
397 {
398 base.InputWheel(wheel);
399 }
400 }
401 }
402
403 public override void OnCancel()
404 {
405 if (target != null)
406 {
407 target = null;
408 if (onetime)
409 {
410 base.OnCancel();
411 }
412 }
413 else
414 {
415 base.OnCancel();
416 }
417 }
418
419 public override void OnFinishProcessTiles()
420 {
421 if (onetime)
422 {
423 Deactivate();
424 }
425 }
426}
ActInput
Definition: ActInput.cs:2
HitResult
Definition: HitResult.cs:2
Hostility
Definition: Hostility.cs:2
PlaceState
Definition: PlaceState.cs:2
bool _IsRoofEditMode(Card c)
Definition: AM_Build.cs:74
override void OnProcessTiles(Point point, int dir)
override int hitH
override bool ShouldHideBuildMenu
override int hitW
override void OnActivate()
override HitResult HitTest(Point point, Point start)
override BaseTileMap.CardIconMode cardIconMode
override bool CanInstaComplete(TaskMoveInstalled t)
override void RotateUnderMouse()
override HitResult HitResultOnDesignation(Point p)
override BaseTileSelector.SelectType selectType
override void OnCancel()
void SetTarget(Card _target)
override bool AllowMiddleClickFunc
override void InputWheel(int wheel)
override void OnDeactivate()
Card GetTarget(Point point)
override MeshPass GetGuidePass(Point point)
override bool IsRoofEditMode(Card c=null)
override void OnFinishProcessTiles()
void Activate(Thing t)
override int CostMoney
override void OnCreateMold(bool processing)
bool CheckEnemyNearBy(Card t, Point p, bool msg=true)
override void OnRenderTile(Point point, HitResult result, int dir)
List list
Definition: ActPlan.cs:163
static AM_Build Build
Definition: ActionMode.cs:49
ScreenGuide guide
void SetGender(int g)
Definition: Biography.cs:450
void RefreshSprite()
Definition: Card.cs:11
virtual bool isThing
Definition: Card.cs:1957
virtual Chara Chara
Definition: Card.cs:1946
void SetPlaceState(PlaceState newState, bool byPlayer=false)
Definition: Card.cs:3454
bool isRoofItem
Definition: Card.cs:550
Biography bio
Definition: Card.cs:40
void ForeachPoint(Action< Point, bool > action)
Definition: Card.cs:6942
Point pos
Definition: Card.cs:55
Trait trait
Definition: Card.cs:49
int altitude
Definition: Card.cs:214
virtual bool isChara
Definition: Card.cs:1959
int Dist(Card c)
Definition: Card.cs:6777
int idSkin
Definition: Card.cs:346
int H
Definition: Card.cs:2226
Thing Duplicate(int num)
Definition: Card.cs:3191
int dir
Definition: Card.cs:142
int W
Definition: Card.cs:2214
bool freePos
Definition: Card.cs:490
CardRenderer renderer
Definition: Card.cs:57
bool ignoreStackHeight
Definition: Card.cs:610
static Chara Create(string id, int lv=-1)
Definition: CharaGen.cs:17
Definition: Chara.cs:10
Point orgPos
Definition: Chara.cs:21
Hostility hostility
Definition: Chara.cs:276
bool enable
Definition: CoreDebug.cs:285
bool ignoreBuildRule
Definition: CoreDebug.cs:184
Definition: EClass.cs:5
static Game game
Definition: EClass.cs:8
static Scene scene
Definition: EClass.cs:30
static Map _map
Definition: EClass.cs:18
static BaseGameScreen screen
Definition: EClass.cs:32
static Player player
Definition: EClass.cs:12
static CoreDebug debug
Definition: EClass.cs:48
static UI ui
Definition: EClass.cs:16
Definition: EInput.cs:8
static bool isCtrlDown
Definition: EInput.cs:263
static bool isAltDown
Definition: EInput.cs:265
static int hotkey
Definition: EInput.cs:283
bool FreePos
Definition: Game.cs:99
Config config
Definition: Game.cs:215
bool Contains(int dx, int dz)
Definition: MapBounds.cs:38
void SetDecal(int x, int z, int id=0, int amount=1, bool refresh=true)
Definition: Map.cs:2029
bool PutAway(Card c)
Definition: Map.cs:2510
TaskManager tasks
Definition: Map.cs:34
List< Chara > charas
Definition: Map.cs:81
void AddDecal(int x, int z, int id, int amount=1, bool refresh=true)
Definition: Map.cs:2007
MapBounds bounds
Definition: Map.cs:52
bool instaComplete
Definition: Player.cs:956
void CycleTarget(int a)
Definition: PointTarget.cs:204
bool CanCycle()
Definition: PointTarget.cs:215
Definition: Point.cs:9
Point Copy()
Definition: Point.cs:467
Point Set(int _x, int _z)
Definition: Point.cs:479
bool IsBlocked
Definition: Point.cs:339
List< Thing > Things
Definition: Point.cs:314
int x
Definition: Point.cs:36
int z
Definition: Point.cs:39
ref Vector3 PositionCenter()
Definition: Point.cs:563
bool HasChara
Definition: Point.cs:226
PointTarget mouseTarget
Definition: Scene.cs:129
MeshPass passGuideBlock
Definition: ScreenGuide.cs:5
void DrawLine(Vector3 from, Vector3 to)
Definition: ScreenGuide.cs:17
DesignationList< TaskMoveInstalled > moveInstalled
Definition: TaskManager.cs:24
Designations designations
Definition: TaskManager.cs:62
Status Destroy()
Definition: Task.cs:31
Definition: Thing.cs:8
virtual void TrySetAct(ActPlan p)
Definition: Trait.cs:984
virtual bool ShowContextOnPick
Definition: Trait.cs:171
virtual bool CanOnlyCarry
Definition: Trait.cs:283
void Show(UIItem i)
void AddButton(Func< string > funcText, UnityAction action=null)