8 public static bool CanChangeHeightByWheel()
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();
14 public static bool CanRotate()
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)));
21 public override Act act
41 public override void OnSetCurrentItem()
43 ActionMode.Build.altitude = 0;
44 HotItemHeld.disableTool =
false;
45 if (
EClass.pc.held !=
this.thing)
47 EClass.pc.HoldCard(this.thing, -1);
49 HotItemHeld.taskBuild =
null;
51 HotItemHeld.recipe = this.thing.trait.GetRecipe();
58 this.thing.trait.OnHeld();
60 HotItemHeld.lastHeld = this.thing;
63 EClass.pc.ranged = this.thing;
68 public override void OnUnselect()
70 HotItemHeld.taskBuild =
null;
71 HotItemHeld.recipe =
null;
72 if (
EClass.pc.held ==
this.thing)
89 if (this.thing.HasElement(241, 1))
93 if (this.thing.HasElement(220, 1))
97 if (this.thing.HasElement(225, 1))
101 if (this.thing.HasElement(230, 1))
105 mode = TaskDig.Mode.RemoveFloor
108 if (this.thing.HasElement(286, 1))
112 if (this.thing.HasElement(245, 1))
116 if (this.thing.HasElement(237, 1))
124 public Act GetSelfAct()
130 if (this.thing.trait.CanDrink(
EClass.pc))
137 if (this.thing.trait.CanEat(
EClass.pc))
144 if (this.thing.trait.CanRead(
EClass.pc))
155 public override bool TrySetAct(
ActPlan p)
157 HotItemHeld.taskBuild =
null;
160 if (p.IsSelf &&
this.thing.trait.CanUse(
EClass.pc))
162 return p.TrySetAct(this.thing.trait.LangUse, () =>
this.thing.trait.OnUse(p.cc),
this.thing,
null, -1,
false,
true,
false);
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);
168 if (this.thing.trait.CanUse(
EClass.pc, p.pos))
170 return p.TrySetAct(this.thing.trait.LangUse, () =>
this.thing.trait.OnUse(p.cc, p.pos),
this.thing,
null, -1,
false,
true,
false);
172 if (this.thing.trait.IsTool)
174 if (this.TrySetToolAct(p))
181 this.thing.trait.TrySetHeldAct(p);
183 if (p.HasAct ||
this.thing.trait.IsTool)
188 if (p.pos.Equals(
EClass.pc.pos))
190 Act selfAct = this.GetSelfAct();
193 p.TrySetAct(selfAct, this.thing);
197 if (p.IsSelfOrNeighbor)
199 Thing installed = p.pos.Installed;
200 if (installed !=
null)
202 Trait trait = installed.trait;
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))
207 string lang =
"actGive";
212 p.TrySetAct(lang, delegate()
214 if (!tg.IsValidGiftWeight(
EClass.pc.held, 1))
216 tg.Talk(
"tooHeavy",
null,
null,
false);
219 if (
EClass.core.config.game.confirmGive)
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");
225 base.<TrySetAct>g__func|4();
228 }, this.thing,
null, 1,
false,
true,
false);
235 if (!this.thing.c_isImportant && (p.IsSelfOrNeighbor ||
this.thing.trait.CanExtendBuild))
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))
247 build.bridgeHeight = -1;
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))
274 public bool TrySetToolAct(
ActPlan p)
276 this.thing.trait.TrySetHeldAct(p);
281 Cell cell = p.pos.cell;
283 if (cell.HasBlock &&
TaskMine.CanMine(pos,
this.thing) && p.TrySetAct(
new TaskMine
296 if (!
EClass.pc.CanSeeSimple(pos))
301 foreach (
Chara chara
in pos.ListVisibleCharas())
303 if (chara.isSynced && chara.IsAliveInCurrentZone)
309 EClass.pc.ranged = this.thing;
310 p.TrySetAct(
ACT.Ranged, tc);
315 if (cell.IsTopWaterAndNoSnow &&
this.thing.HasElement(245, 1) && p.TrySetAct(
new AI_Fish
322 if (p.IsNeighborBlocked)
327 if (taskHarvest !=
null && p.TrySetAct(taskHarvest,
null))
332 if (cell.IsTopWaterAndNoSnow)
334 if (traitToolWaterPot !=
null && traitToolWaterPot.owner.c_charges < traitToolWaterPot.MaxCharge && p.TrySetAct(
new TaskDrawWater
336 pot = traitToolWaterPot,
345 if (traitToolWaterPot !=
null && !p.pos.HasBridge && traitToolWaterPot.owner.c_charges > 0 && pos.cell.sourceSurface.tag.Contains(
"soil") && p.TrySetAct(
new TaskPourWater
347 pot = traitToolWaterPot,
353 if (this.thing.HasElement(286, 1) && p.TrySetAct(
new TaskPlow
360 if (this.thing.HasElement(230, 1) && p.TrySetAct(
new TaskDig
363 mode = TaskDig.Mode.RemoveFloor
378 Chara firstChara = pos.FirstChara;
381 if (this.thing.HasTag(CTAG.throwWeapon) &&
ActThrow.CanThrow(
EClass.pc,
this.thing,
null, p.pos))
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))
397 public unsafe
override void OnRenderTile(
Point point, HitResult result,
int dir)
399 if (
EClass.game.config.showGuideGrid)
401 for (
int i = point.z - 1; i < point.z + 2; i++)
403 for (
int j = point.x - 1; j < point.x + 2; j++)
405 EClass.screen.guide.passGuideFloor.Add(
Point.shared.Set(j, i), 1f, 0f);
421 EClass.screen.guide.isActive =
false;
423 EClass.screen.guide.isActive =
true;
428 Vector3 vector = *pos.Position();
430 EClass.screen.guide.passGuideFloor.Add(ref vector, 0f, 0f);
436 public static Thing lastHeld;
442 public static Recipe recipe;
445 public static bool disableTool;