protected override void OnCleanUp() { NetworkManager.RemoveFromNetworks(utilityCell, networkItem, is_endpoint: true); ConduitManager.RemoveConduitUpdater(ConduitUpdate); GameScenePartitioner.Instance.Free(ref partitionerEntry); base.OnCleanUp(); }
void Awake() { // Ensure one instance of this if (instance == null) { instance = this; } else if (instance != this) { Destroy(this); return; } Initialize(); }
public void Announce(ILinkable linkable) { Bend bend; if (m_Bends.TryGetValue(linkable.modelName, out bend)) { // Link to Active Conduit ConduitManager.LinkActiveConduit(bend); // Establish Link to Screen linkable.Link(bend); } else { //Debug\.Log( "BendManager: Announce() No Bend found for model name: " + linkable.modelName ); } }
protected override void OnSpawn() { base.OnSpawn(); GameScheduler.Instance.Schedule("PlumbingTutorial", 2f, delegate { Tutorial.Instance.TutorialMessage(Tutorial.TutorialMessages.TM_Plumbing); }); utilityCell = GetUtilityCell(); networkItem = new FlowUtilityNetwork.NetworkItem(portInfo.conduitType, Endpoint.Sink, utilityCell, base.gameObject); NetworkManager.AddToNetworks(utilityCell, networkItem, is_endpoint: true); partitionerEntry = GameScenePartitioner.Instance.Add("ConduitInput.OnSpawn", base.gameObject, utilityCell, ScenePartitionerLayer, OnConduitConnectionChanged); ConduitManager.AddConduitUpdater(ConduitUpdate); OnConduitConnectionChanged(null); OnConduitConnectionChanged(null); }
void Awake() { // Defaults unitType = Units.Type.Standard; outputRulerUnit = Units.RulerUnit.Feet; // Ensure one instance of this if (engine == null) { DontDestroyOnLoad(this); engine = this; } else if (engine != this) { Destroy(this); } // Limit Frame Rate Application.targetFrameRate = 10; // Get References GameObject found = GameObject.FindWithTag("ScreenManager"); if (found != null) { screenManager = found.GetComponent <ScreenManager>(); } found = GameObject.FindWithTag("EventManager"); if (found != null) { eventManager = found.GetComponent <EventManager>(); } found = GameObject.FindWithTag("ConduitManager"); if (found != null) { conduitManager = found.GetComponent <ConduitManager>(); conduitGenerator = found.GetComponent <ConduitGenerator>(); } GameObject[] foundarr = GameObject.FindGameObjectsWithTag("MainCamera"); if (foundarr.Length != 0) { for (int i = 0; i < foundarr.Length; ++i) { if (mainCameraController = foundarr[i].GetComponent <CameraController>()) { break; } } } mainCameraController.movementEnabled = false; root_ui = GameObject.Find("_UI").transform; root_geometry = GameObject.Find("_Geometry").transform; root_conduit = GameObject.Find("_Conduit").transform; root_particles = GameObject.Find("_Particles").transform; root_flag = GameObject.Find("_Flag").transform; cameraUI = GameObject.FindWithTag("UICamera").GetComponent <Camera>(); cameraMain = GameObject.FindWithTag("MainCamera").GetComponent <Camera>(); #if UNITY_EDITOR // Check Nulls if (screenManager == null) { Debug.LogError("Engine: Initialize() No Screen Manager found in scene with the tag 'SceneManager'."); return; } if (eventManager == null) { Debug.LogError("Engine: Initialize() No Event Manager found in scene on object with the tag 'EventManager'."); return; } if (conduitManager == null) { Debug.LogError("Engine: Initialize() No Conduit Manager found in scene on object with the tag 'ConduitManager'."); return; } if (conduitGenerator == null) { Debug.LogError("Engine: Initialize() No Conduit Generator found in scene on object with the tag 'ConduitManager'."); return; } if (mainCameraController == null) { Debug.LogError("Engine: Initialize() No Main Camera Controller found in scene on object with the tag 'MainCamera'."); return; } #endif //DebugToScreen.Log( "Engine: Initialize() Awake Complete!" ); }
private void Consume(float dt) { IsSatisfied = false; if (!IsConnected) { return; } ConduitFlow.ConduitContents contents = ConduitContents; if (contents.mass <= 0f) { return; } IsSatisfied = true; if (!alwaysConsume && !operational.IsOperational) { return; } float massToConsume = ConsumptionRate * dt; massToConsume = Mathf.Min(massToConsume, space_remaining_kg); float consumedMass = 0f; if (massToConsume > 0f) { ConduitFlow.ConduitContents conduitContents = ConduitManager.RemoveElement(utilityCell, massToConsume); consumedMass = conduitContents.mass; lastConsumedElement = conduitContents.element; } Element consumedElement = ElementLoader.FindElementByHash(contents.element); bool validElement = consumedElement.HasTag(capacityTag); if (consumedMass > 0f && capacityTag != GameTags.Any && !validElement) { Trigger(-794517298, new BuildingHP.DamageSourceInfo { damage = 1, source = STRINGS.BUILDINGS.DAMAGESOURCES.BAD_INPUT_ELEMENT, popString = STRINGS.UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.WRONG_ELEMENT }); } if (validElement || wrongElementResult == ConduitConsumer.WrongElementResult.Store || contents.element == SimHashes.Vacuum || capacityTag == GameTags.Any) { if (consumedMass <= 0) { return; } int consumedGerms = (int)((float)contents.diseaseCount * (consumedMass / contents.mass)); if (portInfo.conduitType == ConduitType.Liquid && consumedElement.IsLiquid) { storage.AddLiquid(contents.element, consumedMass, contents.temperature, contents.diseaseIdx, consumedGerms, keepZeroMassObject, do_disease_transfer: false); } else if (portInfo.conduitType == ConduitType.Gas && consumedElement.IsGas) { storage.AddGasChunk(contents.element, consumedMass, contents.temperature, contents.diseaseIdx, consumedGerms, keepZeroMassObject, do_disease_transfer: false); } else { Log.Warn($"{portInfo.conduitType} consumer consuming {consumedElement.state}: {consumedElement.id}"); } } else if (consumedMass > 0 && wrongElementResult == ConduitConsumer.WrongElementResult.Dump) { int consumedGerms = (int)((float)contents.diseaseCount * (consumedMass / contents.mass)); int dumpCell = Grid.PosToCell(base.transform.GetPosition()); SimMessages.AddRemoveSubstance(dumpCell, contents.element, CellEventLogger.Instance.ConduitConsumerWrongElement, consumedMass, contents.temperature, contents.diseaseIdx, consumedGerms); } }