public void AddNetworks(ICollection <UtilityNetwork> networks) { var networkManager = Conduit.GetNetworkManager(Type); var networkForCell1 = networkManager.GetNetworkForCell(_inputCell); if (networkForCell1 != null) { networks.Add(networkForCell1); } var networkForCell2 = networkManager.GetNetworkForCell(_outputCell); if (networkForCell2 != null) { networks.Add(networkForCell2); } var networkForCell3 = networkManager.GetNetworkForCell(_secondaryOutputCell); if (networkForCell3 != null) { networks.Add(networkForCell3); } }
protected override void OnSpawn() { base.OnSpawn(); fuel_tag = SimHashes.Petroleum.CreateTag(); fuel_consumer = base.gameObject.AddComponent <ConduitConsumer>(); fuel_consumer.conduitType = portInfo.conduitType; fuel_consumer.consumptionRate = 10f; fuel_consumer.capacityTag = fuel_tag; fuel_consumer.wrongElementResult = ConduitConsumer.WrongElementResult.Dump; fuel_consumer.forceAlwaysSatisfied = true; fuel_consumer.capacityKG = 100f; fuel_consumer.useSecondaryInput = true; RequireInputs requireInputs = base.gameObject.AddComponent <RequireInputs>(); requireInputs.conduitConsumer = fuel_consumer; requireInputs.SetRequirements(false, true); int cell = Grid.PosToCell(base.transform.GetPosition()); CellOffset rotatedOffset = building.GetRotatedOffset(portInfo.offset); secondaryInputCell = Grid.OffsetCell(cell, rotatedOffset); IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(portInfo.conduitType); flowNetworkItem = new FlowUtilityNetwork.NetworkItem(portInfo.conduitType, Endpoint.Sink, secondaryInputCell, base.gameObject); networkManager.AddToNetworks(secondaryInputCell, flowNetworkItem, true); fuel_meter = new MeterController(GetComponent <KBatchedAnimController>(), "meter_target_1", "meter_petrol", Meter.Offset.Infront, Grid.SceneLayer.NoLayer, Vector3.zero, "meter_target_1"); o2_meter = new MeterController(GetComponent <KBatchedAnimController>(), "meter_target_2", "meter_oxygen", Meter.Offset.Infront, Grid.SceneLayer.NoLayer, Vector3.zero, "meter_target_2"); base.smi.StartSM(); }
protected override void OnCleanUp() { IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(portInfo.conduitType); networkManager.RemoveFromNetworks(secondaryInputCell, flowNetworkItem, true); base.OnCleanUp(); }
public bool IsConnectedToNetworks(ICollection <UtilityNetwork> networks) { bool flag = false; IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(type); return(flag || networks.Contains(networkManager.GetNetworkForCell(inputCell)) || networks.Contains(networkManager.GetNetworkForCell(outputCell))); }
protected override void OnSpawn() { base.OnSpawn(); oxygenOutputCell = building.GetUtilityOutputCell(); int cell = Grid.PosToCell(transform.GetPosition()); CellOffset rotatedOffset = building.GetRotatedOffset(portInfo.offset); hydrogenOutputCell = Grid.OffsetCell(cell, rotatedOffset); IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(portInfo.conduitType); hydrogenOutputItem = new FlowUtilityNetwork.NetworkItem(portInfo.conduitType, Endpoint.Source, hydrogenOutputCell, gameObject); networkManager.AddToNetworks(hydrogenOutputCell, hydrogenOutputItem, true); WaterAccumulator = Game.Instance.accumulators.Add("ElementsConsumed", this); OxygenAccumulator = Game.Instance.accumulators.Add("OutputElements", this); HydrogenAccumulator = Game.Instance.accumulators.Add("OutputElements", this); KBatchedAnimController batchedAnimController = GetComponent <KBatchedAnimController>(); if (hasMeter) { meter = new MeterController(batchedAnimController, "U2H_meter_target", "meter", Meter.Offset.Behind, Grid.SceneLayer.NoLayer, new Vector3(-0.4f, 0.5f, -0.1f), "U2H_meter_target", "U2H_meter_tank", "U2H_meter_waterbody", "U2H_meter_level"); } smi.StartSM(); UpdateMeter(); Tutorial.Instance.oxygenGenerators.Add(gameObject); }
#pragma warning restore CS0649 #pragma warning restore IDE0044 /// <summary> /// Gets the current network for this pipe. /// </summary> /// <returns>The connected network, or none if the wire is not connected.</returns> private FlowUtilityNetwork GetNetwork() { int cell = Grid.PosToCell(this); return((Grid.IsValidCell(cell) && conduit != null) ? conduit.GetNetworkManager(). GetNetworkForCell(cell) as FlowUtilityNetwork : null); }
protected override void OnCleanUp() { Conduit.GetNetworkManager(Type).RemoveFromNetworks(_secondaryOutputCell, _secondOutputItem, true); Conduit.GetFlowManager(Type).RemoveConduitUpdater(ConduitUpdate); Game.Instance.accumulators.Remove(_accumulator); base.OnCleanUp(); }
protected override void OnCleanUp() { if (itemInput != null) { if (itemInput.ConduitType == ConduitType.Solid) { Game.Instance.solidConduitSystem.RemoveFromNetworks(itemInput.Cell, itemInput, true); } else { Conduit.GetNetworkManager(itemInput.ConduitType).RemoveFromNetworks(itemInput.Cell, itemInput, true); } } if (itemOutput != null) { if (itemOutput.ConduitType == ConduitType.Solid) { Game.Instance.solidConduitSystem.RemoveFromNetworks(itemOutput.Cell, itemOutput, true); } else { Conduit.GetNetworkManager(itemOutput.ConduitType).RemoveFromNetworks(itemOutput.Cell, itemOutput, true); } } base.OnCleanUp(); }
public bool IsConnectedToNetworks(ICollection <UtilityNetwork> networks) { var networkManager = Conduit.GetNetworkManager(Type); return(networks.Contains(networkManager.GetNetworkForCell(_inputCell)) || networks.Contains(networkManager.GetNetworkForCell(_outputCell)) || networks.Contains(networkManager.GetNetworkForCell(_secondaryOutputCell))); }
protected override void OnSpawn() { base.OnSpawn(); Building component = GetComponent <Building>(); BuildingDef def = component.Def; if (def.InputConduitType != 0) { int utilityInputCell = component.GetUtilityInputCell(); itemInput = new FlowUtilityNetwork.NetworkItem(def.InputConduitType, Endpoint.Sink, utilityInputCell, base.gameObject); if (def.InputConduitType == ConduitType.Solid) { Game.Instance.solidConduitSystem.AddToNetworks(utilityInputCell, itemInput, true); } else { Conduit.GetNetworkManager(def.InputConduitType).AddToNetworks(utilityInputCell, itemInput, true); } } if (def.OutputConduitType != 0) { int utilityOutputCell = component.GetUtilityOutputCell(); itemOutput = new FlowUtilityNetwork.NetworkItem(def.OutputConduitType, Endpoint.Source, utilityOutputCell, base.gameObject); if (def.OutputConduitType == ConduitType.Solid) { Game.Instance.solidConduitSystem.AddToNetworks(utilityOutputCell, itemOutput, true); } else { Conduit.GetNetworkManager(def.OutputConduitType).AddToNetworks(utilityOutputCell, itemOutput, true); } } }
protected override void OnCleanUp() { IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(portInfo.conduitType); networkManager.RemoveFromNetworks(secondaryInput.Cell, secondaryInput, true); Conduit.GetFlowManager(portInfo.conduitType).RemoveConduitUpdater(ConduitUpdate); base.OnCleanUp(); }
protected override void OnCleanUp() { IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(this.conduitType); networkManager.RemoveFromNetworks(this.utilityCell, this.networkItem, true); this.GetConduitManager().RemoveConduitUpdater(new Action <float>(this.ConduitUpdate)); GameScenePartitioner.Instance.Free(ref this.partitionerEntry); base.OnCleanUp(); }
protected override void OnCleanUp() { IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(this.portInfo.conduitType); networkManager.RemoveFromNetworks(this.sInputCell, this.itemSInput, true); ConduitFlow flowManager = Conduit.GetFlowManager(this.portInfo.conduitType); flowManager.RemoveConduitUpdater(this.OnConduitTick); base.OnCleanUp(); }
protected override void OnCleanUp() { Tutorial.Instance.oxygenGenerators.Remove(gameObject); IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(portInfo.conduitType); networkManager.RemoveFromNetworks(hydrogenOutputCell, hydrogenOutputItem, true); Game.Instance.accumulators.Remove(WaterAccumulator); Game.Instance.accumulators.Remove(OxygenAccumulator); Game.Instance.accumulators.Remove(HydrogenAccumulator); base.OnCleanUp(); }
protected override void OnCleanUp() { smi.StopSM("OnCleanUp"); Game.Instance.liquidConduitFlow.RemoveConduitUpdater(OnLiquidConduitUpdate); Game.Instance.gasConduitFlow.RemoveConduitUpdater(OnGasConduitUpdate); Unsubscribe((int)GameHashes.ConduitConnectionChanged, CheckPipesDelegate); Unsubscribe((int)GameHashes.OnStorageChange, OnStorageChangeDelegate); Unsubscribe((int)GameHashes.CopySettings, OnCopySettingsDelegate); Conduit.GetNetworkManager(fuelPortInfo.conduitType).RemoveFromNetworks(fuelInputCell, fuelNetworkItem, true); Conduit.GetNetworkManager(liquidWastePortInfo.conduitType).RemoveFromNetworks(liquidWasteOutputCell, liquidWasteNetworkItem, true); Conduit.GetNetworkManager(gasWastePortInfo.conduitType).RemoveFromNetworks(gasWasteOutputCell, gasWasteNetworkItem, true); base.OnCleanUp(); }
protected override void OnCleanUp() { IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(portInfo.conduitType); networkManager.RemoveFromNetworks(filteredCell, itemFilter, true); ConduitFlow flowManager = Conduit.GetFlowManager(portInfo.conduitType); flowManager.RemoveConduitUpdater(OnConduitTick); if (partitionerEntry.IsValid() && (UnityEngine.Object)GameScenePartitioner.Instance != (UnityEngine.Object)null) { GameScenePartitioner.Instance.Free(ref partitionerEntry); } base.OnCleanUp(); }
private ConduitDispenser CreateConduitDispenser(ConduitType outputType, int outputCell, out FlowUtilityNetwork.NetworkItem flowNetworkItem) { var dispenser = gameObject.AddComponent <AlwaysFunctionalConduitDispenser>(); dispenser.conduitType = outputType; dispenser.useSecondaryOutput = true; dispenser.alwaysDispense = true; dispenser.storage = storage; var networkManager = Conduit.GetNetworkManager(outputType); flowNetworkItem = new FlowUtilityNetwork.NetworkItem(outputType, Endpoint.Source, outputCell, gameObject); networkManager.AddToNetworks(outputCell, flowNetworkItem, true); return(dispenser); }
public void AddNetworks(ICollection <UtilityNetwork> networks) { IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(type); UtilityNetwork networkForCell = networkManager.GetNetworkForCell(inputCell); if (networkForCell != null) { networks.Add(networkForCell); } networkForCell = networkManager.GetNetworkForCell(outputCell); if (networkForCell != null) { networks.Add(networkForCell); } }
private ConduitConsumer CreateConduitConsumer(ConduitType inputType, int inputCell, out FlowUtilityNetwork.NetworkItem flowNetworkItem) { var consumer = gameObject.AddComponent <ConduitConsumer>(); consumer.conduitType = inputType; consumer.useSecondaryInput = true; consumer.consumptionRate = inputType == ConduitType.Gas ? ConduitFlow.MAX_GAS_MASS : ConduitFlow.MAX_LIQUID_MASS; consumer.wrongElementResult = ConduitConsumer.WrongElementResult.Dump; consumer.forceAlwaysSatisfied = true; consumer.storage = storage; var networkManager = Conduit.GetNetworkManager(inputType); flowNetworkItem = new FlowUtilityNetwork.NetworkItem(inputType, Endpoint.Sink, inputCell, gameObject); networkManager.AddToNetworks(inputCell, flowNetworkItem, true); return(consumer); }
protected override void OnSpawn() { base.OnSpawn(); this.utilityCell = this.GetInputCell(); IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(this.conduitType); this.networkItem = new FlowUtilityNetwork.NetworkItem(this.conduitType, Endpoint.Sink, this.utilityCell, base.gameObject); networkManager.AddToNetworks(this.utilityCell, this.networkItem, true); ScenePartitionerLayer layer = GameScenePartitioner.Instance.objectLayers[(this.conduitType != ConduitType.Gas) ? 16 : 12]; this.partitionerEntry = GameScenePartitioner.Instance.Add("ConduitConsumer.OnSpawn", base.gameObject, this.utilityCell, layer, new Action <object>(this.OnConduitConnectionChanged)); this.GetConduitManager().AddConduitUpdater(new Action <float>(this.ConduitUpdate), ConduitFlowPriority.Default); this.OnConduitConnectionChanged(null); }
protected override void OnSpawn() { base.OnSpawn(); Building component = GetComponent <Building>(); inputCell = component.GetUtilityInputCell(); outputCell = component.GetUtilityOutputCell(); secondaryOutputCell = Grid.OffsetCell(Grid.PosToCell(transform.GetPosition()), component.GetRotatedOffset(SecondaryPort.offset)); var secondOutput = new FlowUtilityNetwork.NetworkItem(SecondaryPort.conduitType, Endpoint.Source, secondaryOutputCell, gameObject); IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(SecondaryPort.conduitType); networkManager.AddToNetworks(secondaryOutputCell, (object)secondOutput, true); Conduit.GetFlowManager(type).AddConduitUpdater(ConduitUpdate); }
protected override void OnSpawn() { base.OnSpawn(); Building component = GetComponent <Building>(); inputCell = component.GetUtilityInputCell(); outputCell = component.GetUtilityOutputCell(); int cell = Grid.PosToCell(base.transform.GetPosition()); CellOffset rotatedOffset = component.GetRotatedOffset(portInfo.offset); int cell2 = Grid.OffsetCell(cell, rotatedOffset); Conduit.GetFlowManager(portInfo.conduitType).AddConduitUpdater(ConduitUpdate, ConduitFlowPriority.Default); IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(portInfo.conduitType); secondaryInput = new FlowUtilityNetwork.NetworkItem(portInfo.conduitType, Endpoint.Sink, cell2, base.gameObject); networkManager.AddToNetworks(secondaryInput.Cell, secondaryInput, true); }
protected override void OnSpawn() { base.OnSpawn(); inputCell = building.GetUtilityInputCell(); outputCell = building.GetUtilityOutputCell(); int cell = Grid.PosToCell(base.transform.GetPosition()); CellOffset rotatedOffset = building.GetRotatedOffset(portInfo.offset); filteredCell = Grid.OffsetCell(cell, rotatedOffset); IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(portInfo.conduitType); itemFilter = new FlowUtilityNetwork.NetworkItem(portInfo.conduitType, Endpoint.Source, filteredCell, base.gameObject); networkManager.AddToNetworks(filteredCell, itemFilter, true); GetComponent <ConduitConsumer>().isConsuming = false; OnFilterChanged(filterable.SelectedTag); filterable.onFilterChanged += OnFilterChanged; ConduitFlow flowManager = Conduit.GetFlowManager(portInfo.conduitType); flowManager.AddConduitUpdater(OnConduitTick, ConduitFlowPriority.Default); GetComponent <KSelectable>().SetStatusItem(Db.Get().StatusItemCategories.Main, filterStatusItem, this); UpdateConduitExistsStatus(); UpdateConduitBlockedStatus(); ScenePartitionerLayer scenePartitionerLayer = null; switch (portInfo.conduitType) { case ConduitType.Gas: scenePartitionerLayer = GameScenePartitioner.Instance.gasConduitsLayer; break; case ConduitType.Liquid: scenePartitionerLayer = GameScenePartitioner.Instance.liquidConduitsLayer; break; case ConduitType.Solid: scenePartitionerLayer = GameScenePartitioner.Instance.solidConduitsLayer; break; } if (scenePartitionerLayer != null) { partitionerEntry = GameScenePartitioner.Instance.Add("ElementFilterConduitExists", base.gameObject, filteredCell, scenePartitionerLayer, delegate { UpdateConduitExistsStatus(); }); } }
public void AddNetworks(ICollection <UtilityNetwork> networks) { var networkManager = Conduit.GetNetworkManager(type); var networkForCell1 = networkManager.GetNetworkForCell(inputCell); if (networkForCell1 != null) { networks.Add(networkForCell1); } var networkForCell2 = networkManager.GetNetworkForCell(outputCell); if (networkForCell2 == null) { return; } networks.Add(networkForCell2); }
protected override void OnSpawn() { base.OnSpawn(); var building = GetComponent <Building>(); _inputCell = building.GetUtilityInputCell(); _outputCell = building.GetUtilityOutputCell(); _secondaryOutputCell = Grid.OffsetCell(Grid.PosToCell(transform.GetPosition()), building.GetRotatedOffset(SecondaryPort.offset)); _secondOutputItem = new FlowUtilityNetwork.NetworkItem(SecondaryPort.conduitType, Endpoint.Source, _secondaryOutputCell, gameObject); var networkManager = Conduit.GetNetworkManager(SecondaryPort.conduitType); networkManager.AddToNetworks(_secondaryOutputCell, _secondOutputItem, true); Conduit.GetFlowManager(Type).AddConduitUpdater(ConduitUpdate); }
protected override void OnSpawn() { base.OnSpawn(); var building = base.GetComponent <Building>(); this.utilityCell = building.GetCellWithOffset(building.Orientation == Orientation.Neutral ? this.conduitOffset : this.conduitOffsetFlipped); IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(this.conduitType); this.networkItem = new FlowUtilityNetwork.NetworkItem(this.conduitType, Endpoint.Source, this.utilityCell, base.gameObject); networkManager.AddToNetworks(this.utilityCell, this.networkItem, true); ScenePartitionerLayer layer = GameScenePartitioner.Instance.objectLayers[(this.conduitType != ConduitType.Gas) ? 16 : 12]; this.partitionerEntry = GameScenePartitioner.Instance.Add("ConduitConsumer.OnSpawn", base.gameObject, this.utilityCell, layer, new Action <object>(this.OnConduitConnectionChanged)); this.GetConduitManager().AddConduitUpdater(new Action <float>(this.ConduitUpdate), ConduitFlowPriority.Default); this.OnConduitConnectionChanged(null); }
public override bool Success() { float num = 0f; IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(ConduitType.Gas); foreach (UtilityNetwork network in networkManager.GetNetworks()) { FlowUtilityNetwork flowUtilityNetwork = network as FlowUtilityNetwork; if (flowUtilityNetwork != null) { foreach (FlowUtilityNetwork.IItem sink in flowUtilityNetwork.sinks) { Vent component = sink.GameObject.GetComponent <Vent>(); if ((Object)component != (Object)null) { num += component.GetVentedMass(element); } } } } return(num >= kilogramsToVent); }
public override string GetProgress(bool complete) { float num = 0f; IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(ConduitType.Gas); foreach (UtilityNetwork network in networkManager.GetNetworks()) { FlowUtilityNetwork flowUtilityNetwork = network as FlowUtilityNetwork; if (flowUtilityNetwork != null) { foreach (FlowUtilityNetwork.IItem sink in flowUtilityNetwork.sinks) { Vent component = sink.GameObject.GetComponent <Vent>(); if ((Object)component != (Object)null) { num += component.GetVentedMass(element); } } } } return(string.Format(COLONY_ACHIEVEMENTS.MISC_REQUIREMENTS.STATUS.VENTED_MASS, GameUtil.GetFormattedMass((!complete) ? num : kilogramsToVent, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.Kilogram, true, "{0:0.#}"), GameUtil.GetFormattedMass(kilogramsToVent, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.Kilogram, true, "{0:0.#}"))); }
private static string CheckOxygenVent() { float num = 0; var goal = 1000; foreach (var network in Conduit.GetNetworkManager(ConduitType.Gas).GetNetworks()) { if (network is FlowUtilityNetwork flowUtilityNetwork) { foreach (var sink in flowUtilityNetwork.sinks) { var component = sink.GameObject.GetComponent <Vent>(); if (component != null) { num += component.GetVentedMass(SimHashes.Oxygen); } } } } return(FormatProgress(num, goal, "kg")); }
public void AddNetworks(ICollection <UtilityNetwork> networks) { IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(type); UtilityNetwork networkForCell1 = networkManager.GetNetworkForCell(inputCell); if (networkForCell1 != null) { networks.Add(networkForCell1); } UtilityNetwork networkForCell2 = networkManager.GetNetworkForCell(outputCell); if (networkForCell2 != null) { networks.Add(networkForCell2); } UtilityNetwork networkForCell3 = networkManager.GetNetworkForCell(secondaryOutputCell); if (networkForCell3 != null) { networks.Add(networkForCell3); } }