private void Exhale() { if (!(lastEmitTag != Tag.Invalid)) { gases.Clear(); storage.Find(GameTags.Gas, gases); if (nextGasEmitIndex >= gases.Count) { nextGasEmitIndex = 0; } PrimaryElement component; do { if (nextGasEmitIndex >= gases.Count) { return; } int index = nextGasEmitIndex++; component = gases[index].GetComponent <PrimaryElement>(); }while (!((UnityEngine.Object)component != (UnityEngine.Object)null) || !(component.Mass > 0f) || !simEmitCBHandle.IsValid()); float temperature = Mathf.Max(component.Element.lowTemp + 5f, component.Temperature + deltaEmitTemperature); int gameCell = Grid.PosToCell(base.transform.GetPosition() + emitOffsetCell); byte idx = component.Element.idx; Game.Instance.massEmitCallbackManager.GetItem(simEmitCBHandle); SimMessages.EmitMass(gameCell, idx, component.Mass, temperature, component.DiseaseIdx, component.DiseaseCount, simEmitCBHandle.index); lastEmitTag = component.Element.tag; } }
public override void InitializeStates(out BaseState default_state) { default_state = idle; idle.PlayAnim("grounded", KAnim.PlayMode.Loop).EventTransition(GameHashes.IgniteEngine, burning, null); burning.EventTransition(GameHashes.LandRocket, burnComplete, null).PlayAnim("launch_pre").QueueAnim("launch_loop", true, null) .Update(delegate(StatesInstance smi, float dt) { Vector3 pos = smi.master.gameObject.transform.GetPosition() + smi.master.GetComponent <KBatchedAnimController>().Offset; int num = Grid.PosToCell(pos); if (Grid.IsValidCell(num)) { SimMessages.EmitMass(num, (byte)ElementLoader.GetElementIndex(smi.master.exhaustElement), dt * smi.master.exhaustEmitRate, smi.master.exhaustTemperature, 0, 0, -1); } int num2 = 10; for (int i = 1; i < num2; i++) { int num3 = Grid.OffsetCell(num, -1, -i); int num4 = Grid.OffsetCell(num, 0, -i); int num5 = Grid.OffsetCell(num, 1, -i); if (Grid.IsValidCell(num3)) { SimMessages.ModifyEnergy(num3, smi.master.exhaustTemperature / (float)(i + 1), 3200f, SimMessages.EnergySourceID.Burner); } if (Grid.IsValidCell(num4)) { SimMessages.ModifyEnergy(num4, smi.master.exhaustTemperature / (float)i, 3200f, SimMessages.EnergySourceID.Burner); } if (Grid.IsValidCell(num5)) { SimMessages.ModifyEnergy(num5, smi.master.exhaustTemperature / (float)(i + 1), 3200f, SimMessages.EnergySourceID.Burner); } } }, UpdateRate.SIM_200ms, false); burnComplete.PlayAnim("grounded", KAnim.PlayMode.Loop).EventTransition(GameHashes.IgniteEngine, burning, null); }
public override void InitializeStates(out BaseState default_state) { default_state = healthy; base.serializable = true; healthy.EventTransition(GameHashes.Wilt, wilted, (StatesInstance smi) => smi.IsWilting()).Update("PlantEmit", delegate(StatesInstance smi, float dt) { SimMessages.EmitMass(Grid.PosToCell(smi.master.gameObject), ElementLoader.FindElementByHash(smi.master.emittedElement).idx, smi.master.emitRate * dt, ElementLoader.FindElementByHash(smi.master.emittedElement).defaultValues.temperature, byte.MaxValue, 0, -1); }, UpdateRate.SIM_4000ms, false); wilted.EventTransition(GameHashes.WiltRecover, healthy, null); }
private void OnSimConsume(Sim.MassConsumedCallback mass_cb_info) { float num = mass_cb_info.mass * base.smi.master.exchangeRatio; if (reportExchange && base.smi.master.emittedElement == SimHashes.Oxygen) { string text = base.gameObject.GetProperName(); ReceptacleMonitor component = GetComponent <ReceptacleMonitor>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null && (UnityEngine.Object)component.GetReceptacle() != (UnityEngine.Object)null) { text = text + " (" + component.GetReceptacle().gameObject.GetProperName() + ")"; } ReportManager.Instance.ReportValue(ReportManager.ReportType.OxygenCreated, num, text, null); } SimMessages.EmitMass(Grid.PosToCell(base.smi.master.transform.GetPosition() + outputOffset), ElementLoader.FindElementByHash(base.smi.master.emittedElement).idx, num, ElementLoader.FindElementByHash(base.smi.master.emittedElement).defaultValues.temperature, byte.MaxValue, 0, -1); }
public void Sim33ms(float dt) { if (!hasExploded) { Vector2 vector = new Vector2((float)Grid.WidthInCells, (float)Grid.HeightInCells) * -0.1f; Vector2 vector2 = new Vector2((float)Grid.WidthInCells, (float)Grid.HeightInCells) * 1.1f; Vector3 position = base.transform.GetPosition(); Vector3 vector3 = position + new Vector3(velocity.x * dt, velocity.y * dt, 0f); int num = Grid.PosToCell(vector3); loopingSounds.UpdateVelocity(flyingSound, vector3 - position); Element element = ElementLoader.FindElementByHash(SimHashes.CarbonDioxide); if (Grid.IsValidCell(num) && !Grid.Solid[num]) { SimMessages.EmitMass(num, element.idx, dt * 50f, element.defaultValues.temperature, 0, 0, -1); } if (vector3.x < vector.x || vector2.x < vector3.x || vector3.y < vector.y) { Util.KDestroyGameObject(base.gameObject); } int num2 = Grid.PosToCell(this); int num3 = Grid.PosToCell(previousPosition); if (num2 != num3) { if (Grid.IsValidCell(num2) && Grid.Solid[num2]) { PrimaryElement component = GetComponent <PrimaryElement>(); remainingTileDamage = DamageTiles(num2, num3, remainingTileDamage); if (remainingTileDamage <= 0f) { Explode(position, num2, num3, component.Element); hasExploded = true; Util.KDestroyGameObject(base.gameObject); return; } } else { DamageThings(position, num2, entityDamage); } } previousPosition = position; base.transform.SetPosition(vector3); } }