protected override void OnPaintCell(int cell, int distFromOrigin) { base.OnPaintCell(cell, distFromOrigin); recentlyAffectedCells.Add(cell); if (!recentAffectedCellColor.ContainsKey(cell)) { recentAffectedCellColor.Add(cell, settings.Element.substance.uiColour); } else { recentAffectedCellColor[cell] = settings.Element.substance.uiColour; } Game.CallbackInfo item = new Game.CallbackInfo(delegate { recentlyAffectedCells.Remove(cell); recentAffectedCellColor.Remove(cell); }, false); int index = Game.Instance.callbackManager.Add(item).index; int gameCell = cell; SimHashes id = settings.Element.id; CellElementEvent sandBoxTool = CellEventLogger.Instance.SandBoxTool; float mass = settings.Mass; float temperature = settings.temperature; int callbackIdx = index; SimMessages.ReplaceElement(gameCell, id, sandBoxTool, mass, temperature, Db.Get().Diseases.GetIndex(settings.Disease.IdHash), settings.diseaseCount, callbackIdx); SetBrushSize(brushRadius); }
protected override void OnPaintCell(int cell, int distFromOrigin) { base.OnPaintCell(cell, distFromOrigin); recentlyAffectedCells.Add(cell); Game.CallbackInfo item = new Game.CallbackInfo(delegate { recentlyAffectedCells.Remove(cell); }, false); int index = Game.Instance.callbackManager.Add(item).index; int gameCell = cell; SimHashes new_element = SimHashes.Vacuum; CellElementEvent sandBoxTool = CellEventLogger.Instance.SandBoxTool; float mass = 0f; float temperature = 0f; int callbackIdx = index; SimMessages.ReplaceElement(gameCell, new_element, sandBoxTool, mass, temperature, Db.Get().Diseases.GetIndex(settings.Disease.IdHash), 0, callbackIdx); HashSetPool <GameObject, SandboxDestroyerTool> .PooledHashSet pooledHashSet = HashSetPool <GameObject, SandboxDestroyerTool> .Allocate(); foreach (Pickupable item2 in Components.Pickupables.Items) { if (Grid.PosToCell(item2) == cell) { pooledHashSet.Add(item2.gameObject); } } foreach (BuildingComplete item3 in Components.BuildingCompletes.Items) { if (Grid.PosToCell(item3) == cell) { pooledHashSet.Add(item3.gameObject); } } if ((Object)Grid.Objects[cell, 1] != (Object)null) { pooledHashSet.Add(Grid.Objects[cell, 1]); } foreach (Crop item4 in Components.Crops.Items) { if (Grid.PosToCell(item4) == cell) { pooledHashSet.Add(item4.gameObject); } } foreach (Health item5 in Components.Health.Items) { if (Grid.PosToCell(item5) == cell) { pooledHashSet.Add(item5.gameObject); } } foreach (GameObject item6 in pooledHashSet) { Util.KDestroyGameObject(item6); } pooledHashSet.Recycle(); }
public static void ReplaceElement(int gameCell, SimHashes new_element, CellElementEvent ev, float mass, float temperature = -1f, byte diseaseIdx = byte.MaxValue, int diseaseCount = 0, int callbackIdx = -1) { int elementIndex = GetElementIndex(new_element); if (elementIndex != -1) { Element element = ElementLoader.elements[elementIndex]; float num = (temperature == -1f) ? element.defaultValues.temperature : temperature; int elementIdx = elementIndex; float temperature2 = num; byte disease_idx = diseaseIdx; ReplaceType replace_type = ReplaceType.Replace; ModifyCell(gameCell, elementIdx, temperature2, mass, disease_idx, diseaseCount, replace_type, false, callbackIdx); } }
private void PaintCell(int cell) { recentlyAffectedCells.Add(cell); Game.CallbackInfo item = new Game.CallbackInfo(delegate { recentlyAffectedCells.Remove(cell); }, false); int index = Game.Instance.callbackManager.Add(item).index; int gameCell = cell; SimHashes id = settings.Element.id; CellElementEvent sandBoxTool = CellEventLogger.Instance.SandBoxTool; float mass = settings.Mass; float temperature = settings.temperature; int callbackIdx = index; SimMessages.ReplaceElement(gameCell, id, sandBoxTool, mass, temperature, Db.Get().Diseases.GetIndex(settings.Disease.IdHash), settings.diseaseCount, callbackIdx); }
public void DestroySelf(System.Action onComplete) { callDestroy = false; for (int i = 0; i < building.PlacementCells.Length; i++) { int num = building.PlacementCells[i]; Game.Instance.RemoveSolidChangedFilter(num); Sim.Cell.Properties simCellProperties = GetSimCellProperties(); SimMessages.ClearCellProperties(num, (byte)simCellProperties); if (doReplaceElement && Grid.Element[num].id == primaryElement.ElementID) { HandleVector <int> .Handle handle = GameComps.DiseaseContainers.GetHandle(base.gameObject); if (handle.IsValid()) { DiseaseHeader header = GameComps.DiseaseContainers.GetHeader(handle); header.diseaseIdx = Grid.DiseaseIdx[num]; header.diseaseCount = Grid.DiseaseCount[num]; GameComps.DiseaseContainers.SetHeader(handle, header); } if (onComplete != null) { HandleVector <Game.CallbackInfo> .Handle handle2 = Game.Instance.callbackManager.Add(new Game.CallbackInfo(onComplete, false)); int gameCell = num; SimHashes new_element = SimHashes.Vacuum; CellElementEvent simCellOccupierDestroySelf = CellEventLogger.Instance.SimCellOccupierDestroySelf; float mass = 0f; float temperature = -1f; int index = handle2.index; SimMessages.ReplaceElement(gameCell, new_element, simCellOccupierDestroySelf, mass, temperature, byte.MaxValue, 0, index); } else { SimMessages.ReplaceElement(num, SimHashes.Vacuum, CellEventLogger.Instance.SimCellOccupierDestroySelf, 0f, -1f, byte.MaxValue, 0, -1); } SimMessages.SetStrength(num, 1, 1f); } else { Grid.SetSolid(num, false, CellEventLogger.Instance.SimCellOccupierDestroy); onComplete.Signal(); World.Instance.OnSolidChanged(num); GameScenePartitioner.Instance.TriggerEvent(num, GameScenePartitioner.Instance.solidChangedLayer, null); } } }
private void SetSimState(bool is_door_open, IList <int> cells) { PrimaryElement component = GetComponent <PrimaryElement>(); float num = component.Mass / (float)cells.Count; for (int i = 0; i < cells.Count; i++) { int num2 = cells[i]; DoorType doorType = this.doorType; if (doorType == DoorType.Pressure || doorType == DoorType.Sealed || doorType == DoorType.ManualPressure) { World.Instance.groundRenderer.MarkDirty(num2); if (is_door_open) { SimMessages.Dig(num2, Game.Instance.callbackManager.Add(new Game.CallbackInfo(OnSimDoorOpened, false)).index); if (ShouldBlockFallingSand) { SimMessages.ClearCellProperties(num2, 4); } else { SimMessages.SetCellProperties(num2, 4); } } else { HandleVector <Game.CallbackInfo> .Handle handle = Game.Instance.callbackManager.Add(new Game.CallbackInfo(OnSimDoorClosed, false)); float temperature = component.Temperature; if (temperature <= 0f) { temperature = component.Temperature; } int gameCell = num2; SimHashes elementID = component.ElementID; CellElementEvent doorClose = CellEventLogger.Instance.DoorClose; float mass = num; float temperature2 = temperature; int index = handle.index; SimMessages.ReplaceAndDisplaceElement(gameCell, elementID, doorClose, mass, temperature2, byte.MaxValue, 0, index); SimMessages.SetCellProperties(num2, 4); } } } }
protected override void OnPaintCell(int cell, int distFromOrigin) { base.OnPaintCell(cell, distFromOrigin); if (!recentlyAffectedCells.Contains(cell)) { recentlyAffectedCells.Add(cell); Game.CallbackInfo item = new Game.CallbackInfo(delegate { recentlyAffectedCells.Remove(cell); }, false); int index = Game.Instance.callbackManager.Add(item).index; float num = Grid.Temperature[cell]; num += SandboxToolParameterMenu.instance.settings.temperatureAdditive; num = Mathf.Clamp(num, 1f, 9999f); int gameCell = cell; SimHashes id = Grid.Element[cell].id; CellElementEvent sandBoxTool = CellEventLogger.Instance.SandBoxTool; float mass = Grid.Mass[cell]; float temperature = num; int callbackIdx = index; SimMessages.ReplaceElement(gameCell, id, sandBoxTool, mass, temperature, Grid.DiseaseIdx[cell], Grid.DiseaseCount[cell], callbackIdx); } }
protected override void OnPrefabInit() { base.OnPrefabInit(); Instance = this; SimMessagesSolid = (AddEvent(new CellSolidEvent("SimMessageSolid", "Sim Message", false, true)) as CellSolidEvent); SimCellOccupierDestroy = (AddEvent(new CellSolidEvent("SimCellOccupierClearSolid", "Sim Cell Occupier Destroy", false, true)) as CellSolidEvent); SimCellOccupierForceSolid = (AddEvent(new CellSolidEvent("SimCellOccupierForceSolid", "Sim Cell Occupier Force Solid", false, true)) as CellSolidEvent); SimCellOccupierSolidChanged = (AddEvent(new CellSolidEvent("SimCellOccupierSolidChanged", "Sim Cell Occupier Solid Changed", false, true)) as CellSolidEvent); DoorOpen = (AddEvent(new CellElementEvent("DoorOpen", "Door Open", true, true)) as CellElementEvent); DoorClose = (AddEvent(new CellElementEvent("DoorClose", "Door Close", true, true)) as CellElementEvent); Excavator = (AddEvent(new CellElementEvent("Excavator", "Excavator", true, true)) as CellElementEvent); DebugTool = (AddEvent(new CellElementEvent("DebugTool", "Debug Tool", true, true)) as CellElementEvent); SandBoxTool = (AddEvent(new CellElementEvent("SandBoxTool", "Sandbox Tool", true, true)) as CellElementEvent); TemplateLoader = (AddEvent(new CellElementEvent("TemplateLoader", "Template Loader", true, true)) as CellElementEvent); Scenario = (AddEvent(new CellElementEvent("Scenario", "Scenario", true, true)) as CellElementEvent); SimCellOccupierOnSpawn = (AddEvent(new CellElementEvent("SimCellOccupierOnSpawn", "Sim Cell Occupier OnSpawn", true, true)) as CellElementEvent); SimCellOccupierDestroySelf = (AddEvent(new CellElementEvent("SimCellOccupierDestroySelf", "Sim Cell Occupier Destroy Self", true, true)) as CellElementEvent); WorldGapManager = (AddEvent(new CellElementEvent("WorldGapManager", "World Gap Manager", true, true)) as CellElementEvent); ReceiveElementChanged = (AddEvent(new CellElementEvent("ReceiveElementChanged", "Sim Message", false, false)) as CellElementEvent); ObjectSetSimOnSpawn = (AddEvent(new CellElementEvent("ObjectSetSimOnSpawn", "Object set sim on spawn", true, true)) as CellElementEvent); DecompositionDirtyWater = (AddEvent(new CellElementEvent("DecompositionDirtyWater", "Decomposition dirty water", true, true)) as CellElementEvent); SendCallback = (AddEvent(new CellCallbackEvent("SendCallback", true, true)) as CellCallbackEvent); ReceiveCallback = (AddEvent(new CellCallbackEvent("ReceiveCallback", false, true)) as CellCallbackEvent); Dig = (AddEvent(new CellDigEvent(true)) as CellDigEvent); WorldDamageDelayedSpawnFX = (AddEvent(new CellAddRemoveSubstanceEvent("WorldDamageDelayedSpawnFX", "World Damage Delayed Spawn FX", false)) as CellAddRemoveSubstanceEvent); OxygenModifierSimUpdate = (AddEvent(new CellAddRemoveSubstanceEvent("OxygenModifierSimUpdate", "Oxygen Modifier SimUpdate", false)) as CellAddRemoveSubstanceEvent); LiquidChunkOnStore = (AddEvent(new CellAddRemoveSubstanceEvent("LiquidChunkOnStore", "Liquid Chunk On Store", false)) as CellAddRemoveSubstanceEvent); FallingWaterAddToSim = (AddEvent(new CellAddRemoveSubstanceEvent("FallingWaterAddToSim", "Falling Water Add To Sim", false)) as CellAddRemoveSubstanceEvent); ExploderOnSpawn = (AddEvent(new CellAddRemoveSubstanceEvent("ExploderOnSpawn", "Exploder OnSpawn", false)) as CellAddRemoveSubstanceEvent); ExhaustSimUpdate = (AddEvent(new CellAddRemoveSubstanceEvent("ExhaustSimUpdate", "Exhaust SimUpdate", false)) as CellAddRemoveSubstanceEvent); ElementConsumerSimUpdate = (AddEvent(new CellAddRemoveSubstanceEvent("ElementConsumerSimUpdate", "Element Consumer SimUpdate", false)) as CellAddRemoveSubstanceEvent); SublimatesEmit = (AddEvent(new CellAddRemoveSubstanceEvent("SublimatesEmit", "Sublimates Emit", false)) as CellAddRemoveSubstanceEvent); Mop = (AddEvent(new CellAddRemoveSubstanceEvent("Mop", "Mop", false)) as CellAddRemoveSubstanceEvent); OreMelted = (AddEvent(new CellAddRemoveSubstanceEvent("OreMelted", "Ore Melted", false)) as CellAddRemoveSubstanceEvent); ConstructTile = (AddEvent(new CellAddRemoveSubstanceEvent("ConstructTile", "ConstructTile", false)) as CellAddRemoveSubstanceEvent); Dumpable = (AddEvent(new CellAddRemoveSubstanceEvent("Dympable", "Dumpable", false)) as CellAddRemoveSubstanceEvent); Cough = (AddEvent(new CellAddRemoveSubstanceEvent("Cough", "Cough", false)) as CellAddRemoveSubstanceEvent); Meteor = (AddEvent(new CellAddRemoveSubstanceEvent("Meteor", "Meteor", false)) as CellAddRemoveSubstanceEvent); ElementChunkTransition = (AddEvent(new CellAddRemoveSubstanceEvent("ElementChunkTransition", "Element Chunk Transition", false)) as CellAddRemoveSubstanceEvent); OxyrockEmit = (AddEvent(new CellAddRemoveSubstanceEvent("OxyrockEmit", "Oxyrock Emit", false)) as CellAddRemoveSubstanceEvent); BleachstoneEmit = (AddEvent(new CellAddRemoveSubstanceEvent("BleachstoneEmit", "Bleachstone Emit", false)) as CellAddRemoveSubstanceEvent); UnstableGround = (AddEvent(new CellAddRemoveSubstanceEvent("UnstableGround", "Unstable Ground", false)) as CellAddRemoveSubstanceEvent); ConduitFlowEmptyConduit = (AddEvent(new CellAddRemoveSubstanceEvent("ConduitFlowEmptyConduit", "Conduit Flow Empty Conduit", false)) as CellAddRemoveSubstanceEvent); ConduitConsumerWrongElement = (AddEvent(new CellAddRemoveSubstanceEvent("ConduitConsumerWrongElement", "Conduit Consumer Wrong Element", false)) as CellAddRemoveSubstanceEvent); OverheatableMeltingDown = (AddEvent(new CellAddRemoveSubstanceEvent("OverheatableMeltingDown", "Overheatable MeltingDown", false)) as CellAddRemoveSubstanceEvent); FabricatorProduceMelted = (AddEvent(new CellAddRemoveSubstanceEvent("FabricatorProduceMelted", "Fabricator Produce Melted", false)) as CellAddRemoveSubstanceEvent); PumpSimUpdate = (AddEvent(new CellAddRemoveSubstanceEvent("PumpSimUpdate", "Pump SimUpdate", false)) as CellAddRemoveSubstanceEvent); WallPumpSimUpdate = (AddEvent(new CellAddRemoveSubstanceEvent("WallPumpSimUpdate", "Wall Pump SimUpdate", false)) as CellAddRemoveSubstanceEvent); Vomit = (AddEvent(new CellAddRemoveSubstanceEvent("Vomit", "Vomit", false)) as CellAddRemoveSubstanceEvent); Tears = (AddEvent(new CellAddRemoveSubstanceEvent("Tears", "Tears", false)) as CellAddRemoveSubstanceEvent); Pee = (AddEvent(new CellAddRemoveSubstanceEvent("Pee", "Pee", false)) as CellAddRemoveSubstanceEvent); AlgaeHabitat = (AddEvent(new CellAddRemoveSubstanceEvent("AlgaeHabitat", "AlgaeHabitat", false)) as CellAddRemoveSubstanceEvent); CO2FilterOxygen = (AddEvent(new CellAddRemoveSubstanceEvent("CO2FilterOxygen", "CO2FilterOxygen", false)) as CellAddRemoveSubstanceEvent); ToiletEmit = (AddEvent(new CellAddRemoveSubstanceEvent("ToiletEmit", "ToiletEmit", false)) as CellAddRemoveSubstanceEvent); ElementEmitted = (AddEvent(new CellAddRemoveSubstanceEvent("ElementEmitted", "Element Emitted", false)) as CellAddRemoveSubstanceEvent); CO2ManagerFixedUpdate = (AddEvent(new CellModifyMassEvent("CO2ManagerFixedUpdate", "CO2Manager FixedUpdate", false)) as CellModifyMassEvent); EnvironmentConsumerFixedUpdate = (AddEvent(new CellModifyMassEvent("EnvironmentConsumerFixedUpdate", "EnvironmentConsumer FixedUpdate", false)) as CellModifyMassEvent); ExcavatorShockwave = (AddEvent(new CellModifyMassEvent("ExcavatorShockwave", "Excavator Shockwave", false)) as CellModifyMassEvent); OxygenBreatherSimUpdate = (AddEvent(new CellModifyMassEvent("OxygenBreatherSimUpdate", "Oxygen Breather SimUpdate", false)) as CellModifyMassEvent); CO2ScrubberSimUpdate = (AddEvent(new CellModifyMassEvent("CO2ScrubberSimUpdate", "CO2Scrubber SimUpdate", false)) as CellModifyMassEvent); RiverSourceSimUpdate = (AddEvent(new CellModifyMassEvent("RiverSourceSimUpdate", "RiverSource SimUpdate", false)) as CellModifyMassEvent); RiverTerminusSimUpdate = (AddEvent(new CellModifyMassEvent("RiverTerminusSimUpdate", "RiverTerminus SimUpdate", false)) as CellModifyMassEvent); DebugToolModifyMass = (AddEvent(new CellModifyMassEvent("DebugToolModifyMass", "DebugTool ModifyMass", false)) as CellModifyMassEvent); EnergyGeneratorModifyMass = (AddEvent(new CellModifyMassEvent("EnergyGeneratorModifyMass", "EnergyGenerator ModifyMass", false)) as CellModifyMassEvent); SolidFilterEvent = (AddEvent(new CellSolidFilterEvent("SolidFilterEvent", true)) as CellSolidFilterEvent); }
private static bool Prefix(int gameCell, SimHashes new_element, CellElementEvent ev, float mass, float temperature, byte diseaseIdx, int diseaseCount, int callbackIdx) { SimMessages_Utils.Log(MethodBase.GetCurrentMethod(), gameCell, new_element, ev, mass, temperature, diseaseIdx, diseaseCount, callbackIdx); return(true); }
private static bool Prefix(Door __instance, bool is_door_open, IList <int> cells) { Door.ControlState controlState = Traverse.Create(__instance).Field("controlState").GetValue <Door.ControlState>(); PrimaryElement component = __instance.GetComponent <PrimaryElement>(); float num = component.Mass / (float)cells.Count; MethodInfo method_closed = AccessTools.Method(typeof(Door), "OnSimDoorClosed", null, null); System.Action cb_closed = (System.Action)Delegate.CreateDelegate(typeof(System.Action), __instance, method_closed); MethodInfo method_opened = AccessTools.Method(typeof(Door), "OnSimDoorOpened", null, null); System.Action cb_opened = (System.Action)Delegate.CreateDelegate(typeof(System.Action), __instance, method_opened); for (int i = 0; i < cells.Count; i++) { int num2 = cells[i]; Door.DoorType doorType = __instance.doorType; if (doorType == Door.DoorType.Pressure || doorType == Door.DoorType.Sealed || doorType == Door.DoorType.ManualPressure) { World.Instance.groundRenderer.MarkDirty(num2); if (is_door_open) { SimMessages.Dig(num2, Game.Instance.callbackManager.Add(new Game.CallbackInfo(cb_opened, false)).index); if (controlState == Door.ControlState.Auto) { HandleVector <Game.CallbackInfo> .Handle handle = Game.Instance.callbackManager.Add(new Game.CallbackInfo(cb_opened, false)); float temperature = component.Temperature; if (temperature <= 0f) { temperature = component.Temperature; } int gameCell = num2; SimHashes elementID = component.ElementID; CellElementEvent doorOpen = CellEventLogger.Instance.DoorOpen; float mass = num; float temperature2 = temperature; int index = handle.index; SimMessages.ReplaceAndDisplaceElement(gameCell, elementID, doorOpen, mass, temperature2, byte.MaxValue, 0, index); SimMessages.SetCellProperties(num2, 4); } else if (__instance.ShouldBlockFallingSand) { SimMessages.ClearCellProperties(num2, 4); } else { SimMessages.SetCellProperties(num2, 4); } } else { HandleVector <Game.CallbackInfo> .Handle handle = Game.Instance.callbackManager.Add(new Game.CallbackInfo(cb_closed, false)); float temperature = component.Temperature; if (temperature <= 0f) { temperature = component.Temperature; } int gameCell = num2; SimHashes elementID = component.ElementID; CellElementEvent doorClose = CellEventLogger.Instance.DoorClose; float mass = num; float temperature2 = temperature; int index = handle.index; SimMessages.ReplaceAndDisplaceElement(gameCell, elementID, doorClose, mass, temperature2, byte.MaxValue, 0, index); SimMessages.SetCellProperties(num2, 4); } } } return(false); }