Esempio n. 1
0
        public override MyObjectBuilder_CubeBlock GetObjectBuilderCubeBlock(bool copy = false)
        {
            MyObjectBuilder_OxygenTank objectBuilderCubeBlock = (MyObjectBuilder_OxygenTank)base.GetObjectBuilderCubeBlock(copy);

            objectBuilderCubeBlock.IsStockpiling = this.IsStockpiling;
            objectBuilderCubeBlock.FilledRatio   = (float)this.FilledRatio;
            objectBuilderCubeBlock.AutoRefill    = (bool)this.m_autoRefill;
            objectBuilderCubeBlock.Inventory     = this.GetInventory(0).GetObjectBuilder();
            return(objectBuilderCubeBlock);
        }
Esempio n. 2
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.SyncFlag = true;
            base.Init(objectBuilder, cubeGrid);
            MyObjectBuilder_OxygenTank tank = (MyObjectBuilder_OxygenTank)objectBuilder;

            this.InitializeConveyorEndpoint();
            if (Sync.IsServer)
            {
                base.NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME | MyEntityUpdateEnum.EACH_FRAME;
            }
            if (MyFakes.ENABLE_INVENTORY_FIX)
            {
                base.FixSingleInventory();
                if (this.GetInventory(0) != null)
                {
                    this.GetInventory(0).Constraint = this.BlockDefinition.InputInventoryConstraint;
                }
            }
            MyInventory component = this.GetInventory(0);

            if (component == null)
            {
                component = new MyInventory(this.BlockDefinition.InventoryMaxVolume, this.BlockDefinition.InventorySize, MyInventoryFlags.CanReceive)
                {
                    Constraint = this.BlockDefinition.InputInventoryConstraint
                };
                base.Components.Add <MyInventoryBase>(component);
                component.Init(tank.Inventory);
            }
            component.ContentsChanged += new Action <MyInventoryBase>(this.MyGasTank_ContentsChanged);
            this.m_autoRefill.SetLocalValue(tank.AutoRefill);
            MyResourceSourceInfo item = new MyResourceSourceInfo {
                ResourceTypeId = this.BlockDefinition.StoredGasId,
                DefinedOutput  = 0.05f * this.BlockDefinition.Capacity
            };
            List <MyResourceSourceInfo> list1 = new List <MyResourceSourceInfo>();

            list1.Add(item);
            List <MyResourceSourceInfo> sourceResourceData = list1;

            this.SourceComp.Init(this.BlockDefinition.ResourceSourceGroup, sourceResourceData);
            this.SourceComp.OutputChanged += new MyResourceOutputChangedDelegate(this.Source_OutputChanged);
            this.SourceComp.Enabled        = base.Enabled;
            this.IsStockpiling             = tank.IsStockpiling;
            MyResourceSinkInfo info2 = new MyResourceSinkInfo {
                ResourceTypeId    = MyResourceDistributorComponent.ElectricityId,
                MaxRequiredInput  = this.BlockDefinition.OperationalPowerConsumption,
                RequiredInputFunc = new Func <float>(this.ComputeRequiredPower)
            };
            List <MyResourceSinkInfo> list3 = new List <MyResourceSinkInfo>();

            list3.Add(info2);
            info2 = new MyResourceSinkInfo {
                ResourceTypeId    = this.BlockDefinition.StoredGasId,
                MaxRequiredInput  = this.Capacity,
                RequiredInputFunc = new Func <float>(this.ComputeRequiredGas)
            };
            list3.Add(info2);
            List <MyResourceSinkInfo> sinkData = list3;

            base.ResourceSink.Init(this.BlockDefinition.ResourceSinkGroup, sinkData);
            base.ResourceSink.IsPoweredChanged    += new Action(this.PowerReceiver_IsPoweredChanged);
            base.ResourceSink.CurrentInputChanged += new MyCurrentResourceInputChangedDelegate(this.Sink_CurrentInputChanged);
            float filledRatio = tank.FilledRatio;

            if (MySession.Static.CreativeMode && (filledRatio == 0f))
            {
                filledRatio = 0.5f;
            }
            this.ChangeFilledRatio((double)MathHelper.Clamp(filledRatio, 0f, 1f), false);
            base.ResourceSink.Update();
            base.AddDebugRenderComponent(new MyDebugRenderComponentDrawConveyorEndpoint(this.m_conveyorEndpoint));
            base.SlimBlock.ComponentStack.IsFunctionalChanged += new Action(this.ComponentStack_IsFunctionalChanged);
            base.IsWorkingChanged += new Action <MyCubeBlock>(this.MyOxygenTank_IsWorkingChanged);
        }