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