private static void DeconstructAdjacent(Deconstructable rootDeconstructable, string name, int layer) { GetAdjacentCells(rootDeconstructable.GetCell()) .Select(cell => Grid.Objects[cell, layer]) .Where(gameObject => gameObject != null) .Select(gameObject => gameObject.GetComponent <Deconstructable>()) .Where(deconstructable => deconstructable != null && deconstructable.IsMarkedForDeconstruction() && deconstructable.name == name && false == DestroyedGetter(deconstructable) ) .Do(deconstructable => { var cell = deconstructable.GetCell(); if (CellsDeconstructed.Contains(cell)) { return; } ForceDeconstruct.Invoke(deconstructable, NullWorkerParameter); CellsDeconstructed.Add(cell); DeconstructAdjacent(deconstructable, name, layer); }); }
public static void Postfix(Deconstructable __instance) { try { if (State.TileNames.Contains(__instance.name)) { State.TileColors[__instance.GetCell()] = null; } } catch (Exception e) { State.Common.Logger.LogOnce(e); } }
private static int GetLayerForDeconstructable(Deconstructable deconstructable) { var cell = deconstructable.GetCell(); for (int layer = 1; layer <= 27; layer++) { var obj = Grid.Objects[cell, layer]; if (obj != null && obj.GetComponent <Deconstructable>() == deconstructable) { return(layer); } } return((int)ObjectLayer.Building); }
public static void Postfix(Deconstructable __instance) { try { var buildingComplete = __instance.GetComponent <BuildingComplete>(); var buildingName = buildingComplete.name.Replace("Complete", string.Empty); if (State.TileNames.Contains(buildingName)) { State.TileColors[__instance.GetCell()] = null; } } catch (Exception e) { Common.Logger.LogOnce(e); } }
public static void Postfix(Deconstructable __instance) { ResetCell(__instance.GetCell()); }