Exemplo n.º 1
0
 private bool Prompted(IJunimoAbility ability)
 {
     if (ability.AbilityName() == "ClearDeadCrops")
     {
         return(ProgData.ClearDeadCropsPrompted);
     }
     if (ability.AbilityName() == "Fertilize")
     {
         return(ProgData.FertilizePrompted);
     }
     if (ability.AbilityName() == "HarvestBushes")
     {
         return(ProgData.HarvestBushesPrompted);
     }
     if (ability.AbilityName() == "HarvestForageCrops")
     {
         return(ProgData.HarvestForageCropsPrompted);
     }
     if (ability.AbilityName() == "PlantCrops")
     {
         return(ProgData.PlantCropsPrompted);
     }
     if (ability.AbilityName() == "Water")
     {
         return(ProgData.WaterPrompted);
     }
     if (ability.AbilityName() == "HarvestCrops")
     {
         return(true);
     }
     Monitor.Log($"Prompted: progression checked for {ability.AbilityName()} but not implemented", LogLevel.Debug);
     return(true);
 }
Exemplo n.º 2
0
        // search for crops + open plantable spots
        internal static bool searchAroundHut(JunimoHut hut)
        {
            Guid id     = Util.GetHutIdFromHut(hut);
            int  radius = Util.MaxRadius;

            for (int x = hut.tileX.Value + 1 - radius; x < hut.tileX.Value + 2 + radius; ++x)
            {
                for (int y = hut.tileY.Value + 1 - radius; y < hut.tileY.Value + 2 + radius; ++y)
                {
                    // skip if we find the same lastKnownCropLocation twice
                    if (x == hut.lastKnownCropLocation.X && y == hut.lastKnownCropLocation.Y)
                    {
                        continue;
                    }
                    Vector2        pos     = new Vector2((float)x, (float)y);
                    IJunimoAbility ability = Util.Abilities.IdentifyJunimoAbility(pos, id);
                    if (ability != null)
                    {
                        hut.lastKnownCropLocation = new Point(x, y);
                        return(true);
                    }
                }
            }
            hut.lastKnownCropLocation = Point.Zero;
            return(false);
        }
Exemplo n.º 3
0
 public bool CanUseAbility(IJunimoAbility ability)
 {
     if (!Config.Progression.Enabled)
     {
         return(true);
     }
     PromptForAbility(ability);
     return(Unlocked(ability));
 }
Exemplo n.º 4
0
        /*
         * Add an IJunimoAbility to the list of possible actions if allowed
         */
        public void RegisterJunimoAbility(IJunimoAbility junimoAbility)
        {
            string name = junimoAbility.AbilityName();

            if (!EnabledAbilities.ContainsKey(name))
            {
                EnabledAbilities.Add(name, true);
            }
            if (EnabledAbilities[name])
            {
                JunimoCapabilities.Add(junimoAbility);
            }
        }
Exemplo n.º 5
0
        public bool PerformAction(IJunimoAbility ability, Guid id, Vector2 pos, JunimoHarvester junimo)
        {
            JunimoHut hut   = Util.GetHutFromId(id);
            Chest     chest = hut.output.Value;
            Farm      farm  = Game1.getFarm();

            bool success      = ability.PerformAction(farm, pos, junimo, chest);
            int  requiredItem = ability.RequiredItem();

            if (requiredItem != 0)
            {
                UpdateHutContainsItemCategory(id, chest, requiredItem);
            }

            return(success);
        }
Exemplo n.º 6
0
        public void PromptForAbility(IJunimoAbility ability)
        {
            if (Unlocked(ability) || Prompted(ability))
            {
                return;
            }
            string an = ability.AbilityName();

            switch (an)
            {
            case "ClearDeadCrops":
                Util.SendMessage(GetPromptText(an, Config.Progression.ClearDeadCrops.Item, Config.Progression.ClearDeadCrops.Stack));
                ProgData.ClearDeadCropsPrompted = true;
                break;

            case "Fertilize":
                Util.SendMessage(GetPromptText(an, Config.Progression.Fertilize.Item, Config.Progression.Fertilize.Stack));
                ProgData.FertilizePrompted = true;
                break;

            case "HarvestBushes":
                Util.SendMessage(GetPromptText(an, Config.Progression.HarvestBushes.Item, Config.Progression.HarvestBushes.Stack));
                ProgData.HarvestBushesPrompted = true;
                break;

            case "HarvestForageCrops":
                Util.SendMessage(GetPromptText(an, Config.Progression.HarvestForageCrops.Item, Config.Progression.HarvestForageCrops.Stack));
                ProgData.HarvestForageCropsPrompted = true;
                break;

            case "PlantCrops":
                Util.SendMessage(GetPromptText(an, Config.Progression.PlantCrops.Item, Config.Progression.PlantCrops.Stack));
                ProgData.PlantCropsPrompted = true;
                break;

            case "Water":
                Util.SendMessage(GetPromptText(an, Config.Progression.Water.Item, Config.Progression.Water.Stack));
                ProgData.WaterPrompted = true;
                break;

            default:
                Monitor.Log($"PromptForAbility: progression prompt check needed for {an} but not implemented", LogLevel.Debug);
                break;
            }
        }
Exemplo n.º 7
0
        public bool CanUseAbility(IJunimoAbility ability)
        {
            if (!BetterJunimos.Config.Progression.Enabled)
            {
                return(true);
            }

            var an = ability.AbilityName();

            if (Unlocked(an))
            {
                return(true);
            }
            if (Prompted(an))
            {
                return(false);
            }

            // _monitor.Log($"CanUseAbility: prompting for {an} due CanUseAbility request", LogLevel.Debug);
            DisplayPromptFor(an);
            return(false);
        }
        public static bool Prefix(JunimoHarvester __instance, ref int ___harvestTimer, ref NetGuid ___netHome)
        {
            Guid    id  = ___netHome.Value;
            Vector2 pos = __instance.getTileLocation();

            int            time;
            IJunimoAbility junimoAbility = Util.Abilities.IdentifyJunimoAbility(pos, id);

            if (junimoAbility != null)
            {
                // Use the update() harvesting
                if (junimoAbility is HarvestCropsAbility || junimoAbility is HarvestBushesAbility)
                {
                    time = 2000;
                }
                else if (!Util.Abilities.PerformAction(junimoAbility, id, pos, __instance))
                {
                    // didn't succeed, move on
                    time = 0;
                }
                else
                {
                    // succeeded, shake
                    time = Util.Progression.WorkFaster ? 300 : 998;
                }
            }
            else
            {
                // nothing to do, wait a moment
                time = Util.Progression.WorkFaster ? 5 : 200;
                __instance.pokeToHarvest();
            }
            ___harvestTimer = time;

            return(false);
        }
Exemplo n.º 9
0
 public void RegisterJunimoAbility(IJunimoAbility junimoAbility)
 {
     Util.Abilities.RegisterJunimoAbility(junimoAbility);
 }