private static void RefuelCraft(Base @base, Craft craft) { var metadata = craft.CraftType.Metadata(); switch (metadata.FuelType) { case FuelType.Normal: craft.Fuel += 50; break; case FuelType.Elerium115: if (@base.Stores[ItemType.Elerium115] == 0) { NotifyNotEnoughStoresToRefuelCraft(@base, craft); return; } @base.Stores.Remove(ItemType.Elerium115); craft.Fuel += 5; break; } if (craft.Fuel < metadata.Fuel) return; craft.Fuel = metadata.Fuel; craft.TransitionStatus(); }
private static void RepairCraft(Craft craft) { --craft.Damage; if (craft.Damage == 0) craft.TransitionStatus(); }
private static void RearmCraft(Base @base, Craft craft) { var weapon = craft.Weapons.FirstOrDefault(craftWeapon => !craftWeapon.IsFullyArmed); if (weapon == null) { craft.TransitionStatus(); return; } var metadata = weapon.WeaponType.Metadata(); if (metadata.Ammo == null) weapon.Reload(100); else { foreach (var ammo in Enumerable.Range(0, metadata.AmmoPerHour)) { if (@base.Stores[metadata.Ammo.Value] == 0) { NotifyNotEnoughStoresToRearmCraft(@base, craft, metadata.Ammo.Value); return; } @base.Stores.Remove(metadata.Ammo.Value); weapon.Reload(metadata.RoundsInAmmo); if (weapon.IsFullyArmed) break; } } }