示例#1
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();
        ConduitFlow liquidConduitFlow = Game.Instance.liquidConduitFlow;

        liquidConduitFlow.onConduitsRebuilt += OnConduitsRebuilt;
        liquidConduitFlow.AddConduitUpdater(OnConduitUpdate, ConduitFlowPriority.Default);
        KBatchedAnimController component2 = GetComponent <KBatchedAnimController>();

        fillMeter          = new MeterController(component2, "meter_target", "meter", Meter.Offset.Behind, Grid.SceneLayer.NoLayer, new Vector3(0.4f, 3.2f, 0.1f));
        contaminationMeter = new MeterController(component2, "meter_target", "meter_dirty", Meter.Offset.Behind, Grid.SceneLayer.NoLayer, new Vector3(0.4f, 3.2f, 0.1f));
        Components.Toilets.Add(this);
        base.smi.StartSM();
        base.smi.ShowFillMeter();
    }
    protected override void OnSpawn()
    {
        base.OnSpawn();
        KBatchedAnimController component = GetComponent <KBatchedAnimController>();

        meter_coolant = new MeterController((KAnimControllerBase)component, "meter_target", "meter_coolant", Meter.Offset.Infront, Grid.SceneLayer.NoLayer, Vector3.zero, (string[])null);
        meter_metal   = new MeterController((KAnimControllerBase)component, "meter_target_metal", "meter_metal", Meter.Offset.Infront, Grid.SceneLayer.NoLayer, Vector3.zero, (string[])null);
        meter_metal.SetPositionPercent(1f);
        smi = new StatesInstance(this);
        smi.StartSM();
        ConduitFlow liquidConduitFlow = Game.Instance.liquidConduitFlow;

        liquidConduitFlow.AddConduitUpdater(OnConduitUpdate, ConduitFlowPriority.Default);
        Building component2 = GetComponent <Building>();

        outputCell = component2.GetUtilityOutputCell();
        workable.OnWorkTickActions = delegate
        {
            float percentComplete = workable.GetPercentComplete();
            meter_metal.SetPositionPercent(percentComplete);
        };
    }
    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);
    }