public void AddLoot(ref MaterialSet looted_addition) { Metal = (long)(Metal + looted_addition.Metal / 8d); Crystal = (long)(Crystal + looted_addition.Crystal / 2d); Fissile = (long)(Fissile + looted_addition.Fissile / 2d); Starfuel = (long)(Starfuel + looted_addition.Starfuel / 4d); }
// Add materials to this set public void Add(ref MaterialSet addition) { Metal += addition.Metal; Crystal += addition.Crystal; Fissile += addition.Fissile; Starfuel += addition.Starfuel; }
// Remove materials from this set public void Deplete(ref MaterialSet depletion) { Metal -= depletion.Metal; Crystal -= depletion.Crystal; Fissile -= depletion.Fissile; Starfuel -= depletion.Starfuel; }
// Test if this material set contains at least some requierements public bool HasEnough(ref MaterialSet requierement) { return(Metal >= requierement.Metal && Crystal >= requierement.Crystal && Fissile >= requierement.Fissile && Starfuel >= requierement.Starfuel); }
// Import/Export public void SetProperty(string name, string value) { switch (name ?? "") { case "desc": { desc = value; break; } case "sprite": { SetSprite(value); break; } case "level": { level = Convert.ToInt32(value); break; } case "width": { width = Convert.ToInt32(value); break; } case "integrity": { integrity = Convert.ToInt32(value); break; } case "repair": { repair = Convert.ToInt32(value); break; } case "speed": { speed = Helpers.ToFloat(value); if (turn == 0d) { turn = speed; } break; } case "turn": { turn = Helpers.ToFloat(value); break; } case "weapon": { default_weapons.Add(value); break; } case "shield": { shield = Convert.ToInt32(value); if (shield_opacity == 0.0) { shield_opacity = 0.25f; } break; } case "shield_regeneration": { shield_regeneration = Helpers.ToFloat(value); break; } case "shield_opacity": { shield_opacity = Helpers.ToFloat(value); break; } case "deflectors": { deflectors = Convert.ToInt32(value); break; } case "deflectors_cooldown": { deflectors_cooldown = Convert.ToInt32(value); break; } case "hot_deflectors": { hot_deflectors = Convert.ToInt32(value); break; } case "cold_deflectors": { cold_deflectors = Convert.ToInt32(value); break; } case "craft": { crafts.Add(value); break; } case "native_upgrade": { native_upgrades.Add(value); break; } case "cost": { cost = new MaterialSet(value); if (complexity == 0) { complexity = (int)((width * 5) + (cost.Metal / 8) + (cost.Crystal * 15L) + (cost.Starfuel / 4d) + (cost.Fissile * 100L)); } break; } case "complexity": { complexity = Convert.ToInt32(value); break; } // spawning case "role": role = ShipRoles(value); break; case "spawning_frequency": spawning_frequency = Helpers.ToDouble(value); break; case "spawning_amount_min": spawning_amount_min = Convert.ToInt32(value); break; case "spawning_amount_max": spawning_amount_max = Convert.ToInt32(value); break; case "spawning_amount": { spawning_amount_min = Convert.ToInt32(value); spawning_amount_max = spawning_amount_min + 1; break; } default: throw new Exception("'" + name + "' is not a valid ship property"); } }