Elin Decompiled Documentation EA 23.336 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 int TopHeight(Point p)
73 {
74 if (target != null && moldCard != null && moldCard.altitude != 0)
75 {
76 return moldCard.altitude;
77 }
78 return -1;
79 }
80
81 public override MeshPass GetGuidePass(Point point)
82 {
84 }
85
86 public void Activate(Thing t)
87 {
88 Activate();
89 SetTarget(t);
90 onetime = true;
91 EClass.ui.hud.hint.UpdateText();
92 }
93
94 public override void OnActivate()
95 {
96 onetime = false;
97 list = base.Designations.moveInstalled;
98 target = (moldCard = null);
99 base.OnActivate();
100 }
101
102 public override void OnDeactivate()
103 {
104 target = (moldCard = (mold.target = null));
105 }
106
107 public override void OnCreateMold(bool processing)
108 {
109 mold.target = target;
110 }
111
112 public override HitResult HitTest(Point point, Point start)
113 {
114 if (EClass.debug.enable)
115 {
116 switch (EInput.hotkey)
117 {
118 case 0:
119 EClass._map.SetDecal(point.x, point.z);
120 break;
121 case 1:
122 EClass._map.AddDecal(point.x, point.z, 2);
123 break;
124 }
125 }
126 if (target == null)
127 {
129 {
130 return HitResult.Warning;
131 }
132 if (GetTarget(point) != null)
133 {
134 return HitResult.Valid;
135 }
136 return HitResult.Default;
137 }
138 if (target.isChara && CheckEnemyNearBy(target, point, msg: false))
139 {
140 return HitResult.Invalid;
141 }
142 moldCard.ignoreStackHeight = Input.GetKey(KeyCode.LeftControl);
144 {
145 if (target.isChara && (point.IsBlocked || point.HasChara))
146 {
147 return HitResult.Invalid;
148 }
149 if (!EClass._map.bounds.Contains(point))
150 {
151 return HitResult.Invalid;
152 }
153 }
154 return base.HitTest(point, start);
155 }
156
157 public void SetTarget(Card _target)
158 {
160 foreach (TaskMoveInstalled taskMoveInstalled in array)
161 {
162 if (taskMoveInstalled.target == _target)
163 {
164 taskMoveInstalled.Destroy();
165 }
166 }
167 target = (mold.target = _target);
168 if (target.isThing)
169 {
171 moldCard.placeState = PlaceState.installed;
173 }
174 else
175 {
176 moldCard = CharaGen.Create(_target.id);
177 moldCard.bio.SetGender(_target.bio.gender);
178 moldCard.idSkin = target.idSkin;
179 }
180 EClass.ui.hud.hint.UpdateText();
181 }
182
183 public Card GetTarget(Point point)
184 {
186 }
187
188 public bool CanPutAway()
189 {
190 if (target == null)
191 {
192 return false;
193 }
195 {
196 return true;
197 }
199 {
200 return false;
201 }
202 return true;
203 }
204
205 public bool TryPutAway()
206 {
207 if (!CanPutAway())
208 {
209 return false;
210 }
212 {
213 SE.Beep();
214 return false;
215 }
216 SE.Click();
217 target = null;
218 EClass.ui.hud.hint.UpdateText();
219 return true;
220 }
221
222 public bool CheckEnemyNearBy(Card t, Point p, bool msg = true)
223 {
225 {
226 bool flag = true;
227 foreach (Chara chara in EClass._map.charas)
228 {
229 if (chara.hostility <= Hostility.Enemy && chara.Dist(p) <= 6)
230 {
231 flag = false;
232 }
233 }
234 if (!flag)
235 {
236 if (msg)
237 {
238 SE.BeepSmall();
239 EClass.ui.Say("enemyInMap".langGame());
240 }
241 return true;
242 }
243 }
244 return false;
245 }
246
247 public override void OnProcessTiles(Point point, int dir)
248 {
249 if (target == null)
250 {
251 Card t = GetTarget(point);
252 if (CheckEnemyNearBy(t, t.pos))
253 {
254 return;
255 }
257 {
258 ActPlan actPlan = new ActPlan
259 {
260 pos = point.Copy(),
261 ignoreAddCondition = true,
262 input = ActInput.AllAction,
263 altAction = true
264 };
265 t.trait.TrySetAct(actPlan);
266 if (actPlan.list.Count > 0)
267 {
268 UIContextMenu uIContextMenu = EClass.ui.CreateContextMenuInteraction();
269 uIContextMenu.AddButton("move", delegate
270 {
271 SetTarget(t);
272 SE.Click();
273 });
274 foreach (ActPlan.Item i in actPlan.list)
275 {
276 uIContextMenu.AddButton(i.GetTextContext(showName: false), delegate
277 {
278 i.act.Perform();
279 });
280 }
281 uIContextMenu.Show();
282 return;
283 }
284 }
285 SetTarget(t);
286 SE.Click();
287 }
288 else
289 {
290 if (CheckEnemyNearBy(target, point))
291 {
292 return;
293 }
294 mold.dir = moldCard.dir;
295 mold.altitude = moldCard.altitude;
296 if (target.isChara)
297 {
298 target.Chara.orgPos?.Set(point);
299 }
300 base.OnProcessTiles(point, dir);
301 target.ignoreStackHeight = moldCard.ignoreStackHeight;
302 target.freePos = moldCard.freePos;
303 target.fx = (FreePos ? moldCard.fx : 0f);
304 target.fy = (FreePos ? moldCard.fy : 0f);
305 if (target.isChara && (bool)EClass.debug)
306 {
307 foreach (Thing thing in point.Things)
308 {
309 if (thing.trait is TraitShackle traitShackle)
310 {
311 traitShackle.Restrain(target.Chara);
312 }
313 }
314 }
315 if (target.isThing)
316 {
317 bool isRoofItem = target.isRoofItem;
318 target.isRoofItem = IsRoofEditMode();
319 if (target.isRoofItem)
320 {
322 }
323 else if (isRoofItem)
324 {
326 }
327 if (!target.isRoofItem)
328 {
329 target.ForeachPoint(delegate(Point p, bool center)
330 {
331 if (p.IsBlocked && p.HasChara)
332 {
333 foreach (Chara item in p.ListCharas())
334 {
335 EClass.pc.Kick(item, ignoreSelf: true, karmaLoss: false, show: false);
336 }
337 }
338 });
339 }
340 }
341 SE.Click();
343 {
345 }
346 target = null;
347 }
348 }
349
350 public override void OnRenderTile(Point point, HitResult result, int dir)
351 {
352 if (target == null)
353 {
354 Card card = GetTarget(point);
355 if (card != null && card.isThing)
356 {
357 card.Thing.RenderMarker(point, active: true, result, main: true, -1, useCurrentPosition: true);
358 }
359 base.OnRenderTile(point, (result != HitResult.Valid) ? result : (EClass.scene.mouseTarget.CanCycle() ? HitResult.Warning : HitResult.Default), dir);
360 return;
361 }
362 if (moldCard == null)
363 {
364 base.OnRenderTile(point, result, dir);
365 return;
366 }
367 moldCard.SetFreePos(point);
368 if (result != HitResult.Valid && result != HitResult.Warning)
369 {
370 base.OnRenderTile(point, result, dir);
371 }
372 else
373 {
374 int desiredDir = target.TileType.GetDesiredDir(point, moldCard.dir);
375 if (desiredDir != -1)
376 {
377 int num2 = (moldCard.dir = desiredDir);
378 dir = num2;
379 }
380 bool flag = !base.tileSelector.multisize || (base.tileSelector.firstInMulti && base.Summary.count == base.Summary.countValid);
381 moldCard.RenderMarker(point, active: false, result, flag, -1);
382 if (flag)
383 {
384 target.trait.OnRenderTile(point, result, dir);
385 }
386 }
387 EClass.screen.guide.DrawLine(target.pos.PositionCenter(), point.PositionCenter());
388 }
389
390 public override void RotateUnderMouse()
391 {
392 if (target != null)
393 {
394 SE.Rotate();
395 moldCard.Rotate();
396 }
397 else
398 {
399 base.RotateUnderMouse();
400 }
401 }
402
403 public override void InputWheel(int wheel)
404 {
406 {
407 if (target != null && target.TileType.MaxAltitude > 0)
408 {
409 moldCard.ChangeAltitude(wheel);
410 }
411 else if (EClass.scene.mouseTarget.CanCycle())
412 {
414 }
415 else
416 {
417 base.InputWheel(wheel);
418 }
419 }
420 }
421
422 public override void OnCancel()
423 {
424 if (target != null)
425 {
426 target = null;
427 if (onetime)
428 {
429 base.OnCancel();
430 }
431 }
432 else
433 {
434 base.OnCancel();
435 }
436 }
437
438 public override void OnFinishProcessTiles()
439 {
440 if (onetime)
441 {
442 Deactivate();
443 }
444 }
445}
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()
override int TopHeight(Point p)
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:166
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:2133
virtual Chara Chara
Definition: Card.cs:2122
void SetPlaceState(PlaceState newState, bool byPlayer=false)
Definition: Card.cs:3925
bool isRoofItem
Definition: Card.cs:581
virtual CardRenderer _CreateRenderer()
Definition: Card.cs:6428
Biography bio
Definition: Card.cs:45
void ForeachPoint(Action< Point, bool > action)
Definition: Card.cs:8357
Point pos
Definition: Card.cs:60
Trait trait
Definition: Card.cs:54
int altitude
Definition: Card.cs:233
virtual bool isChara
Definition: Card.cs:2135
int Dist(Card c)
Definition: Card.cs:8192
int idSkin
Definition: Card.cs:365
int H
Definition: Card.cs:2436
Thing Duplicate(int num)
Definition: Card.cs:3622
int dir
Definition: Card.cs:149
int W
Definition: Card.cs:2424
bool freePos
Definition: Card.cs:521
CardRenderer renderer
Definition: Card.cs:64
bool ignoreStackHeight
Definition: Card.cs:641
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:295
bool enable
Definition: CoreDebug.cs:301
bool ignoreBuildRule
Definition: CoreDebug.cs:200
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:274
static int hotkey
Definition: EInput.cs:294
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:2097
bool PutAway(Card c)
Definition: Map.cs:2611
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:2075
MapBounds bounds
Definition: Map.cs:52
bool instaComplete
Definition: Player.cs:1225
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:592
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:1227
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)