Elin Decompiled Documentation EA 23.200 Stable
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 bool isRoofItem = target.isRoofItem;
304 target.isRoofItem = IsRoofEditMode();
305 if (target.isRoofItem)
306 {
308 }
309 else if (isRoofItem)
310 {
312 }
313 if (!target.isRoofItem)
314 {
315 target.ForeachPoint(delegate(Point p, bool center)
316 {
317 if (p.IsBlocked && p.HasChara)
318 {
319 foreach (Chara item in p.ListCharas())
320 {
321 EClass.pc.Kick(item, ignoreSelf: true, karmaLoss: false, show: false);
322 }
323 }
324 });
325 }
326 }
327 SE.Click();
329 {
331 }
332 target = null;
333 }
334 }
335
336 public override void OnRenderTile(Point point, HitResult result, int dir)
337 {
338 if (target == null)
339 {
340 Card card = GetTarget(point);
341 if (card != null && card.isThing)
342 {
343 card.Thing.RenderMarker(point, active: true, result, main: true, -1, useCurrentPosition: true);
344 }
345 base.OnRenderTile(point, (result != HitResult.Valid) ? result : (EClass.scene.mouseTarget.CanCycle() ? HitResult.Warning : HitResult.Default), dir);
346 return;
347 }
348 if (moldCard == null)
349 {
350 base.OnRenderTile(point, result, dir);
351 return;
352 }
353 moldCard.SetFreePos(point);
354 if (result != HitResult.Valid && result != HitResult.Warning)
355 {
356 base.OnRenderTile(point, result, dir);
357 }
358 else
359 {
360 int desiredDir = target.TileType.GetDesiredDir(point, moldCard.dir);
361 if (desiredDir != -1)
362 {
363 int num2 = (moldCard.dir = desiredDir);
364 dir = num2;
365 }
366 bool flag = !base.tileSelector.multisize || (base.tileSelector.firstInMulti && base.Summary.count == base.Summary.countValid);
367 moldCard.RenderMarker(point, active: false, result, flag, -1);
368 if (flag)
369 {
370 target.trait.OnRenderTile(point, result, dir);
371 }
372 }
373 EClass.screen.guide.DrawLine(target.pos.PositionCenter(), point.PositionCenter());
374 }
375
376 public override void RotateUnderMouse()
377 {
378 if (target != null)
379 {
380 SE.Rotate();
381 moldCard.Rotate();
382 }
383 else
384 {
385 base.RotateUnderMouse();
386 }
387 }
388
389 public override void InputWheel(int wheel)
390 {
391 if (target != null && target.TileType.MaxAltitude > 0)
392 {
393 moldCard.ChangeAltitude(wheel);
394 }
395 else if (EClass.scene.mouseTarget.CanCycle())
396 {
398 }
399 else
400 {
401 base.InputWheel(wheel);
402 }
403 }
404
405 public override void OnCancel()
406 {
407 if (target != null)
408 {
409 target = null;
410 if (onetime)
411 {
412 base.OnCancel();
413 }
414 }
415 else
416 {
417 base.OnCancel();
418 }
419 }
420
421 public override void OnFinishProcessTiles()
422 {
423 if (onetime)
424 {
425 Deactivate();
426 }
427 }
428}
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:164
static AM_Build Build
Definition: ActionMode.cs:49
ScreenGuide guide
void SetGender(int g)
Definition: Biography.cs:469
void RefreshSprite()
Definition: Card.cs:11
virtual bool isThing
Definition: Card.cs:2043
virtual Chara Chara
Definition: Card.cs:2032
void SetPlaceState(PlaceState newState, bool byPlayer=false)
Definition: Card.cs:3645
bool isRoofItem
Definition: Card.cs:564
Biography bio
Definition: Card.cs:42
void ForeachPoint(Action< Point, bool > action)
Definition: Card.cs:7571
Point pos
Definition: Card.cs:57
Trait trait
Definition: Card.cs:51
int altitude
Definition: Card.cs:216
virtual bool isChara
Definition: Card.cs:2045
int Dist(Card c)
Definition: Card.cs:7406
int idSkin
Definition: Card.cs:348
int H
Definition: Card.cs:2328
Thing Duplicate(int num)
Definition: Card.cs:3342
int dir
Definition: Card.cs:144
int W
Definition: Card.cs:2316
bool freePos
Definition: Card.cs:504
CardRenderer renderer
Definition: Card.cs:59
bool ignoreStackHeight
Definition: Card.cs:624
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:289
bool enable
Definition: CoreDebug.cs:286
bool ignoreBuildRule
Definition: CoreDebug.cs:185
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 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:2051
bool PutAway(Card c)
Definition: Map.cs:2532
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:2029
MapBounds bounds
Definition: Map.cs:52
bool instaComplete
Definition: Player.cs:1111
void CycleTarget(int a)
Definition: PointTarget.cs:204
bool CanCycle()
Definition: PointTarget.cs:215
Definition: Point.cs:9
Point Copy()
Definition: Point.cs:479
Point Set(int _x, int _z)
Definition: Point.cs:491
bool IsBlocked
Definition: Point.cs:351
List< Thing > Things
Definition: Point.cs:326
int x
Definition: Point.cs:36
int z
Definition: Point.cs:39
ref Vector3 PositionCenter()
Definition: Point.cs:575
bool HasChara
Definition: Point.cs:226
PointTarget mouseTarget
Definition: Scene.cs:135
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:1029
virtual bool ShowContextOnPick
Definition: Trait.cs:178
virtual bool CanOnlyCarry
Definition: Trait.cs:292
void Show(UIItem i)
void AddButton(Func< string > funcText, UnityAction action=null)