Elin Modding Docs Doc
Loading...
Searching...
No Matches
HotItemHeld.cs
1using System;
2using UnityEngine;
3
4// Token: 0x0200061B RID: 1563
6{
7 // Token: 0x06002B7F RID: 11135 RVA: 0x000F3F40 File Offset: 0x000F2140
8 public static bool CanChangeHeightByWheel()
9 {
10 return (EClass.scene.actionMode.IsBuildMode || EInput.isShiftDown) && (!EClass._zone.IsRegion && EClass.pc.held != null && HotItemHeld.taskBuild != null && HotItemHeld.recipe.MaxAltitude != 0) && HotItemHeld.taskBuild.CanPerform();
11 }
12
13 // Token: 0x06002B80 RID: 11136 RVA: 0x000F3FA0 File Offset: 0x000F21A0
14 public static bool CanRotate()
15 {
16 return !EClass._zone.IsRegion && EClass.pc.held != null && (EClass._zone is Zone_Tent || EClass._zone.IsPCFaction || !EClass.pc.held.trait.CanBeOnlyBuiltInHome) && (!EClass._zone.RestrictBuild || EClass.pc.held.trait.CanBuildInTown) && (EClass.pc.held.trait is TraitTile || (HotItemHeld.taskBuild != null && (HotItemHeld.taskBuild.CanPerform() || !ActionMode.Adv.planAll.HasAct)));
17 }
18
19 // Token: 0x17000C87 RID: 3207
20 // (get) Token: 0x06002B81 RID: 11137 RVA: 0x000F405C File Offset: 0x000F225C
21 public override Act act
22 {
23 get
24 {
25 return this.GetAct();
26 }
27 }
28
29 // Token: 0x06002B82 RID: 11138 RVA: 0x000F4064 File Offset: 0x000F2264
30 public HotItemHeld()
31 {
32 }
33
34 // Token: 0x06002B83 RID: 11139 RVA: 0x000F406C File Offset: 0x000F226C
35 public HotItemHeld(Thing t)
36 {
37 this.thing = t;
38 }
39
40 // Token: 0x06002B84 RID: 11140 RVA: 0x000F407C File Offset: 0x000F227C
41 public override void OnSetCurrentItem()
42 {
43 ActionMode.Build.altitude = 0;
44 HotItemHeld.disableTool = false;
45 if (EClass.pc.held != this.thing)
46 {
47 EClass.pc.HoldCard(this.thing, -1);
48 }
49 HotItemHeld.taskBuild = null;
50 RecipeManager.BuildList();
51 HotItemHeld.recipe = this.thing.trait.GetRecipe();
52 if (this.thing.trait is TraitCatalyst)
53 {
54 this._act = (this.thing.trait as TraitCatalyst).CreateAct();
55 }
56 if (HotItemHeld.lastHeld != this.thing)
57 {
58 this.thing.trait.OnHeld();
59 }
60 HotItemHeld.lastHeld = this.thing;
61 if (this.thing.trait is TraitToolRange)
62 {
63 EClass.pc.ranged = this.thing;
64 }
65 }
66
67 // Token: 0x06002B85 RID: 11141 RVA: 0x000F4154 File Offset: 0x000F2354
68 public override void OnUnselect()
69 {
70 HotItemHeld.taskBuild = null;
71 HotItemHeld.recipe = null;
72 if (EClass.pc.held == this.thing)
73 {
74 EClass.pc.PickHeld(false);
75 }
76 }
77
78 // Token: 0x06002B86 RID: 11142 RVA: 0x000F4180 File Offset: 0x000F2380
79 public Act GetAct()
80 {
81 if (this.thing.trait is TraitRod)
82 {
83 return new ActZap();
84 }
85 if (this.thing.trait is TraitToolRange)
86 {
87 return ACT.Ranged;
88 }
89 if (this.thing.HasElement(241, 1))
90 {
91 return new AI_PlayMusic();
92 }
93 if (this.thing.HasElement(220, 1))
94 {
95 return new TaskMine();
96 }
97 if (this.thing.HasElement(225, 1))
98 {
99 return new TaskCut();
100 }
101 if (this.thing.HasElement(230, 1))
102 {
103 return new TaskDig
104 {
105 mode = TaskDig.Mode.RemoveFloor
106 };
107 }
108 if (this.thing.HasElement(286, 1))
109 {
110 return new TaskPlow();
111 }
112 if (this.thing.HasElement(245, 1))
113 {
114 return new AI_Fish();
115 }
116 if (this.thing.HasElement(237, 1))
117 {
118 return new AI_TendAnimal();
119 }
120 return this._act;
121 }
122
123 // Token: 0x06002B87 RID: 11143 RVA: 0x000F427C File Offset: 0x000F247C
124 public Act GetSelfAct()
125 {
126 if (this.lost)
127 {
128 return null;
129 }
130 if (this.thing.trait.CanDrink(EClass.pc))
131 {
132 return new AI_Drink
133 {
134 target = this.thing
135 };
136 }
137 if (this.thing.trait.CanEat(EClass.pc))
138 {
139 return new AI_Eat
140 {
141 cook = false
142 };
143 }
144 if (this.thing.trait.CanRead(EClass.pc))
145 {
146 return new AI_Read
147 {
148 target = this.thing
149 };
150 }
151 return null;
152 }
153
154 // Token: 0x06002B88 RID: 11144 RVA: 0x000F430C File Offset: 0x000F250C
155 public override bool TrySetAct(ActPlan p)
156 {
157 HotItemHeld.taskBuild = null;
158 if (!HotItemHeld.disableTool)
159 {
160 if (p.IsSelf && this.thing.trait.CanUse(EClass.pc))
161 {
162 return p.TrySetAct(this.thing.trait.LangUse, () => this.thing.trait.OnUse(p.cc), this.thing, null, -1, false, true, false);
163 }
164 if (EClass.scene.mouseTarget.target is Card && this.thing.trait.CanUse(EClass.pc, EClass.scene.mouseTarget.target as Card))
165 {
166 return p.TrySetAct(this.thing.trait.LangUse, () => this.thing.trait.OnUse(p.cc, EClass.scene.mouseTarget.target as Card), this.thing, null, -1, false, true, false);
167 }
168 if (this.thing.trait.CanUse(EClass.pc, p.pos))
169 {
170 return p.TrySetAct(this.thing.trait.LangUse, () => this.thing.trait.OnUse(p.cc, p.pos), this.thing, null, -1, false, true, false);
171 }
172 if (this.thing.trait.IsTool)
173 {
174 if (this.TrySetToolAct(p))
175 {
176 return true;
177 }
178 }
179 else
180 {
181 this.thing.trait.TrySetHeldAct(p);
182 }
183 if (p.HasAct || this.thing.trait.IsTool)
184 {
185 return true;
186 }
187 }
188 if (p.pos.Equals(EClass.pc.pos))
189 {
190 Act selfAct = this.GetSelfAct();
191 if (selfAct != null)
192 {
193 p.TrySetAct(selfAct, this.thing);
194 return true;
195 }
196 }
197 if (p.IsSelfOrNeighbor)
198 {
199 Thing installed = p.pos.Installed;
200 if (installed != null)
201 {
202 Trait trait = installed.trait;
203 }
204 Chara tg = p.pos.FirstVisibleChara();
205 if (tg != null && tg != EClass.pc && !tg.IsDisabled && tg.IsNeutralOrAbove() && EClass.pc.held != null && tg.CanAcceptGift(EClass.pc, EClass.pc.held))
206 {
207 string lang = "actGive";
208 if (tg.Evalue(1232) > 0 && EClass.pc.held.trait is TraitDrinkMilkMother)
209 {
210 lang = "actMilk";
211 }
212 p.TrySetAct(lang, delegate()
213 {
214 if (!tg.IsValidGiftWeight(EClass.pc.held, 1))
215 {
216 tg.Talk("tooHeavy", null, null, false);
217 return true;
218 }
219 if (EClass.core.config.game.confirmGive)
220 {
221 Dialog.YesNo("dialogGive".lang(EClass.pc.held.GetName(NameStyle.Full, 1), null, null, null, null), new Action(base.<TrySetAct>g__func|4), null, "yes", "no");
222 }
223 else
224 {
225 base.<TrySetAct>g__func|4();
226 }
227 return true;
228 }, this.thing, null, 1, false, true, false);
229 }
230 }
231 if (p.HasAct)
232 {
233 return true;
234 }
235 if (!this.thing.c_isImportant && (p.IsSelfOrNeighbor || this.thing.trait.CanExtendBuild))
236 {
237 Chara chara = p.pos.FirstVisibleChara();
238 if ((chara == null || chara == EClass.pc || chara.IsNeutralOrAbove()) && HotItemHeld.recipe != null && (!this.thing.trait.IsThrowMainAction || EInput.isShiftDown || HotItemHeld.disableTool))
239 {
240 HotItemHeld.taskBuild = new TaskBuild
241 {
242 recipe = HotItemHeld.recipe,
243 held = EClass.pc.held,
244 pos = p.pos.Copy()
245 };
246 AM_Build build = ActionMode.Build;
247 build.bridgeHeight = -1;
248 build.recipe = HotItemHeld.taskBuild.recipe;
249 build.mold = HotItemHeld.taskBuild;
250 build.SetAltitude(HotItemHeld.recipe.tileType.AltitudeAsDir ? HotItemHeld.recipe._dir : build.altitude);
251 p.TrySetAct(HotItemHeld.taskBuild, null);
252 }
253 }
254 if (p.HasAct)
255 {
256 return true;
257 }
258 if (ActThrow.CanThrow(EClass.pc, this.thing, null, p.pos))
259 {
260 ActPlan p2 = p;
261 ActThrow actThrow = new ActThrow();
262 actThrow.target = this.thing;
263 Card card = p.pos.FindAttackTarget();
264 actThrow.pcTarget = ((card != null) ? card.Chara : null);
265 if (p2.TrySetAct(actThrow, this.thing))
266 {
267 return true;
268 }
269 }
270 return false;
271 }
272
273 // Token: 0x06002B89 RID: 11145 RVA: 0x000F47A8 File Offset: 0x000F29A8
274 public bool TrySetToolAct(ActPlan p)
275 {
276 this.thing.trait.TrySetHeldAct(p);
277 if (p.HasAct)
278 {
279 return true;
280 }
281 Cell cell = p.pos.cell;
282 Point pos = p.pos;
283 if (cell.HasBlock && TaskMine.CanMine(pos, this.thing) && p.TrySetAct(new TaskMine
284 {
285 pos = pos.Copy()
286 }, null))
287 {
288 return true;
289 }
290 if (pos.IsHidden)
291 {
292 return true;
293 }
294 if (this.thing.trait is TraitToolRange)
295 {
296 if (!EClass.pc.CanSeeSimple(pos))
297 {
298 return true;
299 }
300 Card tc = null;
301 foreach (Chara chara in pos.ListVisibleCharas())
302 {
303 if (chara.isSynced && chara.IsAliveInCurrentZone)
304 {
305 tc = chara;
306 break;
307 }
308 }
309 EClass.pc.ranged = this.thing;
310 p.TrySetAct(ACT.Ranged, tc);
311 return true;
312 }
313 else
314 {
315 if (cell.IsTopWaterAndNoSnow && this.thing.HasElement(245, 1) && p.TrySetAct(new AI_Fish
316 {
317 pos = pos.Copy()
318 }, null))
319 {
320 return true;
321 }
322 if (p.IsNeighborBlocked)
323 {
324 return true;
325 }
326 TaskHarvest taskHarvest = TaskHarvest.TryGetAct(EClass.pc, pos);
327 if (taskHarvest != null && p.TrySetAct(taskHarvest, null))
328 {
329 return true;
330 }
331 TraitToolWaterPot traitToolWaterPot = this.thing.trait as TraitToolWaterPot;
332 if (cell.IsTopWaterAndNoSnow)
333 {
334 if (traitToolWaterPot != null && traitToolWaterPot.owner.c_charges < traitToolWaterPot.MaxCharge && p.TrySetAct(new TaskDrawWater
335 {
336 pot = traitToolWaterPot,
337 pos = pos.Copy()
338 }, null))
339 {
340 return true;
341 }
342 }
343 else
344 {
345 if (traitToolWaterPot != null && !p.pos.HasBridge && traitToolWaterPot.owner.c_charges > 0 && pos.cell.sourceSurface.tag.Contains("soil") && p.TrySetAct(new TaskPourWater
346 {
347 pot = traitToolWaterPot,
348 pos = pos.Copy()
349 }, null))
350 {
351 return true;
352 }
353 if (this.thing.HasElement(286, 1) && p.TrySetAct(new TaskPlow
354 {
355 pos = pos.Copy()
356 }, null))
357 {
358 return true;
359 }
360 if (this.thing.HasElement(230, 1) && p.TrySetAct(new TaskDig
361 {
362 pos = pos.Copy(),
363 mode = TaskDig.Mode.RemoveFloor
364 }, null))
365 {
366 return true;
367 }
368 if (TaskMine.CanMine(pos, this.thing) && p.TrySetAct(new TaskMine
369 {
370 pos = pos.Copy()
371 }, null))
372 {
373 return true;
374 }
375 }
376 if (pos.HasChara)
377 {
378 Chara firstChara = pos.FirstChara;
379 Chara pc = EClass.pc;
380 }
381 if (this.thing.HasTag(CTAG.throwWeapon) && ActThrow.CanThrow(EClass.pc, this.thing, null, p.pos))
382 {
383 ActThrow actThrow = new ActThrow();
384 actThrow.target = this.thing;
385 Card card = p.pos.FindAttackTarget();
386 actThrow.pcTarget = ((card != null) ? card.Chara : null);
387 if (p.TrySetAct(actThrow, this.thing))
388 {
389 return true;
390 }
391 }
392 return false;
393 }
394 }
395
396 // Token: 0x06002B8A RID: 11146 RVA: 0x000F4ADC File Offset: 0x000F2CDC
397 public unsafe override void OnRenderTile(Point point, HitResult result, int dir)
398 {
399 if (EClass.game.config.showGuideGrid)
400 {
401 for (int i = point.z - 1; i < point.z + 2; i++)
402 {
403 for (int j = point.x - 1; j < point.x + 2; j++)
404 {
405 EClass.screen.guide.passGuideFloor.Add(Point.shared.Set(j, i), 1f, 0f);
406 }
407 }
408 }
409 if (HotItemHeld.taskBuild == null || !HotItemHeld.taskBuild.IsRunning)
410 {
411 return;
412 }
413 if (!HotItemHeld.recipe.MultiSize && !HotItemHeld.taskBuild.CanProgress())
414 {
415 return;
416 }
417 if (!HotItemHeld.taskBuild.CanPerform(EClass.pc, null, point))
418 {
419 return;
420 }
421 EClass.screen.guide.isActive = false;
422 ActionMode.Build.OnRenderTile(point, HitResult.Valid, HotItemHeld.taskBuild.recipe._dir);
423 EClass.screen.guide.isActive = true;
424 if (HotItemHeld.recipe.MultiSize)
425 {
426 point.ForeachMultiSize(HotItemHeld.recipe.W, HotItemHeld.recipe.H, delegate(Point pos, bool main)
427 {
428 Vector3 vector = *pos.Position();
429 vector.z -= 0.01f;
430 EClass.screen.guide.passGuideFloor.Add(ref vector, 0f, 0f);
431 });
432 }
433 }
434
435 // Token: 0x0400183C RID: 6204
436 public static Thing lastHeld;
437
438 // Token: 0x0400183D RID: 6205
439 public static TaskBuild taskBuild;
440
441 // Token: 0x0400183E RID: 6206
442 public static Recipe recipe;
443
444 // Token: 0x0400183F RID: 6207
445 public static bool disableTool;
446}
Definition ACT.cs:6
Definition Act.2.cs:7
Definition Card.cs:13
Definition Cell.cs:10
Definition Chara.cs:12
Definition Point.cs:11
Definition Thing.cs:10
Definition Trait.cs:9