Exemplo n.º 1
0
 public void ServerInitialize(ItemWithFuelPrivateState privateState, bool isFirstTimeInit)
 {
     if (isFirstTimeInit)
     {
         // set initial fuel amount
         privateState.FuelAmount = this.FuelAmountInitial;
     }
     else
     {
         // clamp current fuel amount
         privateState.FuelAmount = MathHelper.Clamp(privateState.FuelAmount, 0, this.FuelCapacity);
     }
 }
Exemplo n.º 2
0
        public void SharedTryConsumeFuel(
            IItem item,
            ItemWithFuelPrivateState privateState,
            double deltaTime,
            out bool isFuelRanOut)
        {
            var fuelAmount = privateState.FuelAmount;

            fuelAmount -= this.FuelUsePerSecond * deltaTime;

            if (fuelAmount <= 0)
            {
                fuelAmount = 0;
                Api.Logger.Info(item + " - fuel has ran out - make it inactive");
                isFuelRanOut = true;
            }
            else
            {
                isFuelRanOut = false;
            }

            privateState.FuelAmount = fuelAmount;
        }