Esempio n. 1
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();
        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();
    }
Esempio n. 3
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);
        }
        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();
        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);
    }
Esempio n. 6
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);
        }
Esempio n. 7
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();
            });
        }
    }
Esempio n. 8
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);
        }
    protected override void OnSpawn()
    {
        base.OnSpawn();
        //base.smi.StartSM();

        this.inputCell  = this.building.GetUtilityInputCell();
        this.outputCell = this.building.GetUtilityOutputCell();
        int        cell          = Grid.PosToCell(base.transform.GetPosition());
        CellOffset rotatedOffset = this.building.GetRotatedOffset(this.portInfo.offset);

        this.sInputCell = Grid.OffsetCell(cell, rotatedOffset);
        IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(this.portInfo.conduitType);

        this.itemSInput = new FlowUtilityNetwork.NetworkItem(this.portInfo.conduitType, Endpoint.Sink, this.sInputCell, base.gameObject);
        networkManager.AddToNetworks(this.sInputCell, this.itemSInput, true);
        base.GetComponent <ConduitConsumer>().isConsuming = false;
        //this.OnFilterChanged(ElementLoader.FindElementByHash(this.filteredElem).tag);
        //this.filterable.onFilterChanged += this.OnFilterChanged;
        ConduitFlow flowManager = Conduit.GetFlowManager(this.portInfo.conduitType);

        flowManager.AddConduitUpdater(this.OnConduitTick, ConduitFlowPriority.Default);
        //base.GetComponent<KSelectable>().SetStatusItem(Db.Get().StatusItemCategories.Main, ElementFilter.filterStatusItem, this);
    }