Ejemplo n.º 1
0
        public void OnComponentInstallation(Entity parentEntity, ComponentInstance componentInstance)
        {
            Guid               resourceID      = EnergyTypeID;
            ICargoable         energyCargoable = StaticRefLib.StaticData.GetICargoable(resourceID);
            EnergyGenAbilityDB genDB;

            if (!parentEntity.HasDataBlob <EnergyGenAbilityDB>())
            {
                genDB            = new EnergyGenAbilityDB(parentEntity.StarSysDateTime);
                genDB.EnergyType = energyCargoable;
                parentEntity.SetDataBlob(genDB);
            }
            else
            {
                genDB = parentEntity.GetDataBlob <EnergyGenAbilityDB>();


                if (genDB.EnergyType == null)
                {
                    genDB.EnergyType = energyCargoable;
                }
                else if (genDB.EnergyType != energyCargoable)//this is just to reduce complexity. we can add this ability later.
                {
                    throw new Exception("PrimeEntity cannot use two different energy types");
                }
                if (genDB.TotalFuelUseAtMax.type == Guid.Empty)
                {
                    genDB.TotalFuelUseAtMax.type = FuelType;
                }
                else if (genDB.TotalFuelUseAtMax.type != FuelType)
                {
                    throw new Exception("PrimeEntity cannot have power plants that use different fuel types");
                }
            }

            genDB.TotalOutputMax += PowerOutputMax;
            double maxUse = genDB.TotalFuelUseAtMax.maxUse + FuelUsedAtMax;

            genDB.TotalFuelUseAtMax = (FuelType, maxUse);
            genDB.LocalFuel         = maxUse * Lifetime;

            //add enough energy store for 1s of running.
            if (genDB.EnergyStoreMax.ContainsKey(EnergyTypeID))
            {
                genDB.EnergyStoreMax[EnergyTypeID] += PowerOutputMax;
            }
            else
            {
                genDB.EnergyStored[EnergyTypeID]   = 0;
                genDB.EnergyStoreMax[EnergyTypeID] = PowerOutputMax;
            }
        }
Ejemplo n.º 2
0
        public void OnComponentInstallation(Entity parentEntity, ComponentInstance componentInstance)
        {
            EnergyGenAbilityDB genDB;

            if (!parentEntity.HasDataBlob <EnergyGenAbilityDB>())
            {
                genDB = new EnergyGenAbilityDB(parentEntity.StarSysDateTime);
                parentEntity.SetDataBlob(genDB);
            }
            else
            {
                genDB = parentEntity.GetDataBlob <EnergyGenAbilityDB>();
            }
            if (genDB.EnergyStoreMax.ContainsKey(EnergyTypeID))
            {
                genDB.EnergyStoreMax[EnergyTypeID] += MaxStore;
            }
            else
            {
                genDB.EnergyStored[EnergyTypeID]   = 0;
                genDB.EnergyStoreMax[EnergyTypeID] = MaxStore;
            }
        }