protected override void OnCleanUp() { base.OnCleanUp(); int cell = Grid.PosToCell(this); MyGrid.Masks[cell] &= ~MyGrid.Flags.HasScaffolding; Pathfinding.Instance.AddDirtyNavGridCell(cell); if (Patches.ChainedDeconstruction) { Deconstructable deconstructable = base.GetComponent <Deconstructable>(); if (deconstructable != null && deconstructable.IsMarkedForDeconstruction()) { MyGrid.ForceDeconstruction(Grid.CellLeft(cell), false); MyGrid.ForceDeconstruction(Grid.CellRight(cell), false); } } }
public static void ForceDeconstruction(int cell, bool isStairs = true) { if (!Grid.IsValidCell(cell)) { return; } if (isStairs) { if (!MyGrid.IsStair(cell)) { return; } } else if (!MyGrid.IsScaffolding(cell)) { return; } int layer = (int)ObjectLayer.Building; if (!isStairs) { layer = (int)ObjectLayer.AttachableBuilding; } GameObject gameObject = Grid.Objects[cell, layer]; if (gameObject == null) { return; } //if (!isStairs && gameObject.GetComponent<Scaffolding>() == null) return; Deconstructable deconstructable = gameObject.GetComponent <Deconstructable>(); if (deconstructable == null) { return; } if (!deconstructable.IsMarkedForDeconstruction()) { return; } deconstructable.CompleteWork(null); }