Elin Decompiled Documentation EA 23.262 Nightly Patch 1
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;
164 }
165 else
166 {
167 moldCard = CharaGen.Create(_target.id);
168 moldCard.bio.SetGender(_target.bio.gender);
169 moldCard.idSkin = target.idSkin;
170 }
171 EClass.ui.hud.hint.UpdateText();
172 }
173
174 public Card GetTarget(Point point)
175 {
177 }
178
179 public bool CanPutAway()
180 {
181 if (target == null)
182 {
183 return false;
184 }
186 {
187 return true;
188 }
190 {
191 return false;
192 }
193 return true;
194 }
195
196 public bool TryPutAway()
197 {
198 if (!CanPutAway())
199 {
200 return false;
201 }
203 {
204 SE.Beep();
205 return false;
206 }
207 SE.Click();
208 target = null;
209 EClass.ui.hud.hint.UpdateText();
210 return true;
211 }
212
213 public bool CheckEnemyNearBy(Card t, Point p, bool msg = true)
214 {
216 {
217 bool flag = true;
218 foreach (Chara chara in EClass._map.charas)
219 {
220 if (chara.hostility <= Hostility.Enemy && chara.Dist(p) <= 6)
221 {
222 flag = false;
223 }
224 }
225 if (!flag)
226 {
227 if (msg)
228 {
229 SE.BeepSmall();
230 EClass.ui.Say("enemyInMap".langGame());
231 }
232 return true;
233 }
234 }
235 return false;
236 }
237
238 public override void OnProcessTiles(Point point, int dir)
239 {
240 if (target == null)
241 {
242 Card t = GetTarget(point);
243 if (CheckEnemyNearBy(t, t.pos))
244 {
245 return;
246 }
248 {
249 ActPlan actPlan = new ActPlan
250 {
251 pos = point.Copy(),
252 ignoreAddCondition = true,
253 input = ActInput.AllAction,
254 altAction = true
255 };
256 t.trait.TrySetAct(actPlan);
257 if (actPlan.list.Count > 0)
258 {
259 UIContextMenu uIContextMenu = EClass.ui.CreateContextMenuInteraction();
260 uIContextMenu.AddButton("move", delegate
261 {
262 SetTarget(t);
263 SE.Click();
264 });
265 foreach (ActPlan.Item i in actPlan.list)
266 {
267 uIContextMenu.AddButton(i.GetTextContext(showName: false), delegate
268 {
269 i.act.Perform();
270 });
271 }
272 uIContextMenu.Show();
273 return;
274 }
275 }
276 SetTarget(t);
277 SE.Click();
278 }
279 else
280 {
281 if (CheckEnemyNearBy(target, point))
282 {
283 return;
284 }
285 mold.dir = moldCard.dir;
286 mold.altitude = moldCard.altitude;
287 if (target.isChara)
288 {
289 target.Chara.orgPos?.Set(point);
290 }
291 base.OnProcessTiles(point, dir);
292 target.ignoreStackHeight = moldCard.ignoreStackHeight;
293 target.freePos = moldCard.freePos;
294 target.fx = (FreePos ? moldCard.fx : 0f);
295 target.fy = (FreePos ? moldCard.fy : 0f);
296 if (target.isChara && (bool)EClass.debug)
297 {
298 foreach (Thing thing in point.Things)
299 {
300 if (thing.trait is TraitShackle traitShackle)
301 {
302 traitShackle.Restrain(target.Chara);
303 }
304 }
305 }
306 if (target.isThing)
307 {
308 bool isRoofItem = target.isRoofItem;
309 target.isRoofItem = IsRoofEditMode();
310 if (target.isRoofItem)
311 {
313 }
314 else if (isRoofItem)
315 {
317 }
318 if (!target.isRoofItem)
319 {
320 target.ForeachPoint(delegate(Point p, bool center)
321 {
322 if (p.IsBlocked && p.HasChara)
323 {
324 foreach (Chara item in p.ListCharas())
325 {
326 EClass.pc.Kick(item, ignoreSelf: true, karmaLoss: false, show: false);
327 }
328 }
329 });
330 }
331 }
332 SE.Click();
334 {
336 }
337 target = null;
338 }
339 }
340
341 public override void OnRenderTile(Point point, HitResult result, int dir)
342 {
343 if (target == null)
344 {
345 Card card = GetTarget(point);
346 if (card != null && card.isThing)
347 {
348 card.Thing.RenderMarker(point, active: true, result, main: true, -1, useCurrentPosition: true);
349 }
350 base.OnRenderTile(point, (result != HitResult.Valid) ? result : (EClass.scene.mouseTarget.CanCycle() ? HitResult.Warning : HitResult.Default), dir);
351 return;
352 }
353 if (moldCard == null)
354 {
355 base.OnRenderTile(point, result, dir);
356 return;
357 }
358 moldCard.SetFreePos(point);
359 if (result != HitResult.Valid && result != HitResult.Warning)
360 {
361 base.OnRenderTile(point, result, dir);
362 }
363 else
364 {
365 int desiredDir = target.TileType.GetDesiredDir(point, moldCard.dir);
366 if (desiredDir != -1)
367 {
368 int num2 = (moldCard.dir = desiredDir);
369 dir = num2;
370 }
371 bool flag = !base.tileSelector.multisize || (base.tileSelector.firstInMulti && base.Summary.count == base.Summary.countValid);
372 moldCard.RenderMarker(point, active: false, result, flag, -1);
373 if (flag)
374 {
375 target.trait.OnRenderTile(point, result, dir);
376 }
377 }
378 EClass.screen.guide.DrawLine(target.pos.PositionCenter(), point.PositionCenter());
379 }
380
381 public override void RotateUnderMouse()
382 {
383 if (target != null)
384 {
385 SE.Rotate();
386 moldCard.Rotate();
387 }
388 else
389 {
390 base.RotateUnderMouse();
391 }
392 }
393
394 public override void InputWheel(int wheel)
395 {
397 {
398 if (target != null && target.TileType.MaxAltitude > 0)
399 {
400 moldCard.ChangeAltitude(wheel);
401 }
402 else if (EClass.scene.mouseTarget.CanCycle())
403 {
405 }
406 else
407 {
408 base.InputWheel(wheel);
409 }
410 }
411 }
412
413 public override void OnCancel()
414 {
415 if (target != null)
416 {
417 target = null;
418 if (onetime)
419 {
420 base.OnCancel();
421 }
422 }
423 else
424 {
425 base.OnCancel();
426 }
427 }
428
429 public override void OnFinishProcessTiles()
430 {
431 if (onetime)
432 {
433 Deactivate();
434 }
435 }
436}
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:473
void RefreshSprite()
Definition: Card.cs:11
virtual bool isThing
Definition: Card.cs:2082
virtual Chara Chara
Definition: Card.cs:2071
void SetPlaceState(PlaceState newState, bool byPlayer=false)
Definition: Card.cs:3772
bool isRoofItem
Definition: Card.cs:579
virtual CardRenderer _CreateRenderer()
Definition: Card.cs:6014
Biography bio
Definition: Card.cs:45
void ForeachPoint(Action< Point, bool > action)
Definition: Card.cs:7903
Point pos
Definition: Card.cs:60
Trait trait
Definition: Card.cs:54
int altitude
Definition: Card.cs:231
virtual bool isChara
Definition: Card.cs:2084
int Dist(Card c)
Definition: Card.cs:7738
int idSkin
Definition: Card.cs:363
int H
Definition: Card.cs:2369
Thing Duplicate(int num)
Definition: Card.cs:3469
int dir
Definition: Card.cs:147
int W
Definition: Card.cs:2357
bool freePos
Definition: Card.cs:519
CardRenderer renderer
Definition: Card.cs:62
bool ignoreStackHeight
Definition: Card.cs:639
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:293
bool enable
Definition: CoreDebug.cs:286
bool ignoreBuildRule
Definition: CoreDebug.cs:185
Definition: EClass.cs:6
static Game game
Definition: EClass.cs:9
static Scene scene
Definition: EClass.cs:31
static Map _map
Definition: EClass.cs:19
static BaseGameScreen screen
Definition: EClass.cs:33
static Player player
Definition: EClass.cs:13
static CoreDebug debug
Definition: EClass.cs:49
static UI ui
Definition: EClass.cs:17
Definition: EInput.cs:8
static bool isCtrlDown
Definition: EInput.cs:263
static int hotkey
Definition: EInput.cs:283
bool FreePos
Definition: Game.cs:100
Config config
Definition: Game.cs:219
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:1155
void CycleTarget(int a)
Definition: PointTarget.cs:204
bool CanCycle()
Definition: PointTarget.cs:215
Definition: Point.cs:9
Point Copy()
Definition: Point.cs:491
Point Set(int _x, int _z)
Definition: Point.cs:503
bool IsBlocked
Definition: Point.cs:363
List< Thing > Things
Definition: Point.cs:338
int x
Definition: Point.cs:36
int z
Definition: Point.cs:39
ref Vector3 PositionCenter()
Definition: Point.cs:587
bool HasChara
Definition: Point.cs:238
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:1056
virtual bool CanPutAway
Definition: Trait.cs:150
virtual bool ShowContextOnPick
Definition: Trait.cs:191
void Show(UIItem i)
void AddButton(Func< string > funcText, UnityAction action=null)