Ejemplo n.º 1
0
        static long GetOres(List <Ores> recipes, long needAmount)
        {
            Dictionary <string, long> need = new Dictionary <string, long>
            {
                { "FUEL", needAmount }
            };

            Dictionary <string, long> have = new Dictionary <string, long>();

            while (need.Any(kvp => kvp.Key != "ORE" && kvp.Value > 0))
            {
                var  next     = need.First(kvp => kvp.Key != "ORE" && kvp.Value > 0); //ore doesn't have recipe
                Ores reaction = recipes.First(o => o.Name == next.Key);

                long modifier = (long)Math.Ceiling(need[next.Key] / (double)reaction.Amount); //create at least the amount we need

                RemoveNeed(need, have, next.Key, modifier * reaction.Amount);

                foreach (Ores ore in reaction.Requires)
                {
                    AddNeed(need, have, ore.Name, modifier * ore.Amount);
                }
            }

            return(need["ORE"]);
        }
Ejemplo n.º 2
0
 public static int Hue(Ores oreType)
 {
     switch (oreType)
     {
         case Ores.Adamantite:
             return 0x363;
         case Ores.Clay:
             return 0x222;
         case Ores.Coal:
             return 0x7E3;
         case Ores.Copper:
             return 0x466;
         case Ores.Gold:
             return 0x501;
         case Ores.Iron:
             return 0x21F;
         case Ores.Mithril:
             return 0x18A;
         case Ores.RuneEssence:
             return 0x7C4;
         case Ores.Rune:
             return 0xBC;
         case Ores.Silver:
             return 0x47E;
         case Ores.Tin:
             return 0x764;
     }
     return 0;
 }
        public bool CheckOre(Cargo cargo, Ores ore, int amount)
        {
            switch (ore)
            {
            case Ores.DURANIUM:
                if (cargo.Duranium < amount)
                {
                    return(false);
                }
                return(true);

            case Ores.PROMETID:
                if (cargo.Prometid < amount)
                {
                    return(false);
                }
                return(true);

            case Ores.PROMERIUM:
                if (cargo.Promerium < amount)
                {
                    return(false);
                }
                return(true);

            case Ores.SEPROM:
                if (cargo.Seprom < amount)
                {
                    return(false);
                }
                return(true);
            }

            return(false);
        }
Ejemplo n.º 4
0
 public BaseMiningRocks(Ores oreType)
     : base(Utility.RandomBool() ? 0x1367 : Utility.RandomList(0x1363, 0x1364, 0x1367, 0x136A, 0x136D))
 {
     mOreType   = oreType;
     OrePresent = true;
     Movable    = false;
     Stackable  = false;
     myTimer    = new MyTimer(this);
 }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            List <Ores> recipes = new List <Ores>();

            using (StreamReader sr = new StreamReader(File.OpenRead("data.txt")))
            {
                while (!sr.EndOfStream)
                {
                    string   s     = sr.ReadLine();
                    string[] inOut = s.Split("=>");

                    // output first
                    Ores ore = new Ores();
                    inOut[1] = inOut[1].Trim();
                    string[] produces = inOut[1].Split(' ');
                    ore.Amount = Convert.ToInt32(produces[0]);
                    ore.Name   = produces[1];

                    // then input
                    ore.Requires = new List <Ores>();

                    string[] inList = inOut[0].Split(',');

                    for (int i = 0; i < inList.Length; i++)
                    {
                        inList[i] = inList[i].Trim();
                        string[] needed   = inList[i].Split(' ');
                        Ores     required = new Ores();
                        required.Amount = Convert.ToInt32(needed[0]);
                        required.Name   = needed[1];
                        ore.Requires.Add(required);
                    }

                    recipes.Add(ore);
                }
            }

            Console.WriteLine($"Number of reactions: {recipes.Count}");

            // part1 | result: 485720

            long ores = GetOres(recipes, 1);

            Console.WriteLine($"ORE count: {ores}");

            // part2 | result: 3848998

            long maxOres    = 1000000000000;
            long fuelAmount = GetFuel(recipes, maxOres);

            Console.WriteLine($"FUEL amount: {fuelAmount}");

            Console.ReadKey();
        }
Ejemplo n.º 6
0
 void MergeIngOreListInfo()
 {
     _infoIngOre = $"\n=== СЛИТКИ / РУДЫ ===";
     foreach (var item in Ingots)
     {
         _infoIngOre += $"\n{TranslateName_components(item.Key)} : {item.Value.Amount} кг";
         if (Ores.ContainsKey(item.Key))
         {
             _infoIngOre += $" ( {Math.Round((double)Ores[item.Key].Amount / 1000)} т руды )";
         }
     }
 }
Ejemplo n.º 7
0
 public void UpgradeShields(Ores ore, int amount)
 {
     if (ShieldUpgrades == null || ShieldUpgrades.Ore != ore)
     {
         ShieldUpgrades = new Upgrade {
             Ore = ore, Amount = amount
         };
     }
     else
     {
         ShieldUpgrades.Amount += amount;
     }
     World.DatabaseManager.SaveSkylab(Player, this);
 }
Ejemplo n.º 8
0
 public void UpgradeGenerators(Ores ore, int amount)
 {
     if (GeneratorsUpgrades == null || GeneratorsUpgrades.Ore != ore)
     {
         GeneratorsUpgrades = new Upgrade {
             Ore = ore, Amount = amount
         };
     }
     else
     {
         GeneratorsUpgrades.Amount += amount;
     }
     World.DatabaseManager.SaveSkylab(Player, this);
 }
Ejemplo n.º 9
0
        public static double RespawnSeconds(Ores ores)
        {
            double spawnTime = 2.0;
            int    count     = NetState.Instances.Count > 200 ? 200 : NetState.Instances.Count < 10 ? 10 : NetState.Instances.Count;
            double discount  = 1 - (double)count / 400.0;

            switch (ores)
            {
            case Ores.Copper:
            case Ores.Tin:
                spawnTime = 4.0;
                break;

            case Ores.Iron:
                spawnTime = 10.0;
                break;

            case Ores.Silver:
                spawnTime = 90.0;
                break;

            case Ores.Gold:
                spawnTime = 120.0;
                break;

            case Ores.Coal:
                spawnTime = 60.0;
                break;

            case Ores.Mithril:
                spawnTime = 240.0;
                break;

            case Ores.Adamantite:
                spawnTime = 480.0;
                break;

            case Ores.Rune:
                spawnTime = 1500.0;
                break;

            case Ores.Clay:
            case Ores.RuneEssence:
            default:
                spawnTime = 2.0;
                break;
            }
            return(spawnTime * discount);
        }
Ejemplo n.º 10
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
                case 0:
                    {
                        mOreType = (Ores)reader.ReadInt();
                        break;
                    }
            }
        }
Ejemplo n.º 11
0
 public void UpgradeRockets(Ores ore, int amount)
 {
     amount *= 10;
     if (RocketUpgrades == null || RocketUpgrades.Ore != ore)
     {
         RocketUpgrades = new Upgrade {
             Ore = ore, Amount = amount
         };
     }
     else
     {
         RocketUpgrades.Amount += amount;
     }
     World.DatabaseManager.SaveSkylab(Player, this);
 }
Ejemplo n.º 12
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 0:
            {
                mOreType = (Ores)reader.ReadInt();
                break;
            }
            }
        }
Ejemplo n.º 13
0
        void ModuleProgramInit()
        {
            wicoThrusters  = new WicoThrusters(this, wicoBlockMaster);
            wicoGyros      = new WicoGyros(this, wicoBlockMaster);
            wicoGasTanks   = new GasTanks(this, wicoBlockMaster);
            wicoGasGens    = new GasGens(this);
            wicoConnectors = new Connectors(this);
            wicoCameras    = new Cameras(this);
            wicoAntennas   = new Antennas(this);
            wicoSensors    = new Sensors(this, wicoBlockMaster);
            wicoPower      = new PowerProduction(this, wicoBlockMaster);
            wicoTimers     = new Timers(this, wicoBlockMaster);
            //            navRemote = new NavRemote(this);
            navCommon = new NavCommon(this);
            _sensors  = new Sensors(this, wicoBlockMaster);
            _drills   = new Drills(this, wicoBlockMaster);
            _displays = new Displays(this, wicoBlockMaster, wicoElapsedTime);
            Echo("_displays");
            _cargoCheck = new CargoCheck(this, wicoBlockMaster, _displays);
            Echo("_cargoCheck");
            _dock = new DockBase(this);
            Echo("_dock");
//            _scanBase = new ScanBase(this, _wicoControl);
            _asteroids = new Asteroids(this, _wicoControl, wicoIGC, _displays);
            _scanMode  = new ScansMode(this, _wicoControl, wicoBlockMaster, wicoIGC, wicoCameras, _asteroids);
            _ores      = new Ores(this, wicoBlockMaster, _wicoControl, wicoIGC, _asteroids, _displays);

            Echo("_ores");

            _miner = new Miner(this, _wicoControl, wicoBlockMaster, wicoElapsedTime, wicoIGC
                               , _scanMode, _asteroids, wicoThrusters, wicoConnectors, wicoSensors
                               , wicoCameras, _drills, wicoAntennas, wicoGasTanks, wicoGyros, wicoPower
                               , wicoTimers, navCommon, _ores, _dock
                               , _displays
                               );
            Echo("_miner");
            //                spaceDock = new SpaceDock(this, _wicoControl, wicoBlockMaster, wicoThrusters, wicoConnectors,
            //                    wicoAntennas, wicoGasTanks, wicoGyros, wicoPower, wicoTimers, wicoIGC, wicoBases, navCommon, _cargoCheck);
            //wicoOrbitalLaunch = new OrbitalModes(this);
            //            wicoNavigation = new Navigation(this, wicoBlockMaster.GetMainController());

            /// DEBUG
            // wicoIGC.SetDebug(true);
//        _wicoControl.SetDebug(true);
            // wicoElapsedTime.SetDebug(true);
        }
Ejemplo n.º 14
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 0:
            {
                mOreType   = (Ores)reader.ReadInt();
                OrePresent = true;
                myTimer    = new MyTimer(this);
                break;
            }
            }
        }
Ejemplo n.º 15
0
        public void Reconnect()
        {
            Console.WriteLine("Connection lost. Reconnecting.");
            _vanillaClient.pingThread?.Abort();
            Boxes.Clear();
            MemorizedBoxes.Clear();
            Ores.Clear();
            Ships.Clear();
            Gates.Clear();
            Buildings.Clear();
            _proxy.Reset();

            if (_vanillaClient.tcpClient.Connected)
            {
                _vanillaClient.Disconnect();
            }

            _vanillaClient.thread?.Abort();
        }
Ejemplo n.º 16
0
        public static int MiningLevelNeeded(Ores toMineOre)
        {
            switch (toMineOre)
            {
            case Ores.Adamantite:
                return(70);

            case Ores.Clay:
                return(1);

            case Ores.Coal:
                return(30);

            case Ores.Copper:
                return(1);

            case Ores.Gold:
                return(40);

            case Ores.Iron:
                return(15);

            case Ores.Mithril:
                return(55);

            case Ores.RuneEssence:
                return(5);

            case Ores.Rune:
                return(85);

            case Ores.Silver:
                return(20);

            case Ores.Tin:
            default:
                return(1);
            }
        }
Ejemplo n.º 17
0
        public static int Hue(Ores oreType)
        {
            switch (oreType)
            {
            case Ores.Adamantite:
                return(0x363);

            case Ores.Clay:
                return(0x222);

            case Ores.Coal:
                return(0x7E3);

            case Ores.Copper:
                return(0x466);

            case Ores.Gold:
                return(0x501);

            case Ores.Iron:
                return(0x21F);

            case Ores.Mithril:
                return(0x18A);

            case Ores.RuneEssence:
                return(0x7C4);

            case Ores.Rune:
                return(0xBC);

            case Ores.Silver:
                return(0x47E);

            case Ores.Tin:
                return(0x764);
            }
            return(0);
        }
Ejemplo n.º 18
0
 void SortingItems(ref List <MyInventoryItem> items)
 {
     foreach (var item in items)
     {
         if (item.Type.TypeId == "MyObjectBuilder_Component" && Components.ContainsKey(item.Type.SubtypeId)) // Если имя сходится с тем что в словаре
         {
             Components[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe();
         }
         else if (item.Type.TypeId == "MyObjectBuilder_Ingot" && Ingots.ContainsKey(item.Type.SubtypeId))
         {
             Ingots[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe();
         }
         else if (item.Type.TypeId == "MyObjectBuilder_Ore" && Ores.ContainsKey(item.Type.SubtypeId))
         {
             Ores[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe();
         }
         else if (item.Type.TypeId == "MyObjectBuilder_PhysicalGunObject" && Tools.ContainsKey(item.Type.SubtypeId))
         {
             Tools[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe();
         }
         else if (item.Type.TypeId == "MyObjectBuilder_OxygenContainerObject" && Oxygen.ContainsKey(item.Type.SubtypeId))
         {
             Oxygen[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe();
         }
         else if (item.Type.TypeId == "MyObjectBuilder_GasContainerObject" && Hydrogen.ContainsKey(item.Type.SubtypeId))
         {
             Hydrogen[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe();
         }
         else if (item.Type.TypeId == "MyObjectBuilder_AmmoMagazine" && Ammo.ContainsKey(item.Type.SubtypeId))
         {
             Ammo[item.Type.SubtypeId].Amount += item.Amount.ToIntSafe();
         }
         else
         {
             Warning += $"\n[{item.Type.TypeId}/{item.Type.SubtypeId}] отсутствует в словарях";
         }
     }
 }
Ejemplo n.º 19
0
        public void ReduceOre(Ores ore, int amount)
        {
            switch (ore)
            {
            case Ores.SEPROM:
                Seprom -= amount;
                break;

            case Ores.PROMERIUM:
                Promerium -= amount;
                break;

            case Ores.DURANIUM:
                Duranium -= amount;
                break;

            case Ores.PROMETID:
                Prometid -= amount;
                break;
            }
            Packet.Builder.AttributeOreCountUpdateCommand(Player.GetGameSession(), this);
            World.DatabaseManager.SaveCargo(Player, this);
        }
Ejemplo n.º 20
0
        public static BaseRunescapeGem FindGem(Mobile from, Ores oreType, RunescapePickaxe pick)
        {
            BaseRunescapeGem gem      = null;
            double           chance   = 0.005; // Half of 1%
            Item             necklace = from.FindItemOnLayer(Layer.Neck);

            if (necklace != null && necklace is AmuletOfGlory)
            {
                chance = 0.015;                                                           // Increased to 1.5% chance if wearing Glory Ammy
            }
            chance = oreType >= Ores.Mithril ? chance + 0.005 : chance;                   // increased by another half percent if Mith rock and above
            chance = pick.WeaponType >= RuneWeaponType.Mithril ? chance + 0.005 : chance; // increased by another half percent if Mith pick and above

            if (chance > Utility.RandomDouble())
            {
                int select = Utility.Random(100);

                if (select > 97)
                {
                    gem = new DiamondGem();
                }
                else if (select > 90)
                {
                    gem = new RubyGem();
                }
                else if (select > 60)
                {
                    gem = new EmeraldGem();
                }
                else
                {
                    gem = new SapphhireGem();
                }
            }

            return(gem);
        }
Ejemplo n.º 21
0
 public void removeOre(Ores o)
 {
     myOres &= ~o;
 }
Ejemplo n.º 22
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
                case 0:
                {
                    mOreType = (Ores) reader.ReadInt();
                    OrePresent = true;
                    myTimer = new MyTimer(this);
                    break;
                }
            }
        }
Ejemplo n.º 23
0
 public BaseMiningRocks(Ores oreType)
     : base(Utility.RandomBool() ? 0x1367 : Utility.RandomList(0x1363, 0x1364, 0x1367, 0x136A, 0x136D))
 {
     mOreType = oreType;
     OrePresent = true;
     Movable = false;
     Stackable = false;
     myTimer = new MyTimer(this);
 }
Ejemplo n.º 24
0
 public RunescapeOre(Ores oreType)
     : base(Utility.RandomBool() ? 0x19B9 : Utility.Random(4) + 0x19B7)
 {
     mOreType  = oreType;
     Stackable = true;
 }
Ejemplo n.º 25
0
 public static bool IsCluster(ushort type) => type <= TileLoader.TileCount && (TileID.Sets.Ore[type] || Ores.Contains(type) || GemOres.Contains(type));
Ejemplo n.º 26
0
 public void addOre(Ores o)
 {
     myOres |= o;
 }
Ejemplo n.º 27
0
 public bool hasOre(Ores o)
 {
     return(myOres.HasFlag(o));
 }
Ejemplo n.º 28
0
 public static double RespawnSeconds(Ores ores)
 {
     double spawnTime = 2.0;
     int count = NetState.Instances.Count > 200 ? 200 : NetState.Instances.Count < 10 ? 10 : NetState.Instances.Count;
     double discount = 1 - (double)count / 400.0;
     switch (ores)
     {
         case Ores.Copper:
         case Ores.Tin:
             spawnTime = 4.0;
             break;
         case Ores.Iron:
             spawnTime = 10.0;
             break;
         case Ores.Silver:
             spawnTime = 90.0;
             break;
         case Ores.Gold:
             spawnTime = 120.0;
             break;
         case Ores.Coal:
             spawnTime = 60.0;
             break;
         case Ores.Mithril:
             spawnTime = 240.0;
             break;
         case Ores.Adamantite:
             spawnTime = 480.0;
             break;
         case Ores.Rune:
             spawnTime = 1500.0;
             break;
         case Ores.Clay:
         case Ores.RuneEssence:
         default:
             spawnTime = 2.0;
             break;
     }
     return spawnTime * discount;
 }
Ejemplo n.º 29
0
 public static int MiningLevelNeeded(Ores toMineOre)
 {
     switch (toMineOre)
     {
         case Ores.Adamantite:
             return 70;
         case Ores.Clay:
             return 1;
         case Ores.Coal:
             return 30;
         case Ores.Copper:
             return 1;
         case Ores.Gold:
             return 40;
         case Ores.Iron:
             return 15;
         case Ores.Mithril:
             return 55;
         case Ores.RuneEssence:
             return 5;
         case Ores.Rune:
             return 85;
         case Ores.Silver:
             return 20;
         case Ores.Tin:
         default:
             return 1;
     }
 }
Ejemplo n.º 30
0
 public RunescapeOre(Ores oreType)
     : base(Utility.RandomBool() ? 0x19B9 : Utility.Random(4) + 0x19B7)
 {
     mOreType = oreType;
     Stackable = true;
 }
Ejemplo n.º 31
0
            public CornuConfig()
            {
                // Animals
                Animals.Add(new CornuConfigItem {
                    Prefab = "assets/bundled/prefabs/autospawn/animals/chicken.prefab", Min = -1, Max = -1, IgnoreIrridiated = true
                });
                Animals.Add(new CornuConfigItem {
                    Prefab = "assets/bundled/prefabs/autospawn/animals/horse.prefab", Min = -1, Max = -1, IgnoreIrridiated = true
                });
                Animals.Add(new CornuConfigItem {
                    Prefab = "assets/bundled/prefabs/autospawn/animals/boar.prefab", Min = -1, Max = -1, IgnoreIrridiated = true
                });
                Animals.Add(new CornuConfigItem {
                    Prefab = "assets/bundled/prefabs/autospawn/animals/stag.prefab", Min = -1, Max = -1, IgnoreIrridiated = true
                });
                Animals.Add(new CornuConfigItem {
                    Prefab = "assets/bundled/prefabs/autospawn/animals/wolf.prefab", Min = -1, Max = -1, IgnoreIrridiated = true
                });
                Animals.Add(new CornuConfigItem {
                    Prefab = "assets/bundled/prefabs/autospawn/animals/bear.prefab", Min = -1, Max = -1, IgnoreIrridiated = true
                });

                // Ore nodes
                Ores.Add(new CornuConfigItem {
                    Prefab = "assets/bundled/prefabs/autospawn/resource/ores/stone-ore.prefab", Min = -1, Max = -1, IgnoreIrridiated = true
                });
                Ores.Add(new CornuConfigItem {
                    Prefab = "assets/bundled/prefabs/autospawn/resource/ores/metal-ore.prefab", Min = -1, Max = -1, IgnoreIrridiated = true
                });
                Ores.Add(new CornuConfigItem {
                    Prefab = "assets/bundled/prefabs/autospawn/resource/ores/sulfur-ore.prefab", Min = -1, Max = -1, IgnoreIrridiated = true
                });

                // Silver barrels
                Loots.Add(new CornuConfigItem {
                    Prefab = "assets/bundled/prefabs/radtown/loot_barrel_1.prefab", Min = -1, Max = -1, IgnoreIrridiated = true, DeleteEmtpy = false
                });

                // Brown barrels
                Loots.Add(new CornuConfigItem {
                    Prefab = "assets/bundled/prefabs/radtown/loot_barrel_2.prefab", Min = -1, Max = -1, IgnoreIrridiated = true, DeleteEmtpy = false
                });

                // Oil Drums
                Loots.Add(new CornuConfigItem {
                    Prefab = "assets/bundled/prefabs/radtown/oil_barrel.prefab", Min = -1, Max = -1, IgnoreIrridiated = true, DeleteEmtpy = false
                });

                // Trashcans
                Loots.Add(new CornuConfigItem {
                    Prefab = "assets/bundled/prefabs/radtown/loot_trash.prefab", Min = -1, Max = -1, IgnoreIrridiated = true, DeleteEmtpy = false
                });

                // Trash piles (food)
                Loots.Add(new CornuConfigItem {
                    Prefab = "assets/bundled/prefabs/autospawn/resource/loot/trash-pile-1.prefab", Min = -1, Max = -1, IgnoreIrridiated = true, DeleteEmtpy = false
                });

                // Weapon crates
                Loots.Add(new CornuConfigItem {
                    Prefab = "assets/bundled/prefabs/radtown/crate_normal.prefab", Min = -1, Max = -1, IgnoreIrridiated = true, DeleteEmtpy = false
                });

                // Box crates
                Loots.Add(new CornuConfigItem {
                    Prefab = "assets/bundled/prefabs/radtown/crate_normal_2.prefab", Min = -1, Max = -1, IgnoreIrridiated = true, DeleteEmtpy = false
                });
            }
Ejemplo n.º 32
0
        public static BaseRunescapeGem FindGem(Mobile from, Ores oreType, RunescapePickaxe pick)
        {
            BaseRunescapeGem gem = null;
            double chance = 0.005; // Half of 1%
            Item necklace = from.FindItemOnLayer(Layer.Neck);
            if (necklace != null && necklace is AmuletOfGlory)
                chance = 0.015; // Increased to 1.5% chance if wearing Glory Ammy
            chance = oreType >= Ores.Mithril ? chance + 0.005 : chance; // increased by another half percent if Mith rock and above
            chance = pick.WeaponType >= RuneWeaponType.Mithril ? chance + 0.005 : chance; // increased by another half percent if Mith pick and above

            if (chance > Utility.RandomDouble())
            {
                int select = Utility.Random(100);

                if (select>97) gem=new DiamondGem();
                else if (select>90) gem = new RubyGem();
                else if (select>60) gem=new EmeraldGem();
                else gem = new SapphhireGem();
            }

            return gem;
        }