Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        protected override void OnSpawn()
        {
            base.OnSpawn();
            _spawned = true;
            Debug.Log($"[MultiIO] ConduitIO.OnSpawn() -> ConduitType: {ConduitType.ToString()}  CellOffset: {CellOffset.x + "," + CellOffset.y}");
            portCell = GetPortCell();
            MultiIOExtensions.RegisterPort(portCell, this);
            //Register an event listener for any changes to the grid at the location of this port.
            ScenePartitionerLayer layer = GameScenePartitioner.Instance.objectLayers[(int)GetConduitObjectLayer()];

            partitionerEntry = GameScenePartitioner.Instance.Add("ConduitIO.OnSpawn", _parent, portCell, layer, delegate
            {
                UpdateConduitExistsStatus();
            });
            //Register this conduit to the relevant network. Allows the network to determine flow direction.
            IUtilityNetworkMgr networkManager = GetNetworkManager();

            _networkItem = new FlowUtilityNetwork.NetworkItem(ConduitType, EndpointType, portCell, _parent);
            networkManager.AddToNetworks(portCell, _networkItem, EndpointType != Endpoint.Conduit);

            if (UseConduitUpdater)
            {
                GetConduitManager().AddConduitUpdater(ConduitTick, FlowPriority);
            }

            UpdateConduitExistsStatus(true);
        }
    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 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();
    }
Ejemplo n.º 5
0
        protected override void OnSpawn()
        {
            try
            {
                base.OnSpawn();

                Validate();

                InputCell   = this.Building.GetUtilityInputCell();
                OutputCell1 = this.Building.GetUtilityOutputCell();
                OutputCell2 = Grid.OffsetCell(Grid.PosToCell(transform.GetPosition()), this.Building.GetRotatedOffset(OutputPort2Info.offset));

                OutputItem2 = new FlowUtilityNetwork.NetworkItem(this.ConduitType, Endpoint.Source, OutputCell2, gameObject);

                NetworkMgr.AddToNetworks(OutputCell2, OutputItem2, true);

                this.GetComponent <ConduitConsumer>().isConsuming = false;

                FlowMgr.AddConduitUpdater(OnConduitUpdate);

                #region no idea what these do, just copy from game codes ElementFilter.OnSpawn()

                //((KSelectable)((Component)this).GetComponent<KSelectable>()).SetStatusItem(Db.Get().StatusItemCategories.Main, TemperatureFilterProcess.filterStatusItem, (object)this);

                //this.UpdateConduitExistsStatus();
                this.UpdateConduitBlockedStatus();

                //ScenePartitionerLayer layer = (ScenePartitionerLayer)null;
                //switch (this.ConduitType)
                //{
                //    case ConduitType.Gas:
                //        layer = GameScenePartitioner.Instance.gasConduitsLayer;
                //        break;
                //    case ConduitType.Liquid:
                //        layer = GameScenePartitioner.Instance.liquidConduitsLayer;
                //        break;
                //    case ConduitType.Solid:
                //        layer = GameScenePartitioner.Instance.solidConduitsLayer;
                //        break;
                //}
                //if (layer == null)
                //    return;

                //this.partitionerEntry = GameScenePartitioner.Instance.Add("TemperatureFilterProcessConduitExists", this.gameObject, OutputCell2, layer, (System.Action<object>)(data => this.UpdateConduitExistsStatus()));

                #endregion
            }
            catch (Exception ex)
            {
                KelmenUtils.Log("TemperatureFilterProcess.OnSpawn", ex);
                throw ex;
            }
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        protected override void OnSpawn()
        {
            base.OnSpawn();

            InputPort2NetworkItem = new FlowUtilityNetwork.NetworkItem(InputPort2ConduitType, Endpoint.Sink, this.InputPort2Cell, this.gameObject);

            InputPort2NetworkMgr.AddToNetworks(this.InputPort2Cell, InputPort2NetworkItem, true);

            //this.InputPort2CellPartitionerEntry = GameScenePartitioner.Instance.Add("HighInflowLiquidReservoirProcess.OnSpawn", this, InputPort2Cell
            //    , GameScenePartitioner.Instance.objectLayers[this.InputPort2ConduitType != ConduitType.Gas ? 16 : 12], new System.Action<object>(this.OnInputPort2ConduitConnectionChanged));

            this.InputPort2ConduitFlow.AddConduitUpdater(this.InputPort2ConduitUpdate, ConduitFlowPriority.Default);

            //this.OnInputPort2ConduitConnectionChanged(null);
        }
Ejemplo n.º 8
0
        protected override void OnSpawn()
        {
            base.OnSpawn();
            Building component = this.GetComponent <Building>();

            this.inputCell  = component.GetUtilityInputCell();
            this.outputCell = component.GetUtilityOutputCell();

            this.filteredCell = Grid.OffsetCell(Grid.PosToCell(transform.GetPosition()), component.GetRotatedOffset(SecondaryPort.offset));
            var itemFilter = new FlowUtilityNetwork.NetworkItem(this.SecondaryPort.conduitType, Endpoint.Source, this.filteredCell, this.gameObject);

            Game.Instance.solidConduitSystem.AddToNetworks(filteredCell, (object)itemFilter, true);

            SolidConduit.GetFlowManager().AddConduitUpdater(new System.Action <float>(this.ConduitUpdate), ConduitFlowPriority.Default);
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 11
0
        protected override void OnSpawn()
        {
            base.OnSpawn();

            var component = GetComponent <Building>();

            _inputCell  = component.GetUtilityInputCell();
            _outputCell = component.GetUtilityOutputCell();

            _filteredCell = Grid.OffsetCell(Grid.PosToCell(transform.GetPosition()), component.GetRotatedOffset(SecondaryPort.offset));

            var itemFilter = new FlowUtilityNetwork.NetworkItem(SecondaryPort.conduitType, Endpoint.Source, _filteredCell, gameObject);

            Game.Instance.solidConduitSystem.AddToNetworks(_filteredCell, itemFilter, true);
            SolidConduit.GetFlowManager().AddConduitUpdater(ConduitUpdate);
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
    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();
            });
        }
    }
    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);
    }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
        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.Source, utilityCell, base.gameObject);
            NetworkManager.AddToNetworks(utilityCell, networkItem, is_endpoint: true);

            partitionerEntry = GameScenePartitioner.Instance.Add("ConduitOutput.OnSpawn", base.gameObject, utilityCell, ScenePartitionerLayer, OnConduitConnectionChanged);

            ConduitManager.AddConduitUpdater(ConduitUpdate, ConduitFlowPriority.Dispense);
            OnConduitConnectionChanged(null);
        }
Ejemplo n.º 18
0
        protected override void OnSpawn()
        {
            try
            {
                base.OnSpawn();

                InputCell = Building.GetUtilityInputCell();

                OutputCell1 = Building.GetUtilityOutputCell();

                OutputCell2 = Grid.OffsetCell(Grid.PosToCell(transform.GetPosition()), Building.GetRotatedOffset(OutputPort2Info.offset));

                OutputItem2 = new FlowUtilityNetwork.NetworkItem(this.ConduitType, Endpoint.Source, OutputCell2, gameObject);

                NetworkMgr.AddToNetworks(OutputCell2, OutputItem2, true);

                FlowMgr.AddConduitUpdater(OnConduitUpdate);
            }
            catch (Exception ex)
            {
                KelmenUtils.Log("SolidTemperatureFilterProcess.OnSpawn", ex);
                throw ex;
            }
        }