8 public override bool CanBeOnlyBuiltInHome
18 public override bool CanBuildInTown
28 public override bool CanBeDisassembled
32 return !this.owner.IsInstalled;
38 public override Trait.TileMode tileMode
42 return Trait.TileMode.Door;
48 public override bool HaveUpdate
58 public override bool IsOpenSight
68 public override bool IsDoor
78 public override bool ShouldRefreshTile
88 public virtual string idSound
97 public override void Update()
103 public void ForceClose()
107 this.ToggleDoor(
true,
true);
112 public void TryOpen(
Chara c)
118 this.ToggleDoor(
true,
true);
119 c.Say(
"openDoor", c, this.owner,
null,
null);
120 if (this.owner.Cell.Front.FirstThing !=
null)
122 foreach (
Thing thing
in this.owner.Cell.Front.Things)
124 thing.trait.OnOpenDoor(c);
127 if (this.owner.Cell.Right.FirstThing !=
null)
129 foreach (
Thing thing2
in this.owner.Cell.Right.Things)
131 thing2.trait.OnOpenDoor(c);
137 public void TryAutoClose()
140 if (this.count > 5 && this.CanClose() && this.IsOpen())
142 this.ToggleDoor(
false,
true);
147 public virtual bool CanClose()
150 foreach (
Thing thing
in this.owner.pos.Things)
152 if (!thing.isRoofItem && !thing.isHidden && thing.TileType !=
TileType.Illumination)
161 return !this.owner.pos.HasChara;
165 public virtual bool IsOpen()
167 int dir = this.owner.dir;
168 Cell cell = this.owner.pos.cell;
169 return (!cell.Right.HasFullBlockOrWallOrFence && (dir == 0 || dir == 2) && cell.Front.HasFullBlockOrWallOrFence) || (!cell.Front.HasFullBlockOrWallOrFence && (dir == 1 || dir == 3) && cell.Right.HasFullBlockOrWallOrFence);
173 public bool IsValid()
175 int dir = this.owner.dir;
176 Cell cell = this.owner.pos.cell;
181 bool hasFullBlockOrWallOrFence = cell.Left.HasFullBlockOrWallOrFence;
182 bool hasFullBlockOrWallOrFence2 = cell.Right.HasFullBlockOrWallOrFence;
183 bool hasFullBlockOrWallOrFence3 = cell.Front.HasFullBlockOrWallOrFence;
184 bool hasFullBlockOrWallOrFence4 = cell.Back.HasFullBlockOrWallOrFence;
185 return (hasFullBlockOrWallOrFence ? 1 : 0) + (hasFullBlockOrWallOrFence2 ? 1 : 0) + (hasFullBlockOrWallOrFence3 ? 1 : 0) + (hasFullBlockOrWallOrFence4 ? 1 : 0) < 3 && ((hasFullBlockOrWallOrFence && hasFullBlockOrWallOrFence2) || (hasFullBlockOrWallOrFence3 && hasFullBlockOrWallOrFence4));
189 public virtual void ToggleDoor(
bool sound =
true,
bool refresh =
true)
193 this.owner.PlaySound(this.idSound, 1f,
true);
199 EClass._map.RefreshSingleTile(this.owner.pos.x,
this.owner.pos.z);
200 EClass._map.RefreshFOV(this.owner.pos.x,
this.owner.pos.z, 6,
false);
205 public void RotateDoor()
207 if (this.owner.dir == 0)
211 else if (this.owner.dir == 1)
215 else if (this.owner.dir == 2)
223 this.owner.renderer.RefreshSprite();
227 public override void TrySetAct(
ActPlan p)
229 if (!this.owner.IsInstalled)
233 if (this.owner.c_lockLv > 0)
237 target = this.owner.Thing
243 p.TrySetAct(
"actOpen", delegate()
245 EClass.pc.Say(
"openDoor",
EClass.pc,
this.owner,
null,
null);
246 this.ToggleDoor(
true,
true);
248 }, this.owner, CursorSystem.Door, 1,
false,
true,
false);
251 if (this.CanClose() && p.altAction)
253 p.TrySetAct(
"actClose", delegate()
255 EClass.pc.Say(
"close",
EClass.pc,
this.owner,
null,
null);
256 this.ToggleDoor(
true,
true);
258 }, this.owner, CursorSystem.Door, 1,
false,
true,
false);