protected override void OnCompleteWork(Worker worker) { base.OnCompleteWork(worker); if (session != null) { Storage component = worker.GetComponent <Storage>(); float consumedAmount = session.GetConsumedAmount(); if (consumedAmount > 0f) { SubstanceChunk source = session.GetSource(); SimUtil.DiseaseInfo diseaseInfo = (session == null) ? SimUtil.DiseaseInfo.Invalid : session.GetDiseaseInfo(); PrimaryElement component2 = source.GetComponent <PrimaryElement>(); Pickupable component3 = LiquidSourceManager.Instance.CreateChunk(component2.Element, consumedAmount, session.GetTemperature(), diseaseInfo.idx, diseaseInfo.count, base.transform.GetPosition()).GetComponent <Pickupable>(); component3.TotalAmount = consumedAmount; component3.Trigger(1335436905, source.GetComponent <Pickupable>()); worker.workCompleteData = component3; Sim200ms(0f); if ((UnityEngine.Object)component3 != (UnityEngine.Object)null) { component.Store(component3.gameObject, false, false, true, false); } } session.Cleanup(); session = null; } }
public static SubstanceChunk CreateChunk(Element element, float mass, float temperature, byte diseaseIdx, int diseaseCount, Vector3 position) { if (temperature <= 0f) { DebugUtil.LogWarningArgs("GeneratedOre.CreateChunk tried to create a chunk with a temperature <= 0"); } GameObject prefab = Assets.GetPrefab(element.tag); if ((UnityEngine.Object)prefab == (UnityEngine.Object)null) { Debug.LogError("Could not find prefab for element " + element.id.ToString()); } SubstanceChunk component = GameUtil.KInstantiate(prefab, Grid.SceneLayer.Ore, null, 0).GetComponent <SubstanceChunk>(); component.transform.SetPosition(position); component.gameObject.SetActive(true); PrimaryElement component2 = component.GetComponent <PrimaryElement>(); component2.Mass = mass; component2.Temperature = temperature; component2.AddDisease(diseaseIdx, diseaseCount, "GeneratedOre.CreateChunk"); KPrefabID component3 = component.GetComponent <KPrefabID>(); component3.InitializeTags(); return(component); }
protected override void OnCompleteWork(Worker worker) { base.OnCompleteWork(worker); if (this.session == null) { return; } Storage component1 = worker.GetComponent <Storage>(); float consumedAmount = this.session.GetConsumedAmount(); if ((double)consumedAmount > 0.0) { SubstanceChunk source = this.session.GetSource(); SimUtil.DiseaseInfo diseaseInfo = this.session != null?this.session.GetDiseaseInfo() : SimUtil.DiseaseInfo.Invalid; PrimaryElement component2 = source.GetComponent <PrimaryElement>(); Pickupable component3 = LiquidSourceManager.Instance.CreateChunk(component2.Element, consumedAmount, this.session.GetTemperature(), diseaseInfo.idx, diseaseInfo.count, this.transform.GetPosition()).GetComponent <Pickupable>(); component3.TotalAmount = consumedAmount; component3.Trigger(1335436905, (object)source.GetComponent <Pickupable>()); worker.workCompleteData = (object)component3; ///remove the emission for (int index = 0; index < component1.items.Count; ++index) { GameObject go = component1.items[index]; if (!((UnityEngine.Object)go == (UnityEngine.Object)null) && go.HasTag(component2.Element.tag)) { go.GetComponent <PrimaryElement>().Mass -= consumedAmount; } } //End remove emission if ((UnityEngine.Object)component3 != (UnityEngine.Object)null) { component1.Store(component3.gameObject, false, false, true, false); } } this.session.Cleanup(); this.session = (BottleFiller.WorkSession)null; }
private PrimaryElement FindSuitableElement() { PrimaryElement ret = null; // Maybe make it buffer an extra message, that might help? // better version: grab stuff from our ass, I mean network - BR int x, y; Grid.CellToXY(Grid.PosToCell(this), out x, out y); JObject message = Z.net.get_message_for("got_packet", x, y); if (outstanding && message != null) { outstanding = false; // We have a response from the server, finally ya lazy basterd if (message["packet"] != null && message["packet"].Type == JTokenType.Object) { JObject mat_packet = (JObject)message["packet"]; JObject germ_packet = null; if (mat_packet["germs"] != null && mat_packet["germs"].Type == JTokenType.Object) { germ_packet = (JObject)mat_packet["germs"]; } if (dave == null) { dave = GasSourceManager.Instance.CreateChunk( (SimHashes)(-1528777920), 0f, 456f, 255, 0, this.transform.GetPosition()); steve = dave.GetComponent <PrimaryElement>(); steve.KeepZeroMassObject = true; } steve.SetElement((SimHashes)((int)mat_packet["element"])); steve.SetMassTemperature((float)mat_packet["mass"], (float)mat_packet["temperature"]); string reason = conduitType == ConduitType.Liquid ? "Storage.AddLiquid" : "Storage.AddGasChunk"; steve.ModifyDiseaseCount(-steve.DiseaseCount, reason); if (germ_packet != null) { steve.AddDisease((byte)germ_packet["id"], (int)germ_packet["count"], reason); } message = null; ret = steve; } } // Only ask for goodies when we are enabled if (!outstanding && ztransporter.is_enabled()) { // Send a message to the server asking for goodies message = Network.make_message("recv_packet", x, y); message.Add("phase", this.conduitType == ConduitType.Liquid ? "Liquid" : "Gas"); Z.net.send_message(message); outstanding = true; } return(ret); }