コード例 #1
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;
            }
        }