コード例 #1
0
        public override MyObjectBuilder_CubeBlock GetObjectBuilderCubeBlock(bool copy = false)
        {
            MyObjectBuilder_OxygenGenerator objectBuilderCubeBlock = (MyObjectBuilder_OxygenGenerator)base.GetObjectBuilderCubeBlock(copy);

            objectBuilderCubeBlock.Inventory         = this.GetInventory(0).GetObjectBuilder();
            objectBuilderCubeBlock.UseConveyorSystem = (bool)this.m_useConveyorSystem;
            objectBuilderCubeBlock.AutoRefill        = this.AutoRefill;
            return(objectBuilderCubeBlock);
        }
コード例 #2
0
        public OxyGen(IMyGasGenerator thisGenerator)
        {
            Id                 = $"{Id} ({thisGenerator.EntityId})";
            _thisGenerator     = thisGenerator;
            _thisTerminalBlock = thisGenerator;
            _thisCubeBlock     = (MyCubeBlock)thisGenerator;
            _thisEntity        = (MyEntity)thisGenerator;
            _thisGenerator.OnUpgradeValuesChanged += OnUpgradeValuesChanged;
            _thisGenerator.AppendingCustomInfo    += AppendingCustomInfo;
            _thisEntity.AddedToScene    += OnAddedToScene;
            MySink.RequiredInputChanged += OnRequiredInputChanged;
            _thisGenerator.OnClose      += OnClose;
            _thisGenerator.AddUpgradeValue(Power, 1f);
            _thisGenerator.AddUpgradeValue(Yield, 1f);
            _thisGenerator.AddUpgradeValue(Speed, 1f);

            MyObjectBuilder_OxygenGenerator x = (MyObjectBuilder_OxygenGenerator)_thisGenerator.GetObjectBuilderCubeBlock();

            MyOxygenGeneratorDefinition def = MyDefinitionManager.Static.GetCubeBlockDefinition(x.GetId()) as MyOxygenGeneratorDefinition;

            if (def == null)
            {
                return;
            }
            foreach (MyOxygenGeneratorDefinition.MyGasGeneratorResourceInfo resource in def.ProducedGases)
            {
                if (resource.Id == _oxyDef)
                {
                    _baseOxyMaxOutput = KshDefaultMultiplier * resource.IceToGasRatio;
                }
                if (resource.Id == _hydroDef)
                {
                    _baseHydroMaxOutput = KshDefaultMultiplier * resource.IceToGasRatio;
                }
            }
        }
コード例 #3
0
        public override unsafe void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.SyncFlag = true;
            List <MyResourceSourceInfo> sourceResourceData = new List <MyResourceSourceInfo>();

            foreach (MyOxygenGeneratorDefinition.MyGasGeneratorResourceInfo info in this.BlockDefinition.ProducedGases)
            {
                MyResourceSourceInfo *infoPtr1;
                MyResourceSourceInfo  item = new MyResourceSourceInfo {
                    ResourceTypeId = info.Id
                };
                infoPtr1->DefinedOutput = (this.BlockDefinition.IceConsumptionPerSecond * info.IceToGasRatio) * (MySession.Static.CreativeMode ? 10f : 1f);
                infoPtr1 = (MyResourceSourceInfo *)ref item;
                item.ProductionToCapacityMultiplier = 1f;
                sourceResourceData.Add(item);
            }
            this.SourceComp.Init(this.BlockDefinition.ResourceSourceGroup, sourceResourceData);
            base.Init(objectBuilder, cubeGrid);
            MyObjectBuilder_OxygenGenerator generator = objectBuilder as MyObjectBuilder_OxygenGenerator;

            this.InitializeConveyorEndpoint();
            this.m_useConveyorSystem.SetLocalValue(generator.UseConveyorSystem);
            base.NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME | MyEntityUpdateEnum.EACH_FRAME;
            MyInventory component = this.GetInventory(0);

            if (component != null)
            {
                component.Constraint = this.BlockDefinition.InputInventoryConstraint;
            }
            else
            {
                component = new MyInventory(this.BlockDefinition.InventoryMaxVolume, this.BlockDefinition.InventorySize, MyInventoryFlags.CanReceive)
                {
                    Constraint = this.BlockDefinition.InputInventoryConstraint
                };
                base.Components.Add <MyInventoryBase>(component);
            }
            this.m_oreConstraint = new MyInventoryConstraint(component.Constraint.Description, component.Constraint.Icon, component.Constraint.IsWhitelist);
            foreach (MyDefinitionId id in component.Constraint.ConstrainedIds)
            {
                if (id.TypeId != typeof(MyObjectBuilder_GasContainerObject))
                {
                    this.m_oreConstraint.Add(id);
                }
            }
            if (MyFakes.ENABLE_INVENTORY_FIX)
            {
                base.FixSingleInventory();
            }
            if (component != null)
            {
                component.Init(generator.Inventory);
            }
            this.AutoRefill         = generator.AutoRefill;
            this.SourceComp.Enabled = base.Enabled;
            if (Sync.IsServer)
            {
                this.SourceComp.OutputChanged += new MyResourceOutputChangedDelegate(this.Source_OutputChanged);
            }
            float num = this.IceAmount();

            foreach (MyDefinitionId id2 in this.SourceComp.ResourceTypes)
            {
                MyDefinitionId gasId = id2;
                this.m_sourceComp.SetRemainingCapacityByType(id2, (float)this.IceToGas(ref gasId, (double)num));
            }
            MyResourceSinkInfo sinkData = new MyResourceSinkInfo {
                ResourceTypeId    = MyResourceDistributorComponent.ElectricityId,
                MaxRequiredInput  = this.BlockDefinition.OperationalPowerConsumption,
                RequiredInputFunc = new Func <float>(this.ComputeRequiredPower)
            };

            base.ResourceSink.Init(this.BlockDefinition.ResourceSinkGroup, sinkData);
            base.ResourceSink.IsPoweredChanged += new Action(this.PowerReceiver_IsPoweredChanged);
            base.ResourceSink.Update();
            this.UpdateText();
            base.AddDebugRenderComponent(new MyDebugRenderComponentDrawConveyorEndpoint(this.m_conveyorEndpoint));
            base.SlimBlock.ComponentStack.IsFunctionalChanged += new Action(this.ComponentStack_IsFunctionalChanged);
            base.IsWorkingChanged += new Action <MyCubeBlock>(this.MyGasGenerator_IsWorkingChanged);
        }