/// <summary> /// Sets the furniture to be deconstructed. /// </summary> public void SetDeconstructJob() { if (SettingsKeyHolder.DeveloperMode) { Deconstruct(); return; } if (IsBeingDestroyed) { return; // Already being destroyed, don't do anything more } IsBeingDestroyed = true; Jobs.CancelAll(); Deconstruct deconstructOrder = GetOrderAction <Deconstruct>(); if (deconstructOrder != null) { Job job = deconstructOrder.CreateJob(Tile, Type); job.OnJobCompleted += (inJob) => Deconstruct(); World.Current.jobQueue.Enqueue(job); } }
/// <summary> /// Deconstructs the utility. /// </summary> public void Deconstruct() { if (Tile.Utilities != null) { Jobs.CancelAll(); } // Just unregister our grid, it will get reregistered if there are any other utilities on this grid World.Current.PowerNetwork.RemoveGrid(Grid); // We call lua to decostruct EventActions.Trigger("OnUninstall", this); Tile.UnplaceUtility(this); if (Removed != null) { Removed(this); } Deconstruct deconstructOrder = GetOrderAction <Deconstruct>(); if (deconstructOrder != null) { foreach (KeyValuePair <string, int> inv in deconstructOrder.Inventory) { World.Current.InventoryManager.PlaceInventoryAround(Tile, new Inventory(inv.Key, inv.Value)); } } // We should inform our neighbours that they have just lost a neighbour. // Just trigger their OnChangedCallback. foreach (Tile neighbor in Tile.GetNeighbours()) { if (neighbor.Utilities != null && neighbor.Utilities.ContainsKey(this.Type)) { Utility neighborUtility = neighbor.Utilities[this.Type]; if (neighborUtility.Changed != null) { neighborUtility.Changed(neighborUtility); } if (neighborUtility.Grid == this.Grid) { neighborUtility.Grid = new UtilityGrid(); } neighborUtility.UpdateGrid(neighborUtility); neighborUtility.Grid.Split(); } } // At this point, no DATA structures should be pointing to us, so we // should get garbage-collected. }
/// <summary> /// Deconstructs the utility. /// </summary> public void Deconstruct() { int x = Tile.X; int y = Tile.Y; if (Tile.Utilities != null) { Jobs.CancelAll(); } // We call lua to decostruct EventActions.Trigger("OnUninstall", this); Tile.UnplaceUtility(this); if (Removed != null) { Removed(this); } if (deconstructInventory != null) { foreach (Inventory inv in deconstructInventory) { inv.MaxStackSize = PrototypeManager.Inventory.Get(inv.Type).maxStackSize; World.Current.InventoryManager.PlaceInventoryAround(Tile, inv.Clone()); } } // We should inform our neighbours that they have just lost a // neighbour regardless of type. // Just trigger their OnChangedCallback. for (int xpos = x - 1; xpos < x + 2; xpos++) { for (int ypos = y - 1; ypos < y + 2; ypos++) { Tile tileAt = World.Current.GetTileAt(xpos, ypos, Tile.Z); if (tileAt != null && tileAt.Utilities != null) { foreach (Utility neighborUtility in tileAt.Utilities.Values) { if (neighborUtility.Changed != null) { neighborUtility.Changed(neighborUtility); } } } } } // At this point, no DATA structures should be pointing to us, so we // should get garbage-collected. }
public void SetUninstallJob() { if (SettingsKeyHolder.DeveloperMode) { Uninstall(); return; } Jobs.CancelAll(); Uninstall uninstallOrder = GetOrderAction<Uninstall>(); if (uninstallOrder != null) { Job job = uninstallOrder.CreateJob(Tile, Type); job.OnJobCompleted += (inJob) => Uninstall(); World.Current.jobQueue.Enqueue(job); } }
/// <summary> /// Sets the furniture to be deconstructed. /// </summary> public void SetDeconstructJob() { if (Settings.GetSetting("DialogBoxSettings_developerModeToggle", false)) { Deconstruct(); return; } if (IsBeingDestroyed) { return; // Already being destroyed, don't do anything more } IsBeingDestroyed = true; Jobs.CancelAll(); Job job = PrototypeManager.FurnitureDeconstructJob.Get(Type).Clone(); job.tile = Tile; job.OnJobCompleted += (inJob) => Deconstruct(); World.Current.jobQueue.Enqueue(job); }