Пример #1
0
        /// <summary>
        /// Void that will do the scanning for Artifacts.
        /// </summary>
        public void DoScan()
        {
            GameLocation currentLocation = Game1.currentLocation;

            Game1.player.MagneticRadius = _radius * _magneticRadius;
            if (_isDebugging)
            {
                Monitor.Log($"Cur Radius: {Game1.player.MagneticRadius}, Old Radius: {_magneticRadius}");
            }
            int sec = 0;

            foreach (var i in _location)
            {
                currentLocation.Objects.TryGetValue(i, out SObject @object);

                Hoe h = new Hoe();
                if (_isDebugging)
                {
                    Monitor.Log($"Found something {@object.DisplayName} {@object.TileLocation.X}, {@object.TileLocation.Y}");
                }
                h.DoFunction(currentLocation, Convert.ToInt32(i.X * 64f), Convert.ToInt32(i.Y * 64f), 0, Game1.player);
            }

            //Wait 5 Seconds and reset Magnetic Radius
            for (int num = 0; num < 0; num++)
            {
                sec++;
            }
            if (sec == 5)
            {
                Game1.player.MagneticRadius = _magneticRadius;
            }
        }
        public static void CollectNearbyCollectibles(GameLocation location)
        {
            int reach = Config.BalancedMode ? 1 : Config.AutoCollectRadius;

            foreach (SVObject obj in Util.GetObjectsWithin <SVObject>(reach))
            {
                if (obj.IsSpawnedObject || obj.isAnimalProduct())
                {
                    CollectObj(location, obj);
                }
            }

            Hoe hoe = Util.FindToolFromInventory <Hoe>(true);

            if (hoe == null)
            {
                return;
            }
            foreach (KeyValuePair <Vector2, HoeDirt> kv in Util.GetFeaturesWithin <HoeDirt>(reach))
            {
                if (IsGinger(kv.Value.crop))
                {
                    CollectGinger(location, kv.Key, kv.Value);
                }
            }
        }
Пример #3
0
 public static void Postfix(Hoe __instance, GameLocation location, Farmer who)
 {
     if (who.HasNecklace(Necklace.Type.Water))
     {
         location.terrainFeatures.OnValueAdded -= OnFeatureAdded;
     }
 }
Пример #4
0
        public static void Postfix(StardewValley.Farmer who, Dictionary <Item, int[]> __result)
        {
            Tool tool = who.getToolFromName("Axe");

            if (tool != null && tool.UpgradeLevel == 4)
            {
                var newTool = new Axe();
                newTool.UpgradeLevel = 5;
                __result.Add(newTool, new int[] { 100000, 1, CobaltBarItem.INDEX });
            }

            tool = who.getToolFromName("Watering Can");
            if (tool != null && tool.UpgradeLevel == 4)
            {
                var newTool = new WateringCan();
                newTool.UpgradeLevel = 5;
                __result.Add(newTool, new int[] { 100000, 1, CobaltBarItem.INDEX });
            }

            tool = who.getToolFromName("Pickaxe");
            if (tool != null && tool.UpgradeLevel == 4)
            {
                var newTool = new Pickaxe();
                newTool.UpgradeLevel = 5;
                __result.Add(newTool, new int[] { 100000, 1, CobaltBarItem.INDEX });
            }

            tool = who.getToolFromName("Hoe");
            if (tool != null && tool.UpgradeLevel == 4)
            {
                var newTool = new Hoe();
                newTool.UpgradeLevel = 5;
                __result.Add(newTool, new int[] { 100000, 1, CobaltBarItem.INDEX });
            }
        }
Пример #5
0
    // Use this for initialization
    void Start()
    {
        playerStamina = GetComponent <PlayerStamina> ();

        camera = Camera.main;
        tool   = Tools.NONE;

        hoe               = GetComponent <Hoe> ();
        plant             = GetComponent <PlantSeeds> ();
        wateringCan       = GetComponent <WateringCan> ();
        sickle            = GetComponent <Sickle> ();
        none              = GetComponent <None> ();
        holdingItem       = GetComponent <HoldingItem> ();
        inventory         = GetComponent <InventoryManager> ();
        fountainCollision = GetComponent <FountainCollider> ();
        NPCCollision      = GetComponentInChildren <NPCCollision> ();
        if (SceneManager.GetActiveScene().name.Contains("Outside") || SceneManager.GetActiveScene().name == "Farming" || SceneManager.GetActiveScene().name == "Farm")
        {
            outside = true;
        }
        else
        {
            outside = false;
        }

        anim          = GetComponent <Animator> ();
        hoeGO         = this.transform.Find("hoe").gameObject;
        wcanGO        = this.transform.Find("wateringcan").gameObject;
        sickleGO      = this.transform.Find("sickle").gameObject;
        buttonToPress = FindObjectOfType(typeof(ButtonToPress)) as ButtonToPress;
    }
Пример #6
0
        internal static void Hoe_DoFunction_Postfix(ref Hoe __instance, int x, int y, int power, Farmer who)
        {
            if (!Game1.player.eventsSeen.Contains(UNSEALEVENT))
            {
                return;
            }

            try
            {
                int tileX = x / 64;
                int tileY = y / 64;
                if (tileX == 80 && tileY == 22 && Game1.currentLocation.Name.Equals("Custom_Ridgeside_RSVCliff") && !Game1.player.mailReceived.Contains(FLAGMOOSE))
                {
                    SpawnJAItemAsDebris("Moose Statue", tileX, tileY, Game1.currentLocation);
                    Game1.player.mailReceived.Add(FLAGMOOSE);
                }
                else if (tileX == 63 && tileY == 40 && Game1.currentLocation.Name.Equals("Custom_Ridgeside_RSVTheHike") && !Game1.player.mailReceived.Contains(FLAGCOMB))
                {
                    SpawnJAItemAsDebris("Elven Comb", tileX, tileY, Game1.currentLocation);
                    Game1.player.mailReceived.Add(FLAGCOMB);
                }
                else if (tileX == 23 && tileY == 6 && Game1.currentLocation.Name.Equals("Custom_Ridgeside_RSVCableCar") && !Game1.player.mailReceived.Contains(FLAGOPAL))
                {
                    SpawnJAItemAsDebris("Opal Halo", tileX, tileY, Game1.currentLocation);
                    Game1.player.mailReceived.Add(FLAGOPAL);
                }
            }
            catch (Exception e)
            {
                Log.Error($"Harmony patch \"{nameof(Hoe_DoFunction_Postfix)}\" has encountered an error. \n{e.ToString()}");
            }
        }
Пример #7
0
 public static void Prefix(Hoe __instance, GameLocation location, ref int x, ref int y, int power, Farmer who)
 {
     if (who.HasAdornment(ToolType.Axe, Mod.Config.GEODE_REMOTE_USE) > 0)
     {
         x = (int)who.lastClick.X;
         y = (int)who.lastClick.Y;
     }
 }
Пример #8
0
 /*********
 ** Private methods
 *********/
 /// <summary>The method to call before <see cref="Pickaxe.DoFunction"/>.</summary>
 private static void Before_DoFunction(Hoe __instance, GameLocation location, ref int x, ref int y, int power, Farmer who)
 {
     if (Mod.Instance.HasRingEquipped(Mod.Instance.RingMageHand) > 0)
     {
         x = (int)who.lastClick.X;
         y = (int)who.lastClick.Y;
     }
 }
Пример #9
0
 public static void Prefix(Hoe __instance, GameLocation location, ref int x, ref int y, int power, Farmer who)
 {
     if (Mod.instance.hasRingEquipped(Mod.instance.Ring_MageHand) > 0)
     {
         x = ( int )who.lastClick.X;
         y = ( int )who.lastClick.Y;
     }
 }
Пример #10
0
 public Multitool(MultitoolMod m)
 {
     this.mod                     = m;
     this.attachedTools           = new Dictionary <string, Tool>();
     this.axe                     = new Axe();
     this.pickaxe                 = new Pickaxe();
     this.scythe                  = new MeleeWeapon(47);
     this.scythe                  = (MeleeWeapon)this.scythe.getOne();
     this.scythe.Category         = -99;
     this.wateringCan             = new WateringCan();
     this.hoe                     = new Hoe();
     attachedTools["axe"]         = this.axe;
     attachedTools["pickaxe"]     = this.pickaxe;
     attachedTools["melee"]       = this.scythe;
     attachedTools["wateringcan"] = this.wateringCan;
     attachedTools["hoe"]         = this.hoe;
 }
Пример #11
0
        public static void DigNearbyArtifactSpots()
        {
            Farmer       player   = Game1.player;
            int          radius   = Config.AutoDigRadius;
            Hoe          hoe      = Util.FindToolFromInventory <Hoe>(player, InstanceHolder.Config.FindHoeFromInventory);
            GameLocation location = player.currentLocation;

            if (hoe == null)
            {
                return;
            }

            bool flag = false;

            for (int i = -radius; i <= radius; i++)
            {
                for (int j = -radius; j <= radius; j++)
                {
                    int     x   = player.getTileX() + i;
                    int     y   = player.getTileY() + j;
                    Vector2 loc = new Vector2(x, y);
                    if (!location.Objects.ContainsKey(loc) || location.Objects[loc].ParentSheetIndex != 590 ||
                        location.isTileHoeDirt(loc))
                    {
                        continue;
                    }
                    location.digUpArtifactSpot(x, y, player);
                    location.Objects.Remove(loc);
                    location.terrainFeatures.Add(loc, new HoeDirt());
                    flag = true;
                }
            }

            if (flag)
            {
                Game1.playSound("hoeHit");
            }
        }
Пример #12
0
        /*
         * Private Methods
         */
        //Events

        private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
        {
            //Make sure that the activate key is valid
            if (!Enum.TryParse(_toolConfig.KeyBindClear, true, out _actKey))
            {
                _actKey = SButton.Z;
                Monitor.Log("Keybind was invalid. setting it to Z");
            }
            //Make sure the crop key is valid
            if (!Enum.TryParse(_toolConfig.KeyBindCrop, true, out _cropKey))
            {
                _cropKey = SButton.X;
                Monitor.Log("Keybind was invalid. setting it to X");
            }

            //Set up Phantom Tools
            _hoeDirtTool = "PickAxe";
            _ghostScythe = new CustomScythe(47)
            {
                UpgradeLevel = _toolConfig.ToolLevel
            };
            _ghostAxe = new Axe {
                UpgradeLevel = LevelCheck(_toolConfig.ToolLevel)
            };
            _ghostPickaxe = new Pickaxe {
                UpgradeLevel = LevelCheck(_toolConfig.ToolLevel)
            };
            _ghostHoe = new Hoe {
                UpgradeLevel = LevelCheck(_toolConfig.ToolLevel)
            };
            _ghostWaterCan = new WateringCan {
                UpgradeLevel = LevelCheck(_toolConfig.ToolLevel)
            };
            _ghostPan = new Pan();
            _usePailonOtherAnimals = _toolConfig.UsePailonOtherAnimals;
            _ghostShearPail        = new CustomShearPail(_usePailonOtherAnimals);
        }
Пример #13
0
        public static Tool getToolFromDescription(byte index, int upgradeLevel)
        {
            Tool t = null;

            switch (index)
            {
            case 0:
                t = new Axe();
                break;

            case 1:
                t = new Hoe();
                break;

            case 2:
                t = new FishingRod();
                break;

            case 3:
                t = new Pickaxe();
                break;

            case 4:
                t = new WateringCan();
                break;

            case 5:
                t = new MeleeWeapon(0, upgradeLevel);
                break;

            case 6:
                t = new Slingshot();
                break;
            }
            t.UpgradeLevel = upgradeLevel;
            return(t);
        }
Пример #14
0
        public static void LoadContentPacks(object sender, EventArgs e)
        {
            foreach (IContentPack contentPack in MailFrameworkModEntry.ModHelper.ContentPacks.GetOwned())
            {
                if (File.Exists(Path.Combine(contentPack.DirectoryPath, "mail.json")))
                {
                    bool hasTranslation = contentPack.Translation.GetTranslations().Any();

                    MailFrameworkModEntry.ModMonitor.Log($"Reading content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version} from {contentPack.DirectoryPath}");
                    List <MailItem> mailItems = contentPack.ReadJsonFile <List <MailItem> >("mail.json");
                    foreach (MailItem mailItem in mailItems)
                    {
                        Dictionary <int, string> objects    = null;
                        Dictionary <int, string> bigObjects = null;
                        Dictionary <int, string> furnitures = null;
                        Dictionary <int, string> weapons    = null;
                        Dictionary <int, string> boots      = null;

                        //Populate all Indexes based on the given name. Ignore the letter otherwise.
                        if (mailItem.CollectionConditions != null && mailItem.CollectionConditions.Any(c =>
                        {
                            if (c.Name != null && c.Collection != Collection.Crafting)
                            {
                                objects ??= MailFrameworkModEntry.ModHelper.Content.Load <Dictionary <int, string> >(PathUtilities.NormalizeAssetName("Data/ObjectInformation"), ContentSource.GameContent);
                                KeyValuePair <int, string> pair = objects.FirstOrDefault(o => o.Value.StartsWith(c.Name + "/"));
                                if (pair.Value != null)
                                {
                                    c.Index = pair.Key;
                                }
                                else
                                {
                                    MailFrameworkModEntry.ModMonitor.Log($"No object found with the name '{c.Name}' for a condition for letter '{mailItem.Id}'.\n This letter will be ignored.", LogLevel.Warn);
                                    MailDao.RemoveLetter(new Letter(mailItem.Id, null, null));
                                    return(true);
                                }
                            }
                            return(false);
                        }))
                        {
                            continue;
                        }

                        bool Condition(Letter l) =>
                        (!Game1.player.mailReceived.Contains(l.Id) || mailItem.Repeatable) &&
                        (mailItem.Recipe == null || !Game1.player.cookingRecipes.ContainsKey(mailItem.Recipe)) &&
                        (mailItem.Date == null || SDate.Now() >= new SDate(Convert.ToInt32(mailItem.Date.Split(' ')[0]), mailItem.Date.Split(' ')[1], Convert.ToInt32(mailItem.Date.Split(' ')[2].Replace("Y", "")))) &&
                        (mailItem.Days == null || mailItem.Days.Contains(SDate.Now().Day)) &&
                        (mailItem.Seasons == null || mailItem.Seasons.Contains(SDate.Now().Season)) &&
                        (mailItem.Weather == null || (Game1.isRaining && "rainy".Equals(mailItem.Weather)) || (!Game1.isRaining && "sunny".Equals(mailItem.Weather))) &&
                        (mailItem.FriendshipConditions == null || (mailItem.FriendshipConditions.TrueForAll(f => Game1.player.getFriendshipHeartLevelForNPC(f.NpcName) >= f.FriendshipLevel)) &&
                         mailItem.FriendshipConditions.TrueForAll(f => f.FriendshipStatus == null || (Game1.player.friendshipData.ContainsKey(f.NpcName) && f.FriendshipStatus.Any(s => s == Game1.player.friendshipData[f.NpcName].Status)))) &&
                        (mailItem.SkillConditions == null || mailItem.SkillConditions.TrueForAll(s => Game1.player.getEffectiveSkillLevel((int)s.SkillName) >= s.SkillLevel)) &&
                        (mailItem.StatsConditions == null || (mailItem.StatsConditions.TrueForAll(s => s.StatsLabel == null || Game1.player.stats.getStat(s.StatsLabel) >= s.Amount) && mailItem.StatsConditions.TrueForAll(s => s.StatsName == null || MailFrameworkModEntry.ModHelper.Reflection.GetProperty <uint>(Game1.player.stats, s.StatsName.ToString()).GetValue() >= s.Amount))) &&
                        (mailItem.CollectionConditions == null || (mailItem.CollectionConditions.TrueForAll(c =>
                                                                                                            (c.Collection == Collection.Shipped && Game1.player.basicShipped.ContainsKey(c.Index) && Game1.player.basicShipped[c.Index] >= c.Amount) ||
                                                                                                            (c.Collection == Collection.Fish && Game1.player.fishCaught.ContainsKey(c.Index) && Game1.player.fishCaught[c.Index][0] >= c.Amount) ||
                                                                                                            (c.Collection == Collection.Artifacts && Game1.player.archaeologyFound.ContainsKey(c.Index) && Game1.player.archaeologyFound[c.Index][0] >= c.Amount) ||
                                                                                                            (c.Collection == Collection.Minerals && Game1.player.mineralsFound.ContainsKey(c.Index) && Game1.player.mineralsFound[c.Index] >= c.Amount) ||
                                                                                                            (c.Collection == Collection.Cooking && Game1.player.recipesCooked.ContainsKey(c.Index) && Game1.player.recipesCooked[c.Index] >= c.Amount) ||
                                                                                                            (c.Collection == Collection.Crafting && Game1.player.craftingRecipes.ContainsKey(c.Name) && Game1.player.craftingRecipes[c.Name] >= c.Amount)
                                                                                                            ))) &&
                        (mailItem.RandomChance == null || new Random((int)(((ulong)Game1.stats.DaysPlayed * 1000000000000000) + (((ulong)l.Id.GetHashCode()) % 1000000000 * 1000000) + Game1.uniqueIDForThisGame % 1000000)).NextDouble() < mailItem.RandomChance) &&
                        (mailItem.Buildings == null || (mailItem.RequireAllBuildings ? mailItem.Buildings.TrueForAll(b => Game1.getFarm().isBuildingConstructed(b)) : mailItem.Buildings.Any(b => Game1.getFarm().isBuildingConstructed(b)))) &&
                        (mailItem.MailReceived == null || (mailItem.RequireAllMailReceived ? !mailItem.MailReceived.Except(Game1.player.mailReceived).Any() : mailItem.MailReceived.Intersect(Game1.player.mailReceived).Any())) &&
                        (mailItem.MailNotReceived == null || !mailItem.MailNotReceived.Intersect(Game1.player.mailReceived).Any()) &&
                        (mailItem.EventsSeen == null || (mailItem.RequireAllEventsSeen ? !mailItem.EventsSeen.Except(Game1.player.eventsSeen).Any() : mailItem.EventsSeen.Intersect(Game1.player.eventsSeen).Any())) &&
                        (mailItem.EventsNotSeen == null || !mailItem.EventsNotSeen.Intersect(Game1.player.eventsSeen).Any()) &&
                        (mailItem.RecipeKnown == null || (mailItem.RequireAllRecipeKnown ? mailItem.RecipeKnown.All(r => Game1.player.knowsRecipe(r)) : mailItem.RecipeKnown.Any(r => Game1.player.knowsRecipe(r)))) &&
                        (mailItem.RecipeNotKnown == null || mailItem.RecipeNotKnown.All(r => !Game1.player.knowsRecipe(r))) &&
                        (mailItem.ExpandedPrecondition == null || (ConditionsCheckerApi != null && ConditionsCheckerApi.CheckConditions(mailItem.ExpandedPrecondition))) &&
                        (mailItem.ExpandedPreconditions == null || (ConditionsCheckerApi != null && ConditionsCheckerApi.CheckConditions(mailItem.ExpandedPreconditions))) &&
                        (mailItem.HouseUpgradeLevel == null || mailItem.HouseUpgradeLevel <= Game1.player.HouseUpgradeLevel)
                        ;

                        if (mailItem.Attachments != null && mailItem.Attachments.Count > 0)
                        {
                            List <Item> attachments = new List <Item>();
                            mailItem.Attachments.ForEach(i =>
                            {
                                if (i == null)
                                {
                                    return;
                                }
                                switch (i.Type)
                                {
                                case ItemType.Object:
                                    if (i.Name != null)
                                    {
                                        objects ??= MailFrameworkModEntry.ModHelper.Content.Load <Dictionary <int, string> >(PathUtilities.NormalizeAssetName("Data/ObjectInformation"), ContentSource.GameContent);
                                        KeyValuePair <int, string> pair = objects.FirstOrDefault(o => o.Value.StartsWith(i.Name + "/"));
                                        if (pair.Value != null)
                                        {
                                            i.Index = pair.Key;
                                        }
                                        else
                                        {
                                            MailFrameworkModEntry.ModMonitor.Log($"No object found with the name {i.Name} for letter {mailItem.Id}.", LogLevel.Warn);
                                        }
                                    }

                                    if (i.Index.HasValue)
                                    {
                                        attachments.Add(new StardewValley.Object(Vector2.Zero, i.Index.Value, i.Stack ?? 1));
                                    }
                                    else
                                    {
                                        MailFrameworkModEntry.ModMonitor.Log($"An index value is required to attach an object for letter {mailItem.Id}.", LogLevel.Warn);
                                    }
                                    break;

                                case ItemType.BigObject:
                                case ItemType.BigCraftable:
                                    if (i.Name != null)
                                    {
                                        bigObjects ??= MailFrameworkModEntry.ModHelper.Content.Load <Dictionary <int, string> >(PathUtilities.NormalizeAssetName("Data/BigCraftablesInformation"), ContentSource.GameContent);
                                        KeyValuePair <int, string> pair = bigObjects.FirstOrDefault(o => o.Value.StartsWith(i.Name + "/"));
                                        if (pair.Value != null)
                                        {
                                            i.Index = pair.Key;
                                        }
                                        else
                                        {
                                            MailFrameworkModEntry.ModMonitor.Log($"No big craftable found with the name {i.Name} for letter {mailItem.Id}.", LogLevel.Warn);
                                        }
                                    }

                                    if (i.Index.HasValue)
                                    {
                                        Item item = new StardewValley.Object(Vector2.Zero, i.Index.Value);
                                        if (i.Stack.HasValue)
                                        {
                                            item.Stack = i.Stack.Value;
                                        }
                                        attachments.Add(item);
                                    }
                                    else
                                    {
                                        MailFrameworkModEntry.ModMonitor.Log($"An index value is required to attach a big craftable for letter {mailItem.Id}.", LogLevel.Warn);
                                    }
                                    break;

                                case ItemType.Tool:
                                    Tool tool = null;
                                    switch (i.Name)
                                    {
                                    case "Axe":
                                        tool = new Axe();
                                        break;

                                    case "Hoe":
                                        tool = new Hoe();
                                        break;

                                    case "Watering Can":
                                        tool = new WateringCan();
                                        break;

                                    case "Scythe":
                                        tool = new MeleeWeapon(47);
                                        break;

                                    case "Golden Scythe":
                                        tool = new MeleeWeapon(53);
                                        break;

                                    case "Pickaxe":
                                        tool = new Pickaxe();
                                        break;

                                    case "Milk Pail":
                                        tool = new MilkPail();
                                        break;

                                    case "Shears":
                                        tool = new Shears();
                                        break;

                                    case "Fishing Rod":
                                        tool = new FishingRod(i.UpgradeLevel);
                                        break;

                                    case "Pan":
                                        tool = new Pan();
                                        break;

                                    case "Return Scepter":
                                        tool = new Wand();
                                        break;

                                    default:
                                        MailFrameworkModEntry.ModMonitor.Log($"Tool with name {i.Name} not found for letter {mailItem.Id}.", LogLevel.Warn);
                                        break;
                                    }
                                    if (tool != null)
                                    {
                                        if (!NoUpgradeLevelTools.Contains(i.Name))
                                        {
                                            tool.UpgradeLevel = i.UpgradeLevel;
                                        }
                                        attachments.Add(tool);
                                    }
                                    break;

                                case ItemType.Ring:
                                    objects ??= MailFrameworkModEntry.ModHelper.Content.Load <Dictionary <int, string> >("Data\\ObjectInformation", ContentSource.GameContent);
                                    if (i.Name != null)
                                    {
                                        KeyValuePair <int, string> pair = objects.FirstOrDefault(o => o.Value.StartsWith(i.Name + "/"));
                                        if (pair.Value != null)
                                        {
                                            i.Index = pair.Key;
                                        }
                                        else
                                        {
                                            MailFrameworkModEntry.ModMonitor.Log($"No ring found with the name {i.Name} for letter {mailItem.Id}.", LogLevel.Warn);
                                        }
                                    }
                                    if (i.Index.HasValue)
                                    {
                                        if (objects[i.Index.Value].Split('/')[3] == "Ring")
                                        {
                                            attachments.Add(new Ring(i.Index.Value));
                                        }
                                        else
                                        {
                                            MailFrameworkModEntry.ModMonitor.Log($"A valid ring is required to attach an ring for letter {mailItem.Id}.", LogLevel.Warn);
                                        }
                                    }
                                    else
                                    {
                                        MailFrameworkModEntry.ModMonitor.Log($"An index value is required to attach an ring for letter {mailItem.Id}.", LogLevel.Warn);
                                    }
                                    break;

                                case ItemType.Furniture:
                                    if (i.Name != null)
                                    {
                                        furnitures ??= MailFrameworkModEntry.ModHelper.Content.Load <Dictionary <int, string> >(PathUtilities.NormalizeAssetName("Data/Furniture"), ContentSource.GameContent);
                                        KeyValuePair <int, string> pair = furnitures.FirstOrDefault(o => o.Value.StartsWith(i.Name + "/"));
                                        if (pair.Value != null)
                                        {
                                            i.Index = pair.Key;
                                        }
                                        else
                                        {
                                            MailFrameworkModEntry.ModMonitor.Log($"No furniture found with the name {i.Name} for letter {mailItem.Id}.", LogLevel.Warn);
                                        }
                                    }

                                    if (i.Index.HasValue)
                                    {
                                        attachments.Add(Furniture.GetFurnitureInstance(i.Index.Value));
                                    }
                                    else
                                    {
                                        MailFrameworkModEntry.ModMonitor.Log($"An index value is required to attach a furniture for letter {mailItem.Id}.", LogLevel.Warn);
                                    }
                                    break;

                                case ItemType.Weapon:
                                    if (i.Name != null)
                                    {
                                        weapons ??= MailFrameworkModEntry.ModHelper.Content.Load <Dictionary <int, string> >(PathUtilities.NormalizeAssetName("Data/Weapons"), ContentSource.GameContent);
                                        KeyValuePair <int, string> pair = weapons.FirstOrDefault(o => o.Value.StartsWith(i.Name + "/"));
                                        if (pair.Value != null)
                                        {
                                            i.Index = pair.Key;
                                        }
                                        else
                                        {
                                            MailFrameworkModEntry.ModMonitor.Log($"No weapon found with the name {i.Name} for letter {mailItem.Id}.", LogLevel.Warn);
                                        }
                                    }

                                    if (i.Index.HasValue)
                                    {
                                        int index = i.Index.Value;
                                        attachments.Add(SlingshotIndexes.Contains(index) ? (Item) new Slingshot(index) : (Item) new MeleeWeapon(index));
                                    }
                                    else
                                    {
                                        MailFrameworkModEntry.ModMonitor.Log($"An index value is required to attach a weapon for letter {mailItem.Id}.", LogLevel.Warn);
                                    }
                                    break;

                                case ItemType.Boots:
                                    if (i.Name != null)
                                    {
                                        boots ??= MailFrameworkModEntry.ModHelper.Content.Load <Dictionary <int, string> >(PathUtilities.NormalizeAssetName("Data/Boots"), ContentSource.GameContent);
                                        KeyValuePair <int, string> pair = boots.FirstOrDefault(o => o.Value.StartsWith(i.Name + "/"));
                                        if (pair.Value != null)
                                        {
                                            i.Index = pair.Key;
                                        }
                                        else
                                        {
                                            MailFrameworkModEntry.ModMonitor.Log($"No boots found with the name {i.Name} for letter {mailItem.Id}.", LogLevel.Warn);
                                        }
                                    }

                                    if (i.Index.HasValue)
                                    {
                                        attachments.Add(new Boots(i.Index.Value));
                                    }
                                    else
                                    {
                                        MailFrameworkModEntry.ModMonitor.Log($"An index value is required to attach a boots for letter {mailItem.Id}.", LogLevel.Warn);
                                    }
                                    break;

                                case ItemType.DGA:
                                    if (DgaApi != null)
                                    {
                                        try
                                        {
                                            object dgaObject = DgaApi.SpawnDGAItem(i.Name);
                                            if (dgaObject is StardewValley.Item dgaItem)
                                            {
                                                if (dgaItem is StardewValley.Object)
                                                {
                                                    dgaItem.Stack = i.Stack ?? 1;
                                                }
                                                else
                                                {
                                                    dgaItem.Stack = 1;
                                                }

                                                attachments.Add(dgaItem);
                                            }
                                            else
                                            {
                                                MailFrameworkModEntry.ModMonitor.Log($"No DGA item found with the ID {i.Name} for letter {mailItem.Id}.", LogLevel.Warn);
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            MailFrameworkModEntry.ModMonitor.Log($"Error trying to create item with the DGA ID {i.Name} for letter {mailItem.Id}.", LogLevel.Warn);
                                            MailFrameworkModEntry.ModMonitor.Log(ex.Message, LogLevel.Trace);
                                        }
                                    }
                                    else
                                    {
                                        MailFrameworkModEntry.ModMonitor.Log($"No DGA API found, so item with the ID {i.Name} for letter {mailItem.Id} will be ignored.", LogLevel.Warn);
                                    }
                                    break;

                                default:
                                    MailFrameworkModEntry.ModMonitor.Log($"Invalid attachment type '{i.Type}' found in letter {mailItem.Id}.", LogLevel.Warn);
                                    break;
                                }
                            });
                            MailDao.SaveLetter(
                                new Letter(
                                    mailItem.Id
                                    , hasTranslation && mailItem.Text != null ? contentPack.Translation.Get(mailItem.Text) : mailItem.Text
                                    , attachments
                                    , Condition
                                    , (l) =>
                            {
                                Game1.player.mailReceived.Add(l.Id);
                                if (mailItem.AdditionalMailReceived != null)
                                {
                                    Game1.player.mailReceived.AddRange(mailItem.AdditionalMailReceived);
                                }
                            }
                                    , mailItem.WhichBG
                                    )
                            {
                                TextColor     = mailItem.TextColor,
                                Title         = hasTranslation && mailItem.Title != null ? contentPack.Translation.Get(mailItem.Title) : mailItem.Title,
                                GroupId       = mailItem.GroupId,
                                LetterTexture = mailItem.LetterBG != null ? GetTextureAsset(contentPack, mailItem.LetterBG) : null,
                                UpperRightCloseButtonTexture = mailItem.UpperRightCloseButton != null ? GetTextureAsset(contentPack, mailItem.UpperRightCloseButton) : null,
                                AutoOpen = mailItem.AutoOpen,
                            });
                        }
                        else
                        {
                            MailDao.SaveLetter(
                                new Letter(
                                    mailItem.Id
                                    , hasTranslation && mailItem.Text != null ? contentPack.Translation.Get(mailItem.Text) : mailItem.Text
                                    , mailItem.Recipe
                                    , Condition
                                    , (l) =>
                            {
                                Game1.player.mailReceived.Add(l.Id);
                                if (mailItem.AdditionalMailReceived != null)
                                {
                                    Game1.player.mailReceived.AddRange(mailItem.AdditionalMailReceived);
                                }
                            }
                                    , mailItem.WhichBG
                                    )
                            {
                                TextColor     = mailItem.TextColor,
                                Title         = hasTranslation && mailItem.Title != null ? contentPack.Translation.Get(mailItem.Title) : mailItem.Title,
                                GroupId       = mailItem.GroupId,
                                LetterTexture = mailItem.LetterBG != null ? GetTextureAsset(contentPack, mailItem.LetterBG) : null,
                                UpperRightCloseButtonTexture = mailItem.UpperRightCloseButton != null ? GetTextureAsset(contentPack, mailItem.UpperRightCloseButton) : null,
                                AutoOpen = mailItem.AutoOpen,
                            });
                        }
                    }
                }
                else
                {
                    MailFrameworkModEntry.ModMonitor.Log($"Ignoring content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version} from {contentPack.DirectoryPath}\nIt does not have an mail.json file.", LogLevel.Warn);
                }
            }
        }
Пример #15
0
        private static void AddToolRushOrders(ShopMenu shop)
        {
            Dictionary <ISalable, int[]> toAddStock = new Dictionary <ISalable, int[]>();
            Dictionary <ISalable, int[]> stock      = shop.itemPriceAndStock;
            List <ISalable> toAddItems = new List <ISalable>();
            List <ISalable> items      = shop.forSale;

            foreach (KeyValuePair <ISalable, int[]> entry in stock)
            {
                if (entry.Key is not(Tool tool and(Axe or Pickaxe or Hoe or WateringCan)))
                {
                    continue;
                }

                // I'm going to edit the description, and I don't want to affect the original shop entry
                Tool toolRush = null, toolNow = null;
                if (tool is Axe)
                {
                    toolRush = new Axe();
                    toolNow  = new Axe();
                }
                else if (tool is Pickaxe)
                {
                    toolRush = new Pickaxe();
                    toolNow  = new Pickaxe();
                }
                else if (tool is Hoe)
                {
                    toolRush = new Hoe();
                    toolNow  = new Hoe();
                }
                else if (tool is WateringCan)
                {
                    toolRush = new WateringCan();
                    toolNow  = new WateringCan();
                }
                toolRush.UpgradeLevel = tool.UpgradeLevel;
                toolNow.UpgradeLevel  = tool.UpgradeLevel;
                toolRush.description  = I18n.Clint_Rush_Description() + Environment.NewLine + Environment.NewLine + tool.description;
                toolNow.description   = I18n.Clint_Instant_Description() + Environment.NewLine + Environment.NewLine + tool.description;

                int price = Mod.GetToolUpgradePrice(tool.UpgradeLevel);
                if (entry.Value[0] == price)
                {
                    int[] entryDataRush = (int[])entry.Value.Clone();
                    int[] entryDataNow  = (int[])entry.Value.Clone();
                    entryDataRush[0] = (int)(entry.Value[0] * Mod.ModConfig.PriceFactor.Tool.Rush);
                    entryDataNow[0]  = (int)(entry.Value[0] * Mod.ModConfig.PriceFactor.Tool.Now);

                    if (entryDataRush[0] != entry.Value[0] && Mod.ModConfig.PriceFactor.Tool.Rush > 0)
                    {
                        toAddStock.Add(toolRush, entryDataRush);
                        toAddItems.Add(toolRush);
                    }
                    if (entryDataNow[0] != entry.Value[0] && Mod.ModConfig.PriceFactor.Tool.Now > 0)
                    {
                        toAddStock.Add(toolNow, entryDataNow);
                        toAddItems.Add(toolNow);
                    }
                }
            }
            foreach (var elem in toAddStock)
            {
                stock.Add(elem.Key, elem.Value);
            }
            foreach (var elem in toAddItems)
            {
                items.Add(elem);
            }

            shop.forSale = items.OrderBy(i => i.Name).ToList();
        }
Пример #16
0
        private static void addToolRushOrders(ShopMenu shop)
        {
            Dictionary <ISalable, int[]> toAddStock = new Dictionary <ISalable, int[]>();
            Dictionary <ISalable, int[]> stock      = shop.itemPriceAndStock;
            List <ISalable> toAddItems = new List <ISalable>();
            List <ISalable> items      = shop.forSale;

            foreach (KeyValuePair <ISalable, int[]> entry in stock)
            {
                if (!(entry.Key is Tool))
                {
                    continue;
                }
                Tool tool = entry.Key as Tool;

                if (!(tool is Axe || tool is Pickaxe || tool is Hoe || tool is WateringCan))
                {
                    continue;
                }

                // I'm going to edit the description, and I don't want to affect the original shop entry
                Tool toolRush = null, toolNow = null;
                if (tool is Axe)
                {
                    toolRush = new Axe();
                    toolNow  = new Axe();
                }
                else if (tool is Pickaxe)
                {
                    toolRush = new Pickaxe();
                    toolNow  = new Pickaxe();
                }
                else if (tool is Hoe)
                {
                    toolRush = new Hoe();
                    toolNow  = new Hoe();
                }
                else if (tool is WateringCan)
                {
                    toolRush = new WateringCan();
                    toolNow  = new WateringCan();
                }
                toolRush.UpgradeLevel = tool.UpgradeLevel;
                toolNow.UpgradeLevel  = tool.UpgradeLevel;
                toolRush.DisplayName  = tool.DisplayName + "         *RUSH*";
                toolNow.DisplayName   = tool.DisplayName + "       =INSTANT=";
                toolRush.description  = "The tool will take one day to upgrade." + Environment.NewLine + Environment.NewLine + tool.description;
                toolNow.description   = "The tool will be immediately upgraded." + Environment.NewLine + Environment.NewLine + tool.description;

                int price = getToolUpgradePrice(tool.UpgradeLevel);
                if (entry.Value[0] == price)
                {
                    int[] entryDataRush = (int[])entry.Value.Clone();
                    int[] entryDataNow  = (int[])entry.Value.Clone();
                    entryDataRush[0] = (int)(entry.Value[0] * ModConfig.PriceFactor.Tool.Rush);
                    entryDataNow[0]  = (int)(entry.Value[0] * ModConfig.PriceFactor.Tool.Now);

                    if (entryDataRush[0] != entry.Value[0] && ModConfig.PriceFactor.Tool.Rush > 0)
                    {
                        toAddStock.Add(toolRush, entryDataRush);
                        toAddItems.Add(toolRush);
                    }
                    if (entryDataNow[0] != entry.Value[0] && ModConfig.PriceFactor.Tool.Now > 0)
                    {
                        toAddStock.Add(toolNow, entryDataNow);
                        toAddItems.Add(toolNow);
                    }
                }
            }
            foreach (var elem in toAddStock)
            {
                stock.Add(elem.Key, elem.Value);
            }
            foreach (var elem in toAddItems)
            {
                items.Add(elem);
            }

            shop.forSale = items.OrderBy(i => i.Name).ToList();
        }
Пример #17
0
        public LetterViewerMenu(string mail, string mailTitle, bool fromCollection = false)
            : base((int)Utility.getTopLeftPositionForCenteringOnScreen(1280, 720).X, (int)Utility.getTopLeftPositionForCenteringOnScreen(1280, 720).Y, 1280, 720, showUpperRightCloseButton: true)
        {
            isFromCollection = fromCollection;
            mail             = mail.Split(new string[1]
            {
                "[#]"
            }, StringSplitOptions.None)[0];
            mail = mail.Replace("@", Game1.player.Name);
            if (mail.Contains("%update"))
            {
                mail = mail.Replace("%update", Utility.getStardewHeroStandingsString());
            }
            isMail = true;
            Game1.playSound("shwip");
            backButton = new ClickableTextureComponent(new Rectangle(xPositionOnScreen + 32, yPositionOnScreen + height - 32 - 64, 48, 44), Game1.mouseCursors, new Rectangle(352, 495, 12, 11), 4f)
            {
                myID            = 101,
                rightNeighborID = 102
            };
            forwardButton = new ClickableTextureComponent(new Rectangle(xPositionOnScreen + width - 32 - 48, yPositionOnScreen + height - 32 - 64, 48, 44), Game1.mouseCursors, new Rectangle(365, 495, 12, 11), 4f)
            {
                myID           = 102,
                leftNeighborID = 101
            };
            acceptQuestButton = new ClickableComponent(new Rectangle(xPositionOnScreen + width / 2 - 128, yPositionOnScreen + height - 128, (int)Game1.dialogueFont.MeasureString(Game1.content.LoadString("Strings\\UI:AcceptQuest")).X + 24, (int)Game1.dialogueFont.MeasureString(Game1.content.LoadString("Strings\\UI:AcceptQuest")).Y + 24), "")
            {
                myID            = 103,
                rightNeighborID = 102,
                leftNeighborID  = 101
            };
            this.mailTitle = mailTitle;
            letterTexture  = Game1.temporaryContent.Load <Texture2D>("LooseSprites\\letterBG");
            if (mail.Contains("¦"))
            {
                mail = (Game1.player.IsMale ? mail.Substring(0, mail.IndexOf("¦")) : mail.Substring(mail.IndexOf("¦") + 1));
            }
            if (mail.Contains("%item"))
            {
                string   itemDescription = mail.Substring(mail.IndexOf("%item"), mail.IndexOf("%%") + 2 - mail.IndexOf("%item"));
                string[] split           = itemDescription.Split(' ');
                mail = mail.Replace(itemDescription, "");
                if (!isFromCollection)
                {
                    if (split[1].Equals("object"))
                    {
                        int maxNum2 = split.Length - 1;
                        int which3  = Game1.random.Next(2, maxNum2);
                        which3 -= which3 % 2;
                        Object o2 = new Object(Vector2.Zero, Convert.ToInt32(split[which3]), Convert.ToInt32(split[which3 + 1]));
                        itemsToGrab.Add(new ClickableComponent(new Rectangle(xPositionOnScreen + width / 2 - 48, yPositionOnScreen + height - 32 - 96, 96, 96), o2)
                        {
                            myID            = 104,
                            leftNeighborID  = 101,
                            rightNeighborID = 102
                        });
                        backButton.rightNeighborID   = 104;
                        forwardButton.leftNeighborID = 104;
                    }
                    else if (split[1].Equals("tools"))
                    {
                        for (int j = 2; j < split.Length; j++)
                        {
                            Item tool = null;
                            switch (split[j])
                            {
                            case "Axe":
                                tool = new Axe();
                                break;

                            case "Hoe":
                                tool = new Hoe();
                                break;

                            case "Can":
                                tool = new WateringCan();
                                break;

                            case "Scythe":
                                tool = new MeleeWeapon(47);
                                break;

                            case "Pickaxe":
                                tool = new Pickaxe();
                                break;
                            }
                            if (tool != null)
                            {
                                itemsToGrab.Add(new ClickableComponent(new Rectangle(xPositionOnScreen + width / 2 - 48, yPositionOnScreen + height - 32 - 96, 96, 96), tool));
                            }
                        }
                    }
                    else if (split[1].Equals("bigobject"))
                    {
                        int    maxNum = split.Length - 1;
                        int    which  = Game1.random.Next(2, maxNum);
                        Object o      = new Object(Vector2.Zero, Convert.ToInt32(split[which]));
                        itemsToGrab.Add(new ClickableComponent(new Rectangle(xPositionOnScreen + width / 2 - 48, yPositionOnScreen + height - 32 - 96, 96, 96), o)
                        {
                            myID            = 104,
                            leftNeighborID  = 101,
                            rightNeighborID = 102
                        });
                        backButton.rightNeighborID   = 104;
                        forwardButton.leftNeighborID = 104;
                    }
                    else if (split[1].Equals("money"))
                    {
                        int moneyToAdd2 = (split.Length > 4) ? Game1.random.Next(Convert.ToInt32(split[2]), Convert.ToInt32(split[3])) : Convert.ToInt32(split[2]);
                        moneyToAdd2        -= moneyToAdd2 % 10;
                        Game1.player.Money += moneyToAdd2;
                        moneyIncluded       = moneyToAdd2;
                    }
                    else if (split[1].Equals("conversationTopic"))
                    {
                        string topic   = split[2];
                        int    numDays = Convert.ToInt32(split[3].Replace("%%", ""));
                        Game1.player.activeDialogueEvents.Add(topic, numDays);
                        if (topic.Equals("ElliottGone3"))
                        {
                            Utility.getHomeOfFarmer(Game1.player).fridge.Value.addItem(new Object(732, 1));
                        }
                    }
                    else if (split[1].Equals("cookingRecipe"))
                    {
                        Dictionary <string, string> cookingRecipes = Game1.content.Load <Dictionary <string, string> >("Data\\CookingRecipes");
                        int    lowest_required_heart_level         = 1000;
                        string recipe_string = "";
                        foreach (string s in cookingRecipes.Keys)
                        {
                            string[] cookingSplit  = cookingRecipes[s].Split('/');
                            string[] getConditions = cookingSplit[3].Split(' ');
                            if (getConditions[0].Equals("f") && getConditions[1].Equals(mailTitle.Replace("Cooking", "")) && !Game1.player.cookingRecipes.ContainsKey(s))
                            {
                                int required_heart_level = Convert.ToInt32(getConditions[2]);
                                if (required_heart_level <= lowest_required_heart_level)
                                {
                                    lowest_required_heart_level = required_heart_level;
                                    recipe_string = s;
                                    learnedRecipe = s;
                                    if (LocalizedContentManager.CurrentLanguageCode != 0)
                                    {
                                        learnedRecipe = cookingSplit[cookingSplit.Length - 1];
                                    }
                                }
                            }
                        }
                        if (recipe_string != "")
                        {
                            if (!Game1.player.cookingRecipes.ContainsKey(recipe_string))
                            {
                                Game1.player.cookingRecipes.Add(recipe_string, 0);
                            }
                            cookingOrCrafting = Game1.content.LoadString("Strings\\UI:LearnedRecipe_cooking");
                        }
                    }
                    else if (split[1].Equals("craftingRecipe"))
                    {
                        learnedRecipe = split[2].Replace('_', ' ');
                        if (!Game1.player.craftingRecipes.ContainsKey(learnedRecipe))
                        {
                            Game1.player.craftingRecipes.Add(learnedRecipe, 0);
                        }
                        cookingOrCrafting = Game1.content.LoadString("Strings\\UI:LearnedRecipe_crafting");
                        if (LocalizedContentManager.CurrentLanguageCode != 0)
                        {
                            Dictionary <string, string> craftingRecipes = Game1.content.Load <Dictionary <string, string> >("Data\\CraftingRecipes");
                            if (craftingRecipes.ContainsKey(learnedRecipe))
                            {
                                string[] craftingSplit = craftingRecipes[learnedRecipe].Split('/');
                                learnedRecipe = craftingSplit[craftingSplit.Length - 1];
                            }
                        }
                    }
                    else if (split[1].Equals("itemRecovery"))
                    {
                        if (Game1.player.recoveredItem != null)
                        {
                            Item item = Game1.player.recoveredItem;
                            Game1.player.recoveredItem = null;
                            itemsToGrab.Add(new ClickableComponent(new Rectangle(xPositionOnScreen + width / 2 - 48, yPositionOnScreen + height - 32 - 96, 96, 96), item)
                            {
                                myID            = 104,
                                leftNeighborID  = 101,
                                rightNeighborID = 102
                            });
                            backButton.rightNeighborID   = 104;
                            forwardButton.leftNeighborID = 104;
                        }
                    }
                    else if (split[1].Equals("quest"))
                    {
                        questID = Convert.ToInt32(split[2].Replace("%%", ""));
                        if (split.Length > 4)
                        {
                            if (!Game1.player.mailReceived.Contains("NOQUEST_" + questID))
                            {
                                Game1.player.addQuest(questID);
                            }
                            questID = -1;
                        }
                        backButton.rightNeighborID   = 103;
                        forwardButton.leftNeighborID = 103;
                    }
                }
            }
            if (mailTitle == "ccBulletinThankYou" && !Game1.player.hasOrWillReceiveMail("ccBulletinThankYouReceived"))
            {
                foreach (NPC i in Utility.getAllCharacters())
                {
                    if (!i.datable && i.isVillager())
                    {
                        Game1.player.changeFriendship(500, i);
                    }
                }
                Game1.addMailForTomorrow("ccBulletinThankYouReceived", noLetter: true);
            }
            Random r = new Random((int)(Game1.uniqueIDForThisGame / 2uL) ^ Game1.year ^ (int)Game1.player.UniqueMultiplayerID);
            bool   hide_secret_santa = fromCollection;

            if (Game1.currentSeason == "winter" && Game1.dayOfMonth >= 18 && Game1.dayOfMonth <= 25)
            {
                hide_secret_santa = false;
            }
            mail        = mail.Replace("%secretsanta", hide_secret_santa ? "???" : Utility.getRandomTownNPC(r).displayName);
            mailMessage = SpriteText.getStringBrokenIntoSectionsOfHeight(mail, width - 64, height - 128);
            if (mailTitle.Equals("winter_5_2") || mailTitle.Equals("winter_12_1") || mailTitle.ToLower().Contains("wizard"))
            {
                whichBG = 2;
            }
            else if (mailTitle.Equals("Sandy"))
            {
                whichBG = 1;
            }
            if (Game1.options.SnappyMenus)
            {
                populateClickableComponentList();
                snapToDefaultClickableComponent();
                if (mailMessage != null && mailMessage.Count <= 1)
                {
                    backButton.myID    = -100;
                    forwardButton.myID = -100;
                }
            }
        }
Пример #18
0
        private void UseTool(Vector2 startPos, Vector2 endPos, GameLocation loc)
        {
            var player = Game1.player;

            Axe fakeAxe = new Axe {
                UpgradeLevel = 4
            };
            Pickaxe fakePick = new Pickaxe {
                UpgradeLevel = 4
            };
            MeleeWeapon fakeSickle = new MeleeWeapon {
                UpgradeLevel = 4
            };
            Hoe fakeHoe = new Hoe {
                UpgradeLevel = 4
            };
            WateringCan fakeCan = new WateringCan {
                UpgradeLevel = 4
            };

            Game1.player.MagneticRadius = 650;

            for (int xTile = Convert.ToInt32(startPos.X); xTile <= Convert.ToInt32(endPos.X); ++xTile)
            {
                for (int yTile = Convert.ToInt32(startPos.Y); yTile <= Convert.ToInt32(endPos.Y); ++yTile)
                {
                    Vector2 useAt = (new Vector2(xTile, yTile) * Game1.tileSize) + new Vector2(Game1.tileSize / 2f);
                    Game1.player.lastClick = useAt;

                    loc.objects.TryGetValue(new Vector2(xTile, yTile), out var obj);
                    loc.terrainFeatures.TryGetValue(new Vector2(xTile, yTile), out var ter);

                    //Check obj
                    if (obj != null)
                    {
                        bool forage = obj.IsSpawnedObject;//checkForAction(Game1.player);
                        if (forage)
                        {
                            DoForageHarvest(obj, loc, player);
                        }
                        if (obj.Name.ToLower().Contains("twig"))
                        {
                            fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, player);
                        }
                        if (obj.Name.ToLower().Contains("stone"))
                        {
                            fakePick.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, player);
                        }
                        if (obj.Name.ToLower().Contains("weed"))
                        {
                            fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, player);
                        }
                    }
                    //Check ter
                    if (ter != null)
                    {
                        if (ter is Tree tree)
                        {
                            fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, player);
                        }

                        if (ter is Grass)
                        {
                            Random rdn = new Random();
                            loc.terrainFeatures.Remove(new Vector2(xTile, yTile));
                            Game1.createMultipleObjectDebris(178, xTile, yTile, rdn.Next(2), loc);
                        }
                    }

                    if (ter != null && ter is HoeDirt dirt)
                    {
                        if (dirt.crop == null &&
                            player.ActiveObject != null &&
                            ((player.ActiveObject.Category == SObject.SeedsCategory || player.ActiveObject.Category == -19) &&
                             dirt.canPlantThisSeedHere(player.ActiveObject.ParentSheetIndex, (int)useAt.X, (int)useAt.Y, player.ActiveObject.Category == -19)))
                        {
                            if ((dirt.plant(player.ActiveObject.ParentSheetIndex, (int)useAt.X, (int)useAt.Y, player, player.ActiveObject.Category == -19, loc) && player.IsLocalPlayer))
                            {
                                player.reduceActiveItemByOne();
                            }
                            Game1.haltAfterCheck = false;
                        }
                        else if (dirt.crop != null)
                        {
                            if (dirt.crop.fullyGrown.Value)
                            {
                                dirt.crop.harvest((int)useAt.X, (int)useAt.Y, dirt);
                            }
                            else if (player.ActiveObject != null && player.ActiveObject.Category == -19)
                            {
                                dirt.fertilizer.Value = player.ActiveObject.ParentSheetIndex;
                                player.reduceActiveItemByOne();
                            }
                            else
                            {
                                fakeCan.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, Game1.player);
                            }
                        }
                        else
                        {
                            fakePick.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 0, Game1.player);
                        }
                    }
                    else
                    {
                        fakeHoe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 1, Game1.player);
                    }


                    //Lets try bush shit
                    Rectangle rectangle = new Rectangle((int)useAt.X + 32, (int)useAt.Y - 32, 4, 192);
                    foreach (LargeTerrainFeature largeTerrainFeature in loc.largeTerrainFeatures)
                    {
                        if (largeTerrainFeature is Bush bush && bush.getBoundingBox().Intersects(rectangle))
                        {
                            bush.performUseAction(bush.tilePosition.Value, loc);
                        }
                    }

                    //Resource Clumps
                    ResourceClump clump = GetResourceClumpCoveringTile(loc, new Vector2(useAt.X, useAt.Y));
                    if (clump != null)
                    {
                        if (clump.parentSheetIndex.Value == 600)
                        {
                            clump.health.Value = 1;
                            fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 1, Game1.player);
                        }

                        if (clump.parentSheetIndex.Value == 602)
                        {
                            clump.health.Value = 1;
                            fakeAxe.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 1, Game1.player);
                        }

                        if (clump.parentSheetIndex.Value == 672)
                        {
                            clump.health.Value = 1;
                            fakePick.DoFunction(loc, (int)useAt.X, (int)useAt.Y, 1, Game1.player);
                        }
                    }

                    Game1.player.Stamina = Game1.player.MaxStamina;//So we dont passout lol
                }
            }
        }
Пример #19
0
        private static void addToolRushOrders(ShopMenu shop)
        {
            FieldInfo stockField = typeof(ShopMenu).GetField("itemPriceAndStock", BindingFlags.NonPublic | BindingFlags.Instance);
            FieldInfo itemsField = typeof(ShopMenu).GetField("forSale", BindingFlags.NonPublic | BindingFlags.Instance);

            Dictionary <Item, int[]> toAddStock = new Dictionary <Item, int[]>();
            Dictionary <Item, int[]> stock      = (Dictionary <Item, int[]>)stockField.GetValue(shop);
            List <Item> toAddItems = new List <Item>();
            List <Item> items      = (List <Item>)itemsField.GetValue(shop);

            foreach (KeyValuePair <Item, int[]> entry in stock)
            {
                if (!(entry.Key is Tool))
                {
                    continue;
                }
                Tool tool = entry.Key as Tool;

                if (!(tool is Axe || tool is Pickaxe || tool is Hoe || tool is WateringCan))
                {
                    continue;
                }

                // I'm going to edit the description, and I don't want to affect the original shop entry
                Tool toolRush = null, toolNow = null;
                if (tool is Axe)
                {
                    toolRush = new Axe();
                    toolNow  = new Axe();
                }
                else if (tool is Pickaxe)
                {
                    toolRush = new Pickaxe();
                    toolNow  = new Pickaxe();
                }
                else if (tool is Hoe)
                {
                    toolRush = new Hoe();
                    toolNow  = new Hoe();
                }
                else if (tool is WateringCan)
                {
                    toolRush = new WateringCan();
                    toolNow  = new WateringCan();
                }
                toolRush.UpgradeLevel = tool.UpgradeLevel;
                toolNow.UpgradeLevel  = tool.UpgradeLevel;
                toolRush.DisplayName  = tool.DisplayName + "         *RUSH*";
                toolNow.DisplayName   = tool.DisplayName + "       =INSTANT=";
                toolRush.description  = "The tool will take one day to upgrade." + Environment.NewLine + Environment.NewLine + tool.description;
                toolNow.description   = "The tool will be immediately upgraded." + Environment.NewLine + Environment.NewLine + tool.description;

                int price = getToolUpgradePrice(tool.UpgradeLevel);
                if (entry.Value[0] == price)
                {
                    int[] entryDataRush = (int[])entry.Value.Clone();
                    int[] entryDataNow  = (int[])entry.Value.Clone();
                    entryDataRush[0] = (int)(entry.Value[0] * ModConfig.PriceFactor.Tool.Rush);
                    entryDataNow[0]  = (int)(entry.Value[0] * ModConfig.PriceFactor.Tool.Now);

                    if (entryDataRush[0] != entry.Value[0] && ModConfig.PriceFactor.Tool.Rush > 0)
                    {
                        toAddStock.Add(toolRush, entryDataRush);
                        toAddItems.Add(toolRush);
                    }
                    if (entryDataNow[0] != entry.Value[0] && ModConfig.PriceFactor.Tool.Now > 0)
                    {
                        toAddStock.Add(toolNow, entryDataNow);
                        toAddItems.Add(toolNow);
                    }
                }
            }
            foreach (var elem in toAddStock)
            {
                stock.Add(elem.Key, elem.Value);
            }
            foreach (var elem in toAddItems)
            {
                items.Add(elem);
            }

            itemsField.SetValue(shop, items.OrderBy(i => i.Name).ToList());

            prevMenu = Game1.activeClickableMenu;
        }
Пример #20
0
        /*********
        ** Private methods
        *********/
        /// <summary>Raised after the player loads a save slot.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
        {
            this.Config = this.Helper.ReadConfig <ModConfig>();

            this.PlowEnabled    = this.Config.PlowEnabled;
            this.PlantEnabled   = this.Config.PlantEnabled;
            this.GrowEnabled    = this.Config.GrowEnabled;
            this.HarvestEnabled = this.Config.HarvestEnabled;

            this.PlantRadius   = this.Config.PlantRadius;
            this.GrowRadius    = this.Config.GrowRadius;
            this.HarvestRadius = this.Config.HarvestRadius;

            this.PlowWidth  = this.Config.PlowWidth;
            this.PlowHeight = this.Config.PlowHeight;

            this.Fertilizer = this.Config.Fertilizer;

            this.LoggingEnabled = this.Config.LoggingEnabled;

            if (this.Config.PlowWidth < 1)
            {
                this.PlowWidth = 1;
                if (this.PlowEnabled)
                {
                    this.Monitor.Log($"Plow width must be at least 1; defaulted to {this.PlowWidth}.");
                }
            }
            else
            {
                this.PlowWidth = this.Config.PlowWidth;
            }

            if (this.Config.PlowHeight < 1)
            {
                this.PlowHeight = 1;
                if (this.PlowEnabled)
                {
                    this.Monitor.Log($"Plow height must be at least 1; defaulted to {this.PlowHeight}.");
                }
            }
            else
            {
                this.PlowHeight = this.Config.PlowHeight;
            }

            if (this.Config.PlantRadius < 0)
            {
                this.PlantRadius = 0;
                if (this.Config.PlantEnabled)
                {
                    this.Monitor.Log($"Plant Radius must be 0 or greater; defaulted to {this.PlantRadius}.");
                }
            }
            else
            {
                this.PlantRadius = this.Config.PlantRadius;
            }

            if (this.Config.GrowRadius < 0)
            {
                this.GrowRadius = 0;
                if (this.Config.GrowEnabled)
                {
                    this.Monitor.Log($"Grow Radius must be 0 or greater; defaulted to {this.GrowRadius}.");
                }
            }
            else
            {
                this.GrowRadius = this.Config.GrowRadius;
            }

            if (this.Config.HarvestRadius < 0)
            {
                this.HarvestRadius = 0;
                if (this.Config.PlantEnabled)
                {
                    this.Monitor.Log($"Harvest Radius must be 0 or greater; defaulted to {this.HarvestRadius}.");
                }
            }
            else
            {
                this.HarvestRadius = this.Config.HarvestRadius;
            }

            if (!Enum.TryParse(this.Config.PlowKey, true, out this.PlowKey))
            {
                this.PlowKey = SButton.Z;
                if (this.PlowEnabled)
                {
                    this.Monitor.Log($"Error parsing plow key; defaulted to {this.PlowKey}.");
                }
            }

            if (!Enum.TryParse(this.Config.PlantKey, true, out this.PlantKey))
            {
                this.PlantKey = SButton.A;
                if (this.PlantEnabled)
                {
                    this.Monitor.Log($"Error parsing plant key; defaulted to {this.PlantKey}.");
                }
            }

            if (!Enum.TryParse(this.Config.GrowKey, true, out this.GrowKey))
            {
                this.GrowKey = SButton.S;
                if (this.GrowEnabled)
                {
                    this.Monitor.Log($"Error parsing grow key; defaulted to {this.GrowKey}.");
                }
            }

            if (!Enum.TryParse(this.Config.HarvestKey, true, out this.HarvestKey))
            {
                this.HarvestKey = SButton.D;
                if (this.HarvestEnabled)
                {
                    this.Monitor.Log($"Error parsing harvest key; defaulted to {this.HarvestKey}.");
                }
            }

            this.GrassKey     = SButton.Q;
            this.CustomSickle = new ModSickle(47, this.Config.HarvestRadius, this.Vector);
            this.CustomHoe    = new Hoe {
                UpgradeLevel = this.ToolLevel
            };
        }
Пример #21
0
        /*********
        ** Private methods
        *********/
        private void SaveEvents_AfterLoad(object sender, EventArgs e)
        {
            this.Config = this.Helper.ReadConfig <ModConfig>();

            this.PlowEnabled    = this.Config.PlowEnabled;
            this.PlantEnabled   = this.Config.PlantEnabled;
            this.GrowEnabled    = this.Config.GrowEnabled;
            this.HarvestEnabled = this.Config.HarvestEnabled;

            this.PlantRadius   = this.Config.PlantRadius;
            this.GrowRadius    = this.Config.GrowRadius;
            this.HarvestRadius = this.Config.HarvestRadius;

            this.PlowWidth  = this.Config.PlowWidth;
            this.PlowHeight = this.Config.PlowHeight;

            this.Fertilizer = this.Config.Fertilizer;

            this.LoggingEnabled = this.Config.LoggingEnabled;

            if (this.Config.PlowWidth < 1)
            {
                this.PlowWidth = 1;
                if (this.PlowEnabled)
                {
                    this.Monitor.Log("Plow width must be at least 1. Defaulted to 1");
                }
            }
            else
            {
                this.PlowWidth = this.Config.PlowWidth;
            }

            if (this.Config.PlowHeight < 1)
            {
                this.PlowHeight = 1;
                if (this.PlowEnabled)
                {
                    this.Monitor.Log("Plow height must be at least 1. Defaulted to 1");
                }
            }
            else
            {
                this.PlowHeight = this.Config.PlowHeight;
            }

            if (this.Config.PlantRadius < 0)
            {
                this.PlantRadius = 0;
                if (this.Config.PlantEnabled)
                {
                    this.Monitor.Log("Plant Radius must be 0 or greater.  Defaulted to 0");
                }
            }
            else
            {
                this.PlantRadius = this.Config.PlantRadius;
            }

            if (this.Config.GrowRadius < 0)
            {
                this.GrowRadius = 0;
                if (this.Config.GrowEnabled)
                {
                    this.Monitor.Log("Grow Radius must be 0 or greater.  Defaulted to 0");
                }
            }
            else
            {
                this.GrowRadius = this.Config.GrowRadius;
            }

            if (this.Config.HarvestRadius < 0)
            {
                this.HarvestRadius = 0;
                if (this.Config.PlantEnabled)
                {
                    this.Monitor.Log("Harvest Radius must be 0 or greater.  Defaulted to 0");
                }
            }
            else
            {
                this.HarvestRadius = this.Config.HarvestRadius;
            }

            if (!Enum.TryParse(this.Config.PlowKey, true, out this.PlowKey))
            {
                this.PlowKey = Keys.Z;
                if (this.PlowEnabled)
                {
                    this.Monitor.Log("Error parsing plow key. Defaulted to Z");
                }
            }

            if (!Enum.TryParse(this.Config.PlantKey, true, out this.PlantKey))
            {
                this.PlantKey = Keys.A;
                if (this.PlantEnabled)
                {
                    this.Monitor.Log("Error parsing plant key. Defaulted to A");
                }
            }

            if (!Enum.TryParse(this.Config.GrowKey, true, out this.GrowKey))
            {
                this.GrowKey = Keys.S;
                if (this.GrowEnabled)
                {
                    this.Monitor.Log("Error parsing grow key. Defaulted to S");
                }
            }

            if (!Enum.TryParse(this.Config.HarvestKey, true, out this.HarvestKey))
            {
                this.HarvestKey = Keys.D;
                if (this.HarvestEnabled)
                {
                    this.Monitor.Log("Error parsing harvest key. Defaulted to D");
                }
            }

            this.GrassKey     = Keys.Q;
            this.CustomSickle = new ModSickle(47, this.Config.HarvestRadius, this.Vector);
            this.CustomHoe    = new Hoe {
                UpgradeLevel = this.ToolLevel
            };
        }
Пример #22
0
        // Token: 0x06000F06 RID: 3846 RVA: 0x001335E0 File Offset: 0x001317E0
        public LetterViewerMenu(string mail, string mailTitle) : base((int)Utility.getTopLeftPositionForCenteringOnScreen(320 * Game1.pixelZoom, 180 * Game1.pixelZoom, 0, 0).X, (int)Utility.getTopLeftPositionForCenteringOnScreen(320 * Game1.pixelZoom, 180 * Game1.pixelZoom, 0, 0).Y, 320 * Game1.pixelZoom, 180 * Game1.pixelZoom, true)
        {
            this.isMail = true;
            Game1.playSound("shwip");
            this.backButton        = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize / 2, this.yPositionOnScreen + this.height - Game1.tileSize / 2 - 16 * Game1.pixelZoom, 12 * Game1.pixelZoom, 11 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(352, 495, 12, 11), (float)Game1.pixelZoom, false);
            this.forwardButton     = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width - Game1.tileSize / 2 - 12 * Game1.pixelZoom, this.yPositionOnScreen + this.height - Game1.tileSize / 2 - 16 * Game1.pixelZoom, 12 * Game1.pixelZoom, 11 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(365, 495, 12, 11), (float)Game1.pixelZoom, false);
            this.acceptQuestButton = new ClickableComponent(new Rectangle(this.xPositionOnScreen + this.width / 2 - Game1.tileSize * 2, this.yPositionOnScreen + this.height - Game1.tileSize * 2, Game1.tileSize * 4, Game1.tileSize), "");
            this.mailTitle         = mailTitle;
            Game1.temporaryContent = Game1.content.CreateTemporary();
            this.letterTexture     = Game1.temporaryContent.Load <Texture2D>("LooseSprites\\letterBG");
            if (mail.Contains("%item"))
            {
                string   itemDescription = mail.Substring(mail.IndexOf("%item"), mail.IndexOf("%%") + 2 - mail.IndexOf("%item"));
                string[] split           = itemDescription.Split(new char[]
                {
                    ' '
                });
                mail = mail.Replace(itemDescription, "");
                if (split[1].Equals("object"))
                {
                    int maxNum = split.Length - 1;
                    int which  = Game1.random.Next(2, maxNum);
                    which -= which % 2;
                    Object o = new Object(Vector2.Zero, Convert.ToInt32(split[which]), Convert.ToInt32(split[which + 1]));
                    this.itemsToGrab.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + this.width / 2 - 12 * Game1.pixelZoom, this.yPositionOnScreen + this.height - Game1.tileSize / 2 - 24 * Game1.pixelZoom, 24 * Game1.pixelZoom, 24 * Game1.pixelZoom), o));
                }
                else if (split[1].Equals("tools"))
                {
                    for (int i = 2; i < split.Length; i++)
                    {
                        Item   tool = null;
                        string a    = split[i];
                        if (!(a == "Axe"))
                        {
                            if (!(a == "Hoe"))
                            {
                                if (!(a == "Can"))
                                {
                                    if (!(a == "Scythe"))
                                    {
                                        if (a == "Pickaxe")
                                        {
                                            tool = new Pickaxe();
                                        }
                                    }
                                    else
                                    {
                                        tool = new MeleeWeapon(47);
                                    }
                                }
                                else
                                {
                                    tool = new WateringCan();
                                }
                            }
                            else
                            {
                                tool = new Hoe();
                            }
                        }
                        else
                        {
                            tool = new Axe();
                        }
                        if (tool != null)
                        {
                            this.itemsToGrab.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + this.width / 2 - 12 * Game1.pixelZoom, this.yPositionOnScreen + this.height - Game1.tileSize / 2 - 24 * Game1.pixelZoom, 24 * Game1.pixelZoom, 24 * Game1.pixelZoom), tool));
                        }
                    }
                }
                else if (split[1].Equals("bigobject"))
                {
                    int    maxNum2 = split.Length - 1;
                    int    which2  = Game1.random.Next(2, maxNum2);
                    Object o2      = new Object(Vector2.Zero, Convert.ToInt32(split[which2]), false);
                    this.itemsToGrab.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + this.width / 2 - 12 * Game1.pixelZoom, this.yPositionOnScreen + this.height - Game1.tileSize / 2 - 24 * Game1.pixelZoom, 24 * Game1.pixelZoom, 24 * Game1.pixelZoom), o2));
                }
                else if (split[1].Equals("money"))
                {
                    int moneyToAdd = (split.Length > 4) ? Game1.random.Next(Convert.ToInt32(split[2]), Convert.ToInt32(split[3])) : Convert.ToInt32(split[2]);
                    moneyToAdd         -= moneyToAdd % 10;
                    Game1.player.Money += moneyToAdd;
                    this.moneyIncluded  = moneyToAdd;
                }
                else if (split[1].Equals("quest"))
                {
                    this.questID = Convert.ToInt32(split[2]);
                    if (split.Length > 4)
                    {
                        if (!Game1.player.mailReceived.Contains("NOQUEST_" + this.questID))
                        {
                            Game1.player.addQuest(this.questID);
                        }
                        this.questID = -1;
                    }
                }
                else
                {
                    if (split[1].Equals("cookingRecipe"))
                    {
                        Dictionary <string, string> cookingRecipes = Game1.content.Load <Dictionary <string, string> >("Data\\CookingRecipes");
                        using (Dictionary <string, string> .KeyCollection.Enumerator enumerator = cookingRecipes.Keys.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                string   s             = enumerator.Current;
                                string[] getConditions = cookingRecipes[s].Split(new char[]
                                {
                                    '/'
                                })[3].Split(new char[]
                                {
                                    ' '
                                });
                                if (getConditions[0].Equals("f") && getConditions[1].Equals(mailTitle.Replace("Cooking", "")) && Game1.player.friendships[getConditions[1]][0] >= Convert.ToInt32(getConditions[2]) * 250 && !Game1.player.cookingRecipes.ContainsKey(s))
                                {
                                    Game1.player.cookingRecipes.Add(s, 0);
                                    this.learnedRecipe     = s;
                                    this.cookingOrCrafting = Game1.content.LoadString("Strings\\UI:LearnedRecipe_cooking", new object[0]);
                                    break;
                                }
                            }
                            goto IL_704;
                        }
                    }
                    if (split[1].Equals("craftingRecipe"))
                    {
                        this.learnedRecipe = split[2].Replace('_', ' ');
                        Game1.player.craftingRecipes.Add(this.learnedRecipe, 0);
                        this.cookingOrCrafting = Game1.content.LoadString("Strings\\UI:LearnedRecipe_crafting", new object[0]);
                    }
                }
            }
IL_704:
            Random r = new Random((int)(Game1.uniqueIDForThisGame / 2uL) - Game1.year);

            mail             = mail.Replace("%secretsanta", Utility.getRandomTownNPC(r, Utility.getFarmerNumberFromFarmer(Game1.player)).name);
            this.mailMessage = SpriteText.getStringBrokenIntoSectionsOfHeight(mail, this.width - Game1.tileSize, this.height - Game1.tileSize * 2);
        }
Пример #23
0
        public static Item StardewTool(string sid)
        {
            switch (sid)
            {
            case "milk_pail":
                return(new MilkPail());

            case "shears":
                return(new Shears());

            case "pan":
                return(new Pan());

            case "wand":
                return(new Wand());

            case "iridium_fishing_rod": // Exception, fishing rod does not have a iridium upgrade level unlike the other upgrade-supporting tools
                return(null);           // So when asked for, we return null

            default:
                string[] split = sid.Split('_');
                if (split.Length != 2)
                {
                    return(null);
                }
                Tool tool;
                switch (split[1])
                {
                case "axe":
                    tool = new Axe();
                    break;

                case "hoe":
                    tool = new Hoe();
                    break;

                case "pickaxe":
                    tool = new Pickaxe();
                    break;

                case "wateringcan":
                    tool = new WateringCan();
                    break;

                case "fishing_rod":
                    tool = new FishingRod();
                    break;

                default:
                    return(null);
                }
                switch (split[0])
                {
                case "starter":
                    tool.UpgradeLevel = 0;
                    break;

                case "copper":
                    tool.UpgradeLevel = 1;
                    break;

                case "steel":
                    tool.UpgradeLevel = 2;
                    break;

                case "gold":
                    tool.UpgradeLevel = 3;
                    break;

                case "iridium":
                    tool.UpgradeLevel = 4;
                    break;

                default:
                    return(null);
                }
                return(tool);
            }
        }
Пример #24
0
 protected virtual bool OnHoeAction(Hoe hoe) => base.performToolAction(hoe);
Пример #25
0
        public override IActiveEffect OnCast(Farmer player, int level, int targetX, int targetY)
        {
            level   += 1;
            targetX /= Game1.tileSize;
            targetY /= Game1.tileSize;
            Vector2 target = new Vector2(targetX, targetY);

            Tool dummyHoe = new Hoe();

            Mod.Instance.Helper.Reflection.GetField <Farmer>(dummyHoe, "lastUser").SetValue(player);

            GameLocation loc = player.currentLocation;

            for (int tileX = targetX - level; tileX <= targetX + level; ++tileX)
            {
                for (int tileY = targetY - level; tileY <= targetY + level; ++tileY)
                {
                    if (player.GetCurrentMana() <= 2)
                    {
                        return(null);
                    }

                    Vector2 tile = new Vector2(tileX, tileY);
                    if (loc.terrainFeatures.ContainsKey(tile))
                    {
                        continue; // ?
                    }
                    if (loc.objects.TryGetValue(tile, out SObject obj))
                    {
                        if (obj.ParentSheetIndex == 590)
                        {
                            loc.digUpArtifactSpot(tileX, tileY, player);
                            loc.objects.Remove(tile);
                            player.AddMana(-1);
                        }
                        else if (obj.performToolAction(dummyHoe, loc))
                        {
                            if (obj.Type == "Crafting" && obj.Fragility != 2)
                            {
                                loc.debris.Add(new Debris(obj.bigCraftable.Value ? -obj.ParentSheetIndex : obj.ParentSheetIndex, tile, tile));
                            }
                            obj.performRemoveAction(tile, loc);
                            loc.objects.Remove(tile);
                            player.AddMana(-1);
                        }
                    }

                    if (loc.terrainFeatures.TryGetValue(tile, out TerrainFeature feature))
                    {
                        if (feature.performToolAction(dummyHoe, 0, tile, loc))
                        {
                            loc.terrainFeatures.Remove(tile);
                            player.AddMana(-1);
                        }
                    }

                    if (loc.doesTileHaveProperty(tileX, tileY, "Diggable", "Back") != null && !loc.isTileOccupied(tile))
                    {
                        loc.makeHoeDirt(tile);
                        loc.playSoundAt("hoeHit", tile);
                        Game1.removeSquareDebrisFromTile(tileX, tileY);
                        loc.temporarySprites.Add(new TemporaryAnimatedSprite(12, new Vector2(tileX * (float)Game1.tileSize, tileY * (float)Game1.tileSize), Color.White, 8, Game1.random.NextDouble() < 0.5, 50f));
                        loc.temporarySprites.Add(new TemporaryAnimatedSprite(6, new Vector2(tileX * (float)Game1.tileSize, tileY * (float)Game1.tileSize), Color.White, 8, Game1.random.NextDouble() < 0.5, Vector2.Distance(tile, target) * 30f));
                        loc.checkForBuriedItem(tileX, tileY, false, false, player);
                        player.AddMana(-3);
                        player.AddCustomSkillExperience(Magic.Skill, 2);
                    }
                }
            }

            return(null);
        }
Пример #26
0
 public static List <Vector2> tilesAffected(Hoe wcan, Vector2 loc, int power, Farmer who)
 {
     return(Mod.instance.Helper.Reflection.GetMethod(wcan, "tilesAffected").Invoke <List <Vector2> >(loc, power, who));
 }
Пример #27
0
        private static void MenuEvents_MenuChanged1(object sender, EventArgsClickableMenuChanged e)
        {
            if (!(e.NewMenu is ShopMenu))
            {
                return;
            }
            ShopMenu   menu       = e.NewMenu as ShopMenu;
            List <int> categories = ModEntry.ModHelper.Reflection.GetField <List <int> >(menu, "categoriesToSellHere").GetValue();

            if (!categories.Contains(Object.GemCategory) || !categories.Contains(Object.mineralsCategory) || !categories.Contains(Object.metalResources))
            {
                return;
            }
            Farmer who = Game1.player;

            Tool toolFromName1 = who.getToolFromName("Axe");
            Tool toolFromName2 = who.getToolFromName("Watering Can");
            Tool toolFromName3 = who.getToolFromName("Pickaxe");
            Tool toolFromName4 = who.getToolFromName("Hoe");
            Tool tool;

            List <Item> forSale            = ModEntry.ModHelper.Reflection.GetField <List <Item> >(menu, "forSale").GetValue();
            Dictionary <Item, int[]> stock = ModEntry.ModHelper.Reflection.GetField <Dictionary <Item, int[]> >(menu, "itemPriceAndStock").GetValue();

            if (toolFromName1 != null && toolFromName1.UpgradeLevel == 4)
            {
                tool = new Axe {
                    UpgradeLevel = 5
                };
                forSale.Add(tool);
                stock.Add(tool, new int[3] {
                    UpgradeCost, 1, PrismaticBarItem.INDEX
                });
            }
            if (toolFromName2 != null && toolFromName2.UpgradeLevel == 4)
            {
                tool = new WateringCan {
                    UpgradeLevel = 5
                };
                forSale.Add(tool);
                stock.Add(tool, new int[3] {
                    UpgradeCost, 1, PrismaticBarItem.INDEX
                });
            }
            if (toolFromName3 != null && toolFromName3.UpgradeLevel == 4)
            {
                tool = new Pickaxe {
                    UpgradeLevel = 5
                };
                forSale.Add(tool);
                stock.Add(tool, new int[3] {
                    UpgradeCost, 1, PrismaticBarItem.INDEX
                });
            }
            if (toolFromName4 != null && toolFromName4.UpgradeLevel == 4)
            {
                tool = new Hoe {
                    UpgradeLevel = 5
                };
                forSale.Add(tool);
                stock.Add(tool, new int[3] {
                    UpgradeCost, 1, PrismaticBarItem.INDEX
                });
            }
        }
Пример #28
0
        private Tool GetTool()
        {
            ICursorPosition c = Helper.Input.GetCursorPosition();

            Vector2[]    grid       = GetGrid(c.Tile, _config.ToolRadius).ToArray();
            Tool         t          = new Hoe();
            GameLocation location   = Game1.player.currentLocation;
            ToolConfig   toolConfig = _config.Tools;

            //FarmAnimal animal;
            foreach (Vector2 tile in grid)
            {
                location.objects.TryGetValue(tile, out SObject tileObj);
                location.terrainFeatures.TryGetValue(tile, out TerrainFeature tileFeature);
                //animal = GetAnimal(location, tile);

                //Check tiles to see if they're objects. Weed, Twig, Stone type stuff
                if (tileObj != null)
                {
                    if (tileObj.Name.Contains("Weed") || tileObj.Name.Contains("Twig"))
                    {
                        t = new Axe()
                        {
                            UpgradeLevel = _config.ToolLevel
                        }
                    }
                    ;
                    if (tileObj.Name.Contains("Stone"))
                    {
                        t = new Pickaxe()
                        {
                            UpgradeLevel = _config.ToolLevel
                        }
                    }
                    ;
                }
                //Check tiles to see if they're terrainFeatures. Tree, HoeDirt type stuff
                if (tileFeature != null)
                {
                    if (tileFeature is Tree)
                    {
                        t = new Axe()
                        {
                            UpgradeLevel = _config.ToolLevel
                        }
                    }
                    ;
                    if (tileFeature is HoeDirt dirt && dirt.crop == null || (Game1.player.ActiveObject != null && Game1.player.CurrentItem.Category != SObject.SeedsCategory && Game1.player.CurrentItem.Category != -19))
                    {
                        t = new Pickaxe()
                        {
                            UpgradeLevel = _config.ToolLevel
                        }
                    }
                    ;
                    if (tileFeature is HoeDirt dirt1 && dirt1.crop != null)
                    {
                        t = new WateringCan()
                        {
                            UpgradeLevel = _config.ToolLevel
                        }
                    }
                    ;
                    if (tileFeature is Grass grass)
                    {
                        t = new MeleeWeapon()
                        {
                            Name = "Scythe", UpgradeLevel = _config.ToolLevel
                        }
                    }
                    ;
                    if (tileFeature is HoeDirt dirt3 && dirt3.crop == null && Game1.player.ActiveObject != null &&
                        (Game1.player.CurrentItem.Category == SObject.SeedsCategory ||
                         Game1.player.CurrentItem.Category == -19))
                    {
                        bool planted;
                        if (Game1.player.ActiveObject.Category == -19)
                        {
                            planted = dirt3.plant(Game1.player.ActiveObject.ParentSheetIndex, (int)tile.X, (int)tile.Y, Game1.player, true, location);
                            if (planted)
                            {
                                Game1.player.reduceActiveItemByOne();
                            }
                        }

                        if (Game1.player.ActiveObject.Category == SObject.SeedsCategory)
                        {
                            planted = dirt3.plant(Game1.player.ActiveObject.ParentSheetIndex, (int)tile.X, (int)tile.Y, Game1.player, false, location);
                            if (planted)
                            {
                                Game1.player.reduceActiveItemByOne();
                            }
                        }
                    }
                }

                /*
                 * //See if Animal is not null
                 * if (animal != null)
                 * {
                 *  if (animal.toolUsedForHarvest.Value.Contains("ears"))
                 *      t = new Shears(){ UpgradeLevel = _config.ToolLevel };
                 *  else
                 *      t = new MilkPail(){ UpgradeLevel = _config.ToolLevel };
                 * }*/
            }

            return(t);
        }
Пример #29
0
        public override IActiveEffect onCast(Farmer player, int level, int targetX, int targetY)
        {
            level   += 1;
            targetX /= Game1.tileSize;
            targetY /= Game1.tileSize;
            Vector2 target = new Vector2(targetX, targetY);

            Tool dummyHoe = new Hoe();

            Mod.instance.Helper.Reflection.GetField <Farmer>(dummyHoe, "lastUser").SetValue(player);

            GameLocation loc = player.currentLocation;

            for (int ix = targetX - level; ix <= targetX + level; ++ix)
            {
                for (int iy = targetY - level; iy <= targetY + level; ++iy)
                {
                    if (player.getCurrentMana() <= 2)
                    {
                        return(null);
                    }

                    Vector2 pos = new Vector2(ix, iy);
                    if (loc.terrainFeatures.ContainsKey(pos))
                    {
                        continue; // ?
                    }
                    if (loc.objects.ContainsKey(pos))
                    {
                        var obj = loc.objects[pos];
                        if (obj.ParentSheetIndex == 590)
                        {
                            loc.digUpArtifactSpot(ix, iy, player);
                            loc.objects.Remove(pos);
                            player.addMana(-1);
                        }
                        else if (obj.performToolAction(dummyHoe, loc))
                        {
                            if (obj.Type == "Crafting" && obj.Fragility != 2)
                            {
                                loc.debris.Add(new Debris(obj.bigCraftable.Value ? -obj.ParentSheetIndex : obj.ParentSheetIndex, pos, pos));
                            }
                            obj.performRemoveAction(pos, loc);
                            loc.objects.Remove(pos);
                            player.addMana(-1);
                        }
                    }

                    if (loc.terrainFeatures.ContainsKey(pos))
                    {
                        if (loc.terrainFeatures[pos].performToolAction(dummyHoe, 0, pos, loc))
                        {
                            loc.terrainFeatures.Remove(pos);
                            player.addMana(-1);
                        }
                    }

                    if (loc.doesTileHaveProperty(ix, iy, "Diggable", "Back") != null && !loc.isTileOccupied(pos, ""))
                    {
                        loc.makeHoeDirt(pos);
                        Game1.playSound("hoeHit");
                        Game1.removeSquareDebrisFromTile(ix, iy);
                        loc.temporarySprites.Add(new TemporaryAnimatedSprite(12, new Vector2(ix * (float)Game1.tileSize, iy * (float)Game1.tileSize), Color.White, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0));
                        loc.temporarySprites.Add(new TemporaryAnimatedSprite(6, new Vector2(ix * (float)Game1.tileSize, iy * (float)Game1.tileSize), Color.White, 8, Game1.random.NextDouble() < 0.5, Vector2.Distance(pos, target) * 30f, 0, -1, -1f, -1, 0));
                        loc.checkForBuriedItem(ix, iy, false, false);
                        player.addMana(-3);
                        player.AddCustomSkillExperience(Magic.Skill, 2);
                    }
                }
            }

            return(null);
        }
Пример #30
0
 public static void Prefix(Hoe __instance, GameLocation location, int x, int y, int power, Farmer who)
 {
     who.Stamina += Math.Min(who.HasAdornment(ToolType.Hoe, Mod.Config.GEODE_LESS_STAMINA), 4) * 0.25f;
 }