示例#1
0
        public ItemId PreformAction(Colony colony, RoamingJobState state)
        {
            var retval = ItemId.GetItemId(GameLoader.NAMESPACE + ".Repairing");

            if (!colony.OwnerIsOnline() && SettlersConfiguration.OfflineColonies || colony.OwnerIsOnline())
            {
                if (state.GetActionEnergy(MachineConstants.REPAIR) < .75f)
                {
                    var repaired       = false;
                    var requiredForFix = new List <InventoryItem>();
                    var stockpile      = colony.Stockpile;

                    requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.PLANKS.Name, 1));
                    requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.COPPERNAILS.Name, 1));

                    if (state.GetActionEnergy(MachineConstants.REPAIR) < .10f)
                    {
                        requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.IRONWROUGHT.Name, 1));
                        requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.COPPERPARTS.Name, 4));
                        requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.IRONRIVET.Name, 1));
                        requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.COPPERTOOLS.Name, 1));
                    }
                    else if (state.GetActionEnergy(MachineConstants.REPAIR) < .30f)
                    {
                        requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.IRONWROUGHT.Name, 1));
                        requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.COPPERPARTS.Name, 2));
                        requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.COPPERTOOLS.Name, 1));
                    }
                    else if (state.GetActionEnergy(MachineConstants.REPAIR) < .50f)
                    {
                        requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.COPPERPARTS.Name, 1));
                        requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.COPPERTOOLS.Name, 1));
                    }

                    if (stockpile.Contains(requiredForFix))
                    {
                        stockpile.TryRemove(requiredForFix);
                        repaired = true;
                    }
                    else
                    {
                        foreach (var item in requiredForFix)
                        {
                            if (!stockpile.Contains(item))
                            {
                                retval = ItemId.GetItemId(item.Type);
                                break;
                            }
                        }
                    }

                    if (repaired)
                    {
                        state.ResetActionToMaxLoad(MachineConstants.REPAIR);
                    }
                }
            }

            return(retval);
        }
示例#2
0
        public ItemId PreformAction(Colony colony, RoamingJobState state)
        {
            var retval = ItemId.GetItemId(GameLoader.NAMESPACE + ".Refuel");

            if (state.GetActionEnergy(GameLoader.NAMESPACE + ".ManaTankRefill") < .70f)
            {
                var requiredForFix = new List <InventoryItem>();
                var stockpile      = colony.Stockpile;
                var energy         = state.GetActionEnergy(GameLoader.NAMESPACE + ".ManaTankRefill");
                var maxMana        = RoamingJobState.GetActionsMaxEnergy(GameLoader.NAMESPACE + ".ManaTankRefill", colony, state.RoamingJobSettings.ObjectiveCategory);

                var manaCost = (int)System.Math.Round((maxMana - energy) / .02, 0);

                requiredForFix.Add(new InventoryItem(SettlersBuiltIn.ItemTypes.MANA.Id, manaCost));

                if (stockpile.TryRemove(requiredForFix))
                {
                    state.ResetActionToMaxLoad(GameLoader.NAMESPACE + ".ManaTankRefill");
                }
                else
                {
                    foreach (var item in requiredForFix)
                    {
                        if (!stockpile.Contains(item))
                        {
                            retval = ItemId.GetItemId(item.Type);
                            break;
                        }
                    }
                }
            }

            return(retval);
        }
示例#3
0
        public ItemId PreformAction(Colony colony, RoamingJobState state)
        {
            var retval = ItemId.GetItemId(Nach0Config.IndicatorTypePrefix + "Clean");

            if (colony.OwnerIsOnline())
            {
                if (state.GetActionEnergy(ToiletConstants.CLEAN) < .75f)
                {
                    var repaired          = false;
                    var requiredForClean  = new List <InventoryItem>();
                    var returnedFromClean = new List <InventoryItem>();
                    var stockpile         = colony.Stockpile;
                    int itemReqMult       = 1;


                    if (state.GetActionEnergy(ToiletConstants.CLEAN) < .50f)
                    {
                        itemReqMult++;
                    }
                    if (state.GetActionEnergy(ToiletConstants.CLEAN) < .30f)
                    {
                        itemReqMult++;
                    }
                    if (state.GetActionEnergy(ToiletConstants.CLEAN) < .10f)
                    {
                        itemReqMult++;
                    }

                    requiredForClean.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.BUCKETWATER.Name, 1 * itemReqMult));
                    returnedFromClean.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.BUCKETEMPTY.Name, 1 * itemReqMult));

                    if (stockpile.Contains(requiredForClean))
                    {
                        stockpile.TryRemove(requiredForClean);
                        repaired = true;
                        stockpile.Add(returnedFromClean);
                    }
                    else
                    {
                        foreach (var item in requiredForClean)
                        {
                            if (!stockpile.Contains(item))
                            {
                                retval = ItemId.GetItemId(item.Type);
                                break;
                            }
                        }
                    }

                    if (repaired)
                    {
                        state.ResetActionToMaxLoad(ToiletConstants.CLEAN);
                    }
                }
            }

            return(retval);
        }
示例#4
0
        public static ItemId Reload(Colony colony, RoamingJobState machineState)
        {
            if (colony.OwnerIsOnline())
            {
                machineState.ResetActionToMaxLoad(MachineConstants.RELOAD);
            }

            return(ItemId.GetItemId(GameLoader.NAMESPACE + ".Reload"));
        }
示例#5
0
        public static ItemId Repair(Colony colony, RoamingJobState machineState)
        {
            var retval = ItemId.GetItemId(GameLoader.NAMESPACE + ".Repairing");

            try
            {
                if (machineState.GetActionEnergy(MachineConstants.REPAIR) < .75f && TurretSettings.ContainsKey(machineState.RoamObjective))
                {
                    var repaired       = false;
                    var requiredForFix = new List <InventoryItem>();
                    var stockpile      = colony.Stockpile;

                    foreach (var durability in TurretSettings[machineState.RoamObjective]
                             .RequiredForFix.OrderByDescending(s => s.Key))
                    {
                        if (machineState.GetActionEnergy(MachineConstants.REPAIR) < durability.Key)
                        {
                            requiredForFix = durability.Value;
                            break;
                        }
                    }

                    if (stockpile.Contains(requiredForFix))
                    {
                        stockpile.TryRemove(requiredForFix);
                        repaired = true;
                    }
                    else
                    {
                        foreach (var item in requiredForFix)
                        {
                            if (!stockpile.Contains(item) && item.Type != 0)
                            {
                                retval = ItemId.GetItemId(item.Type);
                                break;
                            }
                        }
                    }

                    if (repaired)
                    {
                        machineState.ResetActionToMaxLoad(MachineConstants.REPAIR);
                    }
                }
            }
            catch (Exception ex)
            {
                SettlersLogger.LogError(ex);
            }

            return(retval);
        }
示例#6
0
        public static ItemId Repair(Colony colony, RoamingJobState machineState)
        {
            var retval = ItemId.GetItemId(GameLoader.NAMESPACE + ".Repairing");

            if (colony.OwnerIsOnline() && machineState.GetActionEnergy(MachineConstants.REPAIR) < .75f)
            {
                var repaired       = false;
                var requiredForFix = new List <InventoryItem>();

                requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.COPPERTOOLS.Name, 1));
                requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.COPPERPARTS.Name, 1));

                if (machineState.GetActionEnergy(MachineConstants.REPAIR) < .10f)
                {
                    requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.COPPERPARTS.Name, 4));
                    requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.PLANKS.Name, 1));
                }
                else if (machineState.GetActionEnergy(MachineConstants.REPAIR) < .30f)
                {
                    requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.COPPERPARTS.Name, 3));
                }
                else if (machineState.GetActionEnergy(MachineConstants.REPAIR) < .50f)
                {
                    requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.COPPERPARTS.Name, 2));
                }

                if (colony.Stockpile.Contains(requiredForFix))
                {
                    colony.Stockpile.TryRemove(requiredForFix);
                    repaired = true;
                }
                else
                {
                    foreach (var item in requiredForFix)
                    {
                        if (!colony.Stockpile.Contains(item))
                        {
                            retval = ItemId.GetItemId(item.Type);
                            break;
                        }
                    }
                }

                if (repaired)
                {
                    machineState.ResetActionToMaxLoad(MachineConstants.REPAIR);
                }
            }


            return(retval);
        }
示例#7
0
        public ItemId PreformAction(Colony player, RoamingJobState state)
        {
            var items = state.TempValues.GetOrDefault <List <InventoryItem> >("MinedItems", new List <InventoryItem>());

            foreach (var item in items)
            {
                player.Stockpile.Add(item);
            }

            items.Clear();
            state.ResetActionToMaxLoad(MachineConstants.INVENTORY);
            state.TempValues.Set("MinedItems", items);

            return(ItemId.GetItemId(GameLoader.NAMESPACE + ".Inventory"));
        }
        public ItemId PreformAction(Colony colony, RoamingJobState state)
        {
            var retval = ItemId.GetItemId(GameLoader.NAMESPACE + ".Repairing");

            if (state.GetActionEnergy(GameLoader.NAMESPACE + ".ManaMachineRepair") < .50f)
            {
                var repaired       = false;
                var requiredForFix = new List <InventoryItem>();
                var stockpile      = colony.Stockpile;

                requiredForFix.Add(new InventoryItem(SettlersBuiltIn.ItemTypes.ADAMANTINE.Id));
                requiredForFix.Add(new InventoryItem(SettlersBuiltIn.ItemTypes.MAGICWAND.Id));
                requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.COATEDPLANKS.Id));
                requiredForFix.Add(new InventoryItem(SettlersBuiltIn.ItemTypes.REFINEDEMERALD.Id));
                requiredForFix.Add(new InventoryItem(SettlersBuiltIn.ItemTypes.REFINEDSAPPHIRE.Id));
                requiredForFix.Add(new InventoryItem(SettlersBuiltIn.ItemTypes.REFINEDRUBY.Id));

                if (stockpile.Contains(requiredForFix))
                {
                    stockpile.TryRemove(requiredForFix);
                    repaired = true;
                }
                else
                {
                    foreach (var item in requiredForFix)
                    {
                        if (!stockpile.Contains(item))
                        {
                            retval = ItemId.GetItemId(item.Type);
                            break;
                        }
                    }
                }

                if (repaired)
                {
                    state.ResetActionToMaxLoad(GameLoader.NAMESPACE + ".ManaMachineRepair");
                }
            }

            return(retval);
        }
        public static ItemId Repair(Colony colony, RoamingJobState machineState)
        {
            var retval = ItemId.GetItemId(GameLoader.NAMESPACE + ".Repairing");

            if (machineState.GetActionEnergy(MachineConstants.REPAIR) < .75f)
            {
                var repaired       = false;
                var requiredForFix = new List <InventoryItem>();
                var stockpile      = colony.Stockpile;

                requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.STONEBRICKS.Name, 5));
                requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.SCIENCEBAGBASIC.Name, 2));

                if (machineState.GetActionEnergy(MachineConstants.REPAIR) < .10f)
                {
                    requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.SCIENCEBAGBASIC.Name, 2));
                    requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.IRONRIVET.Name, 2));
                    requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.CRYSTAL.Name, 2));
                }
                else if (machineState.GetActionEnergy(MachineConstants.REPAIR) < .30f)
                {
                    requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.SCIENCEBAGBASIC.Name, 1));
                    requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.IRONRIVET.Name, 2));
                    requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.CRYSTAL.Name, 2));
                }
                else if (machineState.GetActionEnergy(MachineConstants.REPAIR) < .50f)
                {
                    requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.SCIENCEBAGBASIC.Name, 1));
                    requiredForFix.Add(new InventoryItem(ColonyBuiltIn.ItemTypes.CRYSTAL.Name, 1));
                }

                if (stockpile.Contains(requiredForFix))
                {
                    stockpile.TryRemove(requiredForFix);
                    repaired = true;
                }
                else
                {
                    foreach (var item in requiredForFix)
                    {
                        if (!stockpile.Contains(item))
                        {
                            retval = ItemId.GetItemId(item.Type);
                            break;
                        }
                    }
                }

                if (repaired)
                {
                    machineState.ResetActionToMaxLoad(MachineConstants.REPAIR);

                    if (_paired.ContainsKey(machineState.Position) &&
                        GetPadAt(_paired[machineState.Position], out var ms))
                    {
                        ms.ResetActionToMaxLoad(MachineConstants.REPAIR);
                    }
                }
            }

            return(retval);
        }