Ejemplo n.º 1
0
        private void shake(Vector2 tileLocation, bool doEvenIfStillShaking)
        {
            if ((double)this.maxShake == 0.0 | doEvenIfStillShaking && this.growthStage.Value >= 3 && !this.stump.Value)
            {
                this.shakeLeft.Value = (double)Game1.player.getTileLocation().X > (double)tileLocation.X || (double)Game1.player.getTileLocation().X == (double)tileLocation.X && Game1.random.NextDouble() < 0.5;
                this.maxShake        = this.growthStage.Value >= 5 ? (float)Math.PI / 128f : (float)Math.PI / 64f;
                if (this.growthStage.Value >= 5)
                {
                    if (Game1.random.NextDouble() < 0.66)
                    {
                        int num = Game1.random.Next(1, 6);
                        for (int index = 0; index < num; ++index)
                        {
                            this.leaves.Add(new Leaf(new Vector2((float)Game1.random.Next((int)((double)tileLocation.X * 64.0 - 64.0), (int)((double)tileLocation.X * 64.0 + 128.0)), (float)Game1.random.Next((int)((double)tileLocation.Y * 64.0 - 256.0), (int)((double)tileLocation.Y * 64.0 - 192.0))), (float)Game1.random.Next(-10, 10) / 100f, Game1.random.Next(4), (float)Game1.random.Next(5) / 10f));
                        }
                    }
                    if (Game1.random.NextDouble() < 0.01 && (Game1.currentSeason.Equals("spring") || Game1.currentSeason.Equals("summer")))
                    {
                        while (Game1.random.NextDouble() < 0.8)
                        {
                            Game1.currentLocation.addCritter((Critter) new Butterfly(new Vector2(tileLocation.X + (float)Game1.random.Next(1, 3), tileLocation.Y - 2f + (float)Game1.random.Next(-1, 2))));
                        }
                    }
                    if (!this.hasSeed.Value || !Game1.IsMultiplayer && Game1.player.ForagingLevel < 1)
                    {
                        return;
                    }

                    //Add this back in once we've added the seed object for these Voidshroom Trees
                    int objectIndex = VoidshroomSpore.getIndex();
                    if (objectIndex != -1)
                    {
                        Game1.createObjectDebris(objectIndex, (int)tileLocation.X, (int)tileLocation.Y - 3, ((int)tileLocation.Y + 1) * 64, 0, 1f, (GameLocation)null);
                    }
                    this.hasSeed.Value = false;
                }
                else
                {
                    if (Game1.random.NextDouble() >= 0.66)
                    {
                        return;
                    }
                    int num = Game1.random.Next(1, 3);
                    for (int index = 0; index < num; ++index)
                    {
                        this.leaves.Add(new Leaf(new Vector2((float)Game1.random.Next((int)((double)tileLocation.X * 64.0), (int)((double)tileLocation.X * 64.0 + 48.0)), (float)((double)tileLocation.Y * 64.0 - 32.0)), (float)Game1.random.Next(-10, 10) / 100f, Game1.random.Next(4), (float)Game1.random.Next(30) / 10f));
                    }
                }
            }
            else
            {
                if (!this.stump.Value)
                {
                    return;
                }
                this.shakeTimer = 100f;
            }
        }
Ejemplo n.º 2
0
        public static int getIndex()
        {
            if (VoidshroomSpore.itemIndex == -1)
            {
                VoidshroomSpore.setIndex();
            }

            return(VoidshroomSpore.itemIndex);
        }
Ejemplo n.º 3
0
        private void OnRenderedHud(object sender, RenderedHudEventArgs e)
        {
            if (isGameReady())
            {
                Item currentItem = Game1.player.CurrentItem;

                if (currentItem.ParentSheetIndex == VoidshroomSpore.getIndex())
                {
                    VoidshroomSpore.drawPlacementBounds((StardewValley.Object)currentItem, e.SpriteBatch, Game1.player.currentLocation);
                }
            }
        }
Ejemplo n.º 4
0
        private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
        {
            if (isGameReady())
            {
                Item currentItem = Game1.player.CurrentItem;

                if (currentItem.ParentSheetIndex == VoidshroomSpore.getIndex() && e.Button.IsActionButton())
                {
                    this.Monitor.Log("Attempt to plant a new voidshroom tree at " + e.Cursor.GrabTile.ToString());
                    bool planted = VoidshroomSpore.AttemptPlanting(e.Cursor.GrabTile, Game1.currentLocation);
                    if (planted)
                    {
                        Game1.player.reduceActiveItemByOne();
                    }
                }
            }
        }
Ejemplo n.º 5
0
 internal static bool AttemptPlanting(Vector2 grabTile, GameLocation location, Farmer who = null)
 {
     if (VoidshroomSpore.canPlaceHere(location, grabTile))
     {
         location.terrainFeatures.Remove(grabTile);
         location.terrainFeatures.Add(grabTile, (TerrainFeature) new VoidshroomTree(0));
         location.playSound("dirtyHit");
         return(true);
     }
     else
     {
         if (!IsValidLocation(location))
         {
             Game1.showRedMessage("These seeds can only thrive in darkness.");
         }
         return(false);
     }
 }
Ejemplo n.º 6
0
        public static void drawPlacementBounds(StardewValley.Object obj, SpriteBatch spriteBatch, GameLocation location)
        {
            int x = Game1.getOldMouseX() + Game1.viewport.X;
            int y = Game1.getOldMouseY() + Game1.viewport.Y;

            if ((double)Game1.mouseCursorTransparency == 0.0)
            {
                x = (int)Game1.player.GetGrabTile().X * 64;
                y = (int)Game1.player.GetGrabTile().Y * 64;
            }
            if (Game1.player.GetGrabTile().Equals(Game1.player.getTileLocation()) && (double)Game1.mouseCursorTransparency == 0.0)
            {
                Vector2 translatedVector2 = Utility.getTranslatedVector2(Game1.player.GetGrabTile(), Game1.player.FacingDirection, 1f);
                x = (int)translatedVector2.X * 64;
                y = (int)translatedVector2.Y * 64;
            }

            bool flag = VoidshroomSpore.canPlaceHere(location, new Vector2(x / 64, y / 64));

            spriteBatch.Draw(Game1.mouseCursors, new Vector2((float)(x / 64 * 64 - Game1.viewport.X), (float)(y / 64 * 64 - Game1.viewport.Y)), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(flag ? 194 : 210, 388, 16, 16)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.01f);
        }
Ejemplo n.º 7
0
        public static void ProcessLocation(GameLocation location, ProcessingMethod method)
        {
            if (location == null)
            {
                return;
            }

            monitor.Log("VoidshroomTree.ProcessLocation(" + location.Name + ", " + method + ")", StardewModdingAPI.LogLevel.Trace);

            if (processedLocations.Contains(location))
            {
                monitor.Log("VoidshroomTree.ProcessLocation(" + location.Name + ", " + method + "): Already processed this location (infinite recursion?), aborting!", StardewModdingAPI.LogLevel.Warn);
                return;
            }

            processedLocations.Add(location);

            bool itemsToRemove = false;

            if (VoidshroomSpore.IsValidLocation(location))
            {
                String locationName = location.Name.ToString();
                if (method.Equals(ProcessingMethod.Remove))
                {
                    foreach (Vector2 featureSpot in location.terrainFeatures.Keys)
                    {
                        if (location.terrainFeatures[featureSpot] is VoidshroomTree)
                        {
                            StringWriter writer = new StringWriter();

                            if (!ModState.voidshroomTreeLocations.ContainsKey(locationName))
                            {
                                ModState.voidshroomTreeLocations.Add(locationName, new Dictionary <Vector2, VoidshroomtreeSaveData>());
                            }

                            VoidshroomTree tree = (VoidshroomTree)location.terrainFeatures[featureSpot];

                            ModState.voidshroomTreeLocations[locationName].Add(featureSpot, tree.GetSaveData());
                            itemsToRemove = true;
                        }
                    }

                    //data is stored, but if we're removing we need to actually clear stuff out of the list now.
                    if (itemsToRemove)
                    {
                        foreach (Vector2 locationData in ModState.voidshroomTreeLocations[location.Name.ToString()].Keys)
                        {
                            location.terrainFeatures.Remove(locationData);
                        }
                    }
                }
                else if (method.Equals(ProcessingMethod.Restore))
                {
                    if (ModState.voidshroomTreeLocations.ContainsKey(location.Name.ToString()))
                    {
                        foreach (KeyValuePair <Vector2, VoidshroomtreeSaveData> locationData in ModState.voidshroomTreeLocations[location.Name.ToString()])
                        {
                            location.terrainFeatures.Add(locationData.Key, new VoidshroomTree(locationData.Value));
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public override bool performToolAction(
            Tool t,
            int explosion,
            Vector2 tileLocation,
            GameLocation location)
        {
            if (location == null)
            {
                location = Game1.currentLocation;
            }
            if (explosion > 0)
            {
                this.tapped.Value = false;
            }
            if (this.tapped.Value)
            {
                return(false);
            }
            Console.WriteLine("TREE: IsClient:" + Game1.IsClient.ToString() + " randomOutput: " + (object)Game1.recentMultiplayerRandom.Next(9999));
            if ((double)this.health.Value <= -99.0)
            {
                return(false);
            }
            if (this.growthStage.Value >= 5)
            {
                if (t != null && t is Axe)
                {
                    location.playSound("axchop");
                    location.debris.Add(new Debris(12, Game1.random.Next(1, 3), t.getLastFarmerToUse().GetToolLocation(false) + new Vector2(16f, 0.0f), t.getLastFarmerToUse().Position, 0, -1));
                    this.lastPlayerToHit.Value = t.getLastFarmerToUse().UniqueMultiplayerID;
                    if (!this.stump.Value && t.getLastFarmerToUse() != null && (t.getLastFarmerToUse().hasMagnifyingGlass&& Game1.random.NextDouble() < 0.005))
                    {
                        StardewValley.Object unseenSecretNote = location.tryToCreateUnseenSecretNote(t.getLastFarmerToUse());
                        if (unseenSecretNote != null)
                        {
                            Game1.createItemDebris((Item)unseenSecretNote, new Vector2(tileLocation.X, tileLocation.Y - 3f) * 64f, -1, (GameLocation)null, Game1.player.getStandingY() - 32);
                        }
                    }
                }
                else if (explosion <= 0)
                {
                    return(false);
                }
                this.shake(tileLocation, true);
                float num = 1f;
                if (explosion > 0)
                {
                    num = (float)explosion;
                }
                else
                {
                    if (t == null)
                    {
                        return(false);
                    }
                    switch (t.UpgradeLevel)
                    {
                    case 0:
                        num = 1f;
                        break;

                    case 1:
                        num = 1.25f;
                        break;

                    case 2:
                        num = 1.67f;
                        break;

                    case 3:
                        num = 2.5f;
                        break;

                    case 4:
                        num = 5f;
                        break;
                    }
                }
                this.health.Value -= num;
                if ((double)this.health.Value <= 0.0)
                {
                    if (!this.stump.Value)
                    {
                        if (t != null || explosion > 0)
                        {
                            location.playSound("treecrack");
                        }
                        this.stump.Value   = true;
                        this.health.Value  = 5f;
                        this.falling.Value = true;
                        if (t != null && t.getLastFarmerToUse().IsLocalPlayer)
                        {
                            t?.getLastFarmerToUse().gainExperience(2, 12);
                            if (t == null || t.getLastFarmerToUse() == null)
                            {
                                this.shakeLeft.Value = true;
                            }
                            else
                            {
                                this.shakeLeft.Value = (double)t.getLastFarmerToUse().getTileLocation().X > (double)tileLocation.X || (double)t.getLastFarmerToUse().getTileLocation().Y < (double)tileLocation.Y && (double)tileLocation.X % 2.0 == 0.0;
                            }
                        }
                    }
                    else
                    {
                        if (t != null && (double)this.health.Value != -100.0 && (t.getLastFarmerToUse().IsLocalPlayer&& t != null))
                        {
                            t.getLastFarmerToUse().gainExperience(2, 1);
                        }
                        this.health.Value = -100f;
                        Game1.createRadialDebris(location, 12, (int)tileLocation.X, (int)tileLocation.Y, Game1.random.Next(30, 40), false, -1, false, -1);

                        //this produces eitehr sap or mushrooms currently.  Tweak perhaps to drop voidshroom bark to process into wood? Just drop wood directly?
                        int index = (double)tileLocation.X % 7.0 != 0.0 ? 388 : 709;
                        if (Game1.IsMultiplayer)
                        {
                            Game1.recentMultiplayerRandom = new Random((int)tileLocation.X * 2000 + (int)tileLocation.Y);
                            Random multiplayerRandom = Game1.recentMultiplayerRandom;
                        }
                        else
                        {
                            Random random = new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed + (int)tileLocation.X * 7 + (int)tileLocation.Y * 11);
                        }
                        if (t == null || t.getLastFarmerToUse() == null)
                        {
                            if (location.Equals(Game1.currentLocation))
                            {
                                Game1.createMultipleObjectDebris(92, (int)tileLocation.X, (int)tileLocation.Y, 2);
                            }
                            else
                            {
                                Game1.createItemDebris((Item) new StardewValley.Object(92, 1, false, -1, 0), tileLocation * 64f, 2, location, -1);
                                Game1.createItemDebris((Item) new StardewValley.Object(92, 1, false, -1, 0), tileLocation * 64f, 2, location, -1);
                            }
                        }
                        else if (Game1.IsMultiplayer)
                        {
                            Game1.createMultipleObjectDebris(index, (int)tileLocation.X, (int)tileLocation.Y, 1, this.lastPlayerToHit.Value);

                            Game1.createRadialDebris(location, 12, (int)tileLocation.X, (int)tileLocation.Y, 4, true, -1, false, -1);
                        }
                        else
                        {
                            Game1.createRadialDebris(location, 12, (int)tileLocation.X, (int)tileLocation.Y, 5 + this.extraWoodCalculator(tileLocation), true, -1, false, -1);
                            Game1.createMultipleObjectDebris(index, (int)tileLocation.X, (int)tileLocation.Y, 1);
                        }
                        location.playSound("treethud");
                        if (!this.falling.Value)
                        {
                            return(true);
                        }
                    }
                }
            }
            else if (this.growthStage.Value >= 3)
            {
                if (t != null && t.BaseName.Contains("Ax"))
                {
                    location.playSound("axchop");
                    location.debris.Add(new Debris(12, Game1.random.Next(t.UpgradeLevel * 2, t.UpgradeLevel * 4), t.getLastFarmerToUse().GetToolLocation(false) + new Vector2(16f, 0.0f), new Vector2((float)t.getLastFarmerToUse().GetBoundingBox().Center.X, (float)t.getLastFarmerToUse().GetBoundingBox().Center.Y), 0, -1));
                }
                else if (explosion <= 0)
                {
                    return(false);
                }
                this.shake(tileLocation, true);
                float num = 1f;
                if (Game1.IsMultiplayer)
                {
                    Random multiplayerRandom = Game1.recentMultiplayerRandom;
                }
                else
                {
                    Random random = new Random((int)((double)Game1.uniqueIDForThisGame + (double)tileLocation.X * 7.0 + (double)tileLocation.Y * 11.0 + (double)Game1.stats.DaysPlayed + (double)this.health.Value));
                }
                if (explosion > 0)
                {
                    num = (float)explosion;
                }
                else
                {
                    switch (t.UpgradeLevel)
                    {
                    case 0:
                        num = 2f;
                        break;

                    case 1:
                        num = 2.5f;
                        break;

                    case 2:
                        num = 3.34f;
                        break;

                    case 3:
                        num = 5f;
                        break;

                    case 4:
                        num = 10f;
                        break;
                    }
                }
                this.health.Value -= num;
                if ((double)this.health.Value <= 0.0)
                {
                    Game1.createDebris(12, (int)tileLocation.X, (int)tileLocation.Y, 4, (GameLocation)null);
                    Game1.createRadialDebris(location, 12, (int)tileLocation.X, (int)tileLocation.Y, Game1.random.Next(20, 30), false, -1, false, -1);
                    return(true);
                }
            }
            else if (this.growthStage.Value >= 1)
            {
                if (explosion > 0)
                {
                    return(true);
                }
                location.playSound("cut");
                if (t != null && t.BaseName.Contains("Axe"))
                {
                    location.playSound("axchop");
                    Game1.createRadialDebris(location, 12, (int)tileLocation.X, (int)tileLocation.Y, Game1.random.Next(10, 20), false, -1, false, -1);
                }
                if (t is Axe || t is Pickaxe || (t is Hoe || t is MeleeWeapon))
                {
                    Game1.createRadialDebris(location, 12, (int)tileLocation.X, (int)tileLocation.Y, Game1.random.Next(10, 20), false, -1, false, -1);
                    if (t.BaseName.Contains("Axe") && Game1.recentMultiplayerRandom.NextDouble() < (double)t.getLastFarmerToUse().ForagingLevel / 10.0)
                    {
                        Game1.createDebris(12, (int)tileLocation.X, (int)tileLocation.Y, 1, (GameLocation)null);
                    }
                    //TODO: come back and figure out this sprite broadcasting thing
                    //Game1.multiplayer.broadcastSprites(location, new TemporaryAnimatedSprite(17, tileLocation * 64f, Color.White, 8, false, 100f, 0, -1, -1f, -1, 0));
                    return(true);
                }
            }
            else
            {
                if (explosion > 0)
                {
                    return(true);
                }
                if (t.BaseName.Contains("Axe") || t.BaseName.Contains("Pick") || t.BaseName.Contains("Hoe"))
                {
                    location.playSound("woodyHit");
                    location.playSound("axchop");
                    //TODO: come back and figure out this sprite broadcasting thing
                    //Game1.multiplayer.broadcastSprites(location, new TemporaryAnimatedSprite(17, tileLocation * 64f, Color.White, 8, false, 100f, 0, -1, -1f, -1, 0));
                    int seedIndex = VoidshroomSpore.getIndex();
                    if ((long)this.lastPlayerToHit.Value != 0L && Game1.getFarmer((long)this.lastPlayerToHit.Value).getEffectiveSkillLevel(2) >= 1 && seedIndex != -1)
                    {
                        Game1.createMultipleObjectDebris(seedIndex, (int)tileLocation.X, (int)tileLocation.Y, 1, t.getLastFarmerToUse().UniqueMultiplayerID, location);
                    }
                    else if (Game1.player.getEffectiveSkillLevel(2) >= 1 && seedIndex != -1)
                    {
                        Game1.createMultipleObjectDebris(seedIndex, (int)tileLocation.X, (int)tileLocation.Y, 1, (long)t.getLastFarmerToUse().UniqueMultiplayerID, location);
                    }

                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 9
0
        public override bool tickUpdate(GameTime time, Vector2 tileLocation, GameLocation location)
        {
            if (this.season != Game1.currentSeason)
            {
                this.resetTexture();
                this.season = Game1.currentSeason;
            }
            if ((double)this.shakeTimer > 0.0)
            {
                this.shakeTimer -= (float)time.ElapsedGameTime.Milliseconds;
            }
            if (this.destroy.Value)
            {
                return(true);
            }
            this.alpha = Math.Min(1f, this.alpha + 0.05f);
            if (this.growthStage.Value >= 5 && !this.falling.Value && !this.stump.Value && Game1.player.GetBoundingBox().Intersects(new Microsoft.Xna.Framework.Rectangle(64 * ((int)tileLocation.X - 1), 64 * ((int)tileLocation.Y - 5), 192, 288)))
            {
                this.alpha = Math.Max(0.4f, this.alpha - 0.09f);
            }
            if (!this.falling.Value)
            {
                if ((double)Math.Abs(this.shakeRotation) > Math.PI / 2.0 && this.leaves.Count <= 0 && (double)this.health.Value <= 0.0)
                {
                    return(true);
                }
                if ((double)this.maxShake > 0.0)
                {
                    if (this.shakeLeft.Value)
                    {
                        this.shakeRotation -= this.growthStage.Value >= 5 ? (float)Math.PI / 600f : (float)Math.PI / 200f;
                        if ((double)this.shakeRotation <= -(double)this.maxShake)
                        {
                            this.shakeLeft.Value = false;
                        }
                    }
                    else
                    {
                        this.shakeRotation += this.growthStage.Value >= 5 ? (float)Math.PI / 600f : (float)Math.PI / 200f;
                        if ((double)this.shakeRotation >= (double)this.maxShake)
                        {
                            this.shakeLeft.Value = true;
                        }
                    }
                }
                if ((double)this.maxShake > 0.0)
                {
                    this.maxShake = Math.Max(0.0f, this.maxShake - (this.growthStage.Value >= 5 ? 0.001022654f : 0.003067962f));
                }
            }
            else
            {
                this.shakeRotation += this.shakeLeft.Value ? (float)-((double)this.maxShake * (double)this.maxShake) : this.maxShake * this.maxShake;
                this.maxShake      += 0.001533981f;
                if ((double)Math.Abs(this.shakeRotation) > Math.PI / 2.0)
                {
                    this.falling.Value = false;
                    this.maxShake      = 0.0f;
                    location.localSound("treethud");
                    int num = Game1.random.Next(90, 120);
                    if (Game1.currentLocation.Objects.ContainsKey(tileLocation))
                    {
                        Game1.currentLocation.Objects.Remove(tileLocation);
                    }
                    for (int index = 0; index < num; ++index)
                    {
                        this.leaves.Add(new Leaf(new Vector2((float)(Game1.random.Next((int)((double)tileLocation.X * 64.0), (int)((double)tileLocation.X * 64.0 + 192.0)) + (this.shakeLeft.Value ? -320 : 256)), (float)((double)tileLocation.Y * 64.0 - 64.0)), (float)Game1.random.Next(-10, 10) / 100f, Game1.random.Next(4), (float)Game1.random.Next(10, 40) / 10f));
                    }

                    Game1.createRadialDebris(Game1.currentLocation, 12, (int)tileLocation.X + (((NetFieldBase <bool, NetBool>) this.shakeLeft).Value ? -4 : 4), (int)tileLocation.Y, 12 + this.extraWoodCalculator(tileLocation), true, -1, false, -1);

                    int number = 0;
                    if (Game1.getFarmer(this.lastPlayerToHit.Value) != null)
                    {
                        while (Game1.getFarmer(this.lastPlayerToHit.Value).professions.Contains(14) && Game1.random.NextDouble() < 0.4)
                        {
                            ++number;
                        }
                    }
                    if (number > 0)
                    {
                        Game1.createMultipleObjectDebris(709, (int)tileLocation.X + ((bool)((NetFieldBase <bool, NetBool>) this.shakeLeft).Value ? -4 : 4), (int)tileLocation.Y, number);
                    }
                    //seed dropping code. Revisit if I get spores working.
                    int seedIndex = VoidshroomSpore.getIndex();
                    if (this.lastPlayerToHit.Value != 0L && Game1.getFarmer(this.lastPlayerToHit.Value).getEffectiveSkillLevel(2) >= 1 && (Game1.random.NextDouble() < 0.75 && ((NetFieldBase <int, NetInt>) this.treeType).Value < 4) && seedIndex != -1)
                    {
                        Game1.createMultipleObjectDebris(seedIndex, (int)tileLocation.X + (((NetFieldBase <bool, NetBool>) this.shakeLeft).Value ? -4 : 4), (int)tileLocation.Y, Game1.random.Next(1, 3));
                    }
                    if ((double)this.health.Value == -100.0)
                    {
                        return(true);
                    }
                    if ((double)this.health.Value <= 0.0)
                    {
                        this.health.Value = -100f;
                    }
                }
            }
            for (int index = this.leaves.Count - 1; index >= 0; --index)
            {
                this.leaves.ElementAt <Leaf>(index).position.Y -= this.leaves.ElementAt <Leaf>(index).yVelocity - 3f;
                this.leaves.ElementAt <Leaf>(index).yVelocity   = Math.Max(0.0f, this.leaves.ElementAt <Leaf>(index).yVelocity - 0.01f);
                this.leaves.ElementAt <Leaf>(index).rotation   += this.leaves.ElementAt <Leaf>(index).rotationRate;
                if ((double)this.leaves.ElementAt <Leaf>(index).position.Y >= (double)tileLocation.Y * 64.0 + 64.0)
                {
                    this.leaves.RemoveAt(index);
                }
            }
            return(false);
        }
        public void Edit <T>(IAssetData asset)
        {
            VoidshroomSpore.setIndex(); //get an item index for voidshroom spores if one isn't already set.
            CaveCarrotSeed.setIndex();
            CaveCarrot.setIndex();
            CaveCarrot.setCropIndex();
            if (asset.AssetNameEquals("Maps\\springobjects"))
            {
                IAssetDataForImage editor    = asset.AsImage();
                Texture2D          data      = editor.Data;
                Texture2D          texture2D = new Texture2D(Game1.graphics.GraphicsDevice, data.Width, Math.Max(data.Height, 4096));
                editor.ReplaceWith(texture2D);
                editor.PatchImage(data, new Rectangle?(), new Rectangle?(), PatchMode.Replace);
                try
                {
                    editor.PatchImage(TextureSet.voidShroomSpore, new Rectangle?(), new Rectangle?(this.objectRect(VoidshroomSpore.getIndex())), PatchMode.Replace);
                    editor.PatchImage(TextureSet.caveCarrotSeed, new Rectangle?(), new Rectangle?(this.objectRect(CaveCarrotSeed.getIndex())), PatchMode.Replace);
                }
                catch (Exception)
                {
                }
            }
            else if (asset.AssetNameEquals("Data\\ObjectInformation"))
            {
                IAssetDataForDictionary <int, string> editor = asset.AsDictionary <int, string>();

                IDictionary <int, string> data = editor.Data;
                if (!data.ContainsKey(VoidshroomSpore.getIndex()))
                {
                    int    voidShroomSporeIndex = VoidshroomSpore.getIndex();
                    String voidShroomSpore      = VoidshroomSpore.getObjectData();
                    this.log("Add voidshroom spore object data: " + voidShroomSporeIndex + ": " + voidShroomSpore);
                    data.Add(voidShroomSporeIndex, voidShroomSpore);
                }

                if (!data.ContainsKey(CaveCarrotSeed.getIndex()))
                {
                    int    caveCarrotSeedIndex = CaveCarrotSeed.getIndex();
                    String caveCarrotObject    = CaveCarrotSeed.getObjectData();
                    this.log("Add cave carrot seed object data: " + caveCarrotSeedIndex + ": " + caveCarrotObject);
                    data.Add(caveCarrotSeedIndex, caveCarrotObject);
                }

                if (!data.ContainsKey(CaveCarrotFlower.getIndex()))
                {
                    int    caveCarrotFlowerIndex  = CaveCarrotFlower.getIndex();
                    String caveCarrotFlowerObject = CaveCarrotFlower.getObjectData();
                    this.log("Add cave carrot flower 'seed' data: " + caveCarrotFlowerIndex + ": " + caveCarrotFlowerObject);
                    data.Add(caveCarrotFlowerIndex, caveCarrotFlowerObject);
                }
            }
            else if (asset.AssetNameEquals("Data\\Crops"))
            {
                IAssetDataForDictionary <int, string> editor = asset.AsDictionary <int, string>();
                IDictionary <int, string>             data   = editor.Data;

                int seedIndex = CaveCarrot.getIndex();
                this.log("seedIndex is: " + seedIndex);
                if (!data.ContainsKey(seedIndex))
                {
                    String cropData = CaveCarrot.getCropData();
                    this.monitor.Log("Loading crop data: " + cropData);
                    data.Add(CaveCarrot.getIndex(), cropData);
                }

                int caveCarrotFlowerIndex = CaveCarrotFlower.getIndex();
                this.log("seedIndex is: " + caveCarrotFlowerIndex);
                if (!data.ContainsKey(caveCarrotFlowerIndex))
                {
                    String cropData = CaveCarrotFlower.getCropData();
                    this.monitor.Log("Loading crop data: " + cropData);
                    data.Add(caveCarrotFlowerIndex, cropData);
                }
            }
            else if (asset.AssetNameEquals("TileSheets\\crops"))
            {
                IAssetDataForImage editor    = asset.AsImage();
                Texture2D          data      = editor.Data;
                Texture2D          texture2D = new Texture2D(Game1.graphics.GraphicsDevice, data.Width, Math.Max(data.Height, 4096));
                editor.ReplaceWith(texture2D);
                editor.PatchImage(data, new Rectangle?(), new Rectangle?(), PatchMode.Replace);
                try
                {
                    int index = CaveCarrot.getCropIndex();
                    this.monitor.Log("Loading cave carrot crop texture.  Crop index: " + index);
                    editor.PatchImage(TextureSet.caveCarrotCrop, new Rectangle?(), new Rectangle?(this.cropRect(index)), PatchMode.Replace);

                    index = CaveCarrotFlower.getCropIndex();
                    this.monitor.Log("Loading cave carrot flower crop texture.  Crop index: " + index);
                    editor.PatchImage(TextureSet.caveCarrotFlowerCrop, new Rectangle?(), new Rectangle?(this.cropRect(index)), PatchMode.Replace);
                }
                catch (Exception)
                {
                }
            }
        }
Ejemplo n.º 11
0
        private void SpawnVoidshroomTrees(MineShaft loc)
        {
            this.Monitor.Log("Process voidshroom tree spawning for " + loc.Name);
            String floorText   = loc.Name.Substring(15);
            int    floorNumber = 0;

            if (int.TryParse(floorText, out floorNumber))
            {
                if (floorNumber < 120)
                {
                    int    floorsAbove90                = floorNumber - 90;
                    double extraStoneChance             = floorsAbove90 * STONE_INCREASE_PER_LEVEL;
                    double stoneChanceToChange          = STONE_BASE_CHANCE_TO_CHANGE + extraStoneChance;
                    double extraPurpleMushroomChance    = floorsAbove90 * PURPLE_MUSHROOM_INCREASE_PER_LEVEL;
                    double purpleMushroomChanceToChange = PURPLE_MUSHROOM_CHANCE_TO_CHANGE + extraPurpleMushroomChance;
                    double extraRedMushroomChance       = floorsAbove90 * RED_MUSHROOM_INCREASE_PER_LEVEL;
                    double redMushroomChanceToChange    = RED_MUSHROOM_CHANCE_TO_CHANGE + extraRedMushroomChance;

                    List <Vector2> toReplace = new List <Vector2>();

                    //only proceed if there is a chance of something actually changing into a mushroom tree. For red mushrooms this chance starts at level 70, for purple mushrooms it starts at 80 and for rocks it starts at 90
                    if (stoneChanceToChange >= 0 || purpleMushroomChanceToChange >= 0 || redMushroomChanceToChange >= 0)
                    {
                        Vector2 origin = new Vector2(0, 0);

                        if (loc.Objects.ContainsKey(origin))
                        {
                            if (loc.Objects[origin] is LoadMarker)
                            {
                                this.Monitor.Log("We've probably already hit this floor (" + loc.Name + "). Skip processing for voidshroom trees.");
                                return;
                            }
                            else
                            {
                                this.Monitor.Log("We didn't have a load marker for (" + loc.Name + "), but something was sitting at 0,0. Figure out what it was!");
                            }
                        }
                        else
                        {
                            //we haven't processed this floor probably, so go ahead and do so and add a marker object so A) we know it's been done and B) when the floor resets we'll process again next time we visit.
                            this.Monitor.Log("We haven't processed before. Add marker to 0,0 on (" + loc.Name + ")");
                            loc.Objects.Add(origin, new LoadMarker());
                        }

                        //if we've already populated this mine level today, don't do so again.

                        /*
                         * if (ModState.visitedMineshafts.Contains(loc.Name))
                         * {
                         *  this.Monitor.Log(loc.Name + " was already visited and populated with voidshroom trees today.");
                         *  return;
                         * }
                         */

                        //ModState.visitedMineshafts.Add(loc.Name);

                        foreach (StardewValley.Object o in loc.Objects.Values)
                        {
                            double hit = Game1.random.NextDouble();
                            if (o.Name == "Stone" && hit <= stoneChanceToChange)
                            {
                                toReplace.Add(o.TileLocation);
                            }
                            else if (o.ParentSheetIndex == 420 && hit <= redMushroomChanceToChange)
                            {
                                toReplace.Add(o.TileLocation);
                            }
                            else if (o.ParentSheetIndex == 422 && hit <= purpleMushroomChanceToChange)
                            {
                                toReplace.Add(o.TileLocation);
                            }
                        }

                        this.Monitor.Log(loc.Name + " found " + toReplace.Count + " places to put a voidshroom tree.");

                        foreach (Vector2 location in toReplace)
                        {
                            //removing objects is a bad plan, since it screws with other mods that iterate through the objects list.  Replace this to instead search out from the location for an empty spot to place a tree.
                            bool foundSpot = false;
                            for (int i = -1; i <= 1 && !foundSpot; i++)
                            {
                                for (int j = -1; j <= 1 && !foundSpot; j++)
                                {
                                    if (i != 0 || j != 0)
                                    {
                                        Vector2 spotToCheck = new Vector2(location.X + i, location.Y + j);
                                        bool    validSpot   = VoidshroomSpore.canPlaceHere(loc, spotToCheck, true);
                                        if (validSpot)
                                        {
                                            this.Monitor.Log("Found an empty spot to put the tree." + spotToCheck);
                                            foundSpot = true;
                                            loc.terrainFeatures.Add(spotToCheck, (TerrainFeature) new VoidshroomTree(Game1.random.Next(4, 6)));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 12
0
 private bool isModItem(Item currentItem)
 {
     return(currentItem != null && (currentItem.ParentSheetIndex == VoidshroomSpore.getIndex() || currentItem.ParentSheetIndex == CaveCarrotSeed.getIndex()));
 }
Ejemplo n.º 13
0
        private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
        {
            if (isGameReady())
            {
                Item    currentItem = Game1.player.CurrentItem;
                Vector2 tile        = e.Cursor.GrabTile;
                if (e.Button.IsActionButton() || e.Button.IsUseToolButton())
                {
                    GameLocation location = Game1.currentLocation;

                    if (location.terrainFeatures.ContainsKey(tile) && location.terrainFeatures[tile] is HoeDirt)
                    {
                        HoeDirt dirtPatch = location.terrainFeatures[tile] as HoeDirt;
                        if (dirtPatch.crop != null && this.isModCrop(dirtPatch.crop))
                        {
                            int X = (int)tile.X;
                            int Y = (int)tile.Y;
                            if (e.Button.IsActionButton())
                            {
                                dirtPatch.performUseAction(tile, location);
                            }
                            else if (e.Button.IsUseToolButton())
                            {
                                Tool tool = Game1.player.CurrentItem as Tool;
                                dirtPatch.performToolAction(tool, 0, tile, location);
                                dirtPatch.performUseAction(tile, location);
                            }

                            if (dirtPatch.crop == null)
                            {
                                location.terrainFeatures.Remove(tile);
                                return;
                            }
                        }
                    }

                    if (e.Button.IsActionButton())
                    {
                        if (currentItem != null && (this.isModItem(currentItem) || PlantableCaveCarrot.IsValidLocation(location)))
                        {
                            if (currentItem.ParentSheetIndex.Equals(CaveCarrot.HARVEST_INDEX))
                            {
                                this.Monitor.Log("Attempt to plant a cave carrot flower at " + tile.ToString());
                                bool planted = PlantableCaveCarrot.AttemptPlanting(tile, location);
                                if (planted)
                                {
                                    Game1.player.reduceActiveItemByOne();
                                    this.Helper.Input.Suppress(e.Button);
                                    return;
                                }
                            }
                            else if (currentItem.ParentSheetIndex.Equals(VoidshroomSpore.getIndex()))
                            {
                                this.Monitor.Log("Attempt to plant a new voidshroom tree at " + e.Cursor.GrabTile.ToString());
                                bool planted = VoidshroomSpore.AttemptPlanting(tile, Game1.currentLocation);
                                if (planted)
                                {
                                    Game1.player.reduceActiveItemByOne();
                                    return;
                                }
                            }
                            else if (currentItem.ParentSheetIndex.Equals(CaveCarrotSeed.getIndex()))
                            {
                                this.Monitor.Log("Attempt to plant a cave carrot at " + e.Cursor.GrabTile.ToString());
                                bool planted = CaveCarrotSeed.AttemptPlanting(tile, Game1.currentLocation, Game1.player);
                                if (planted)
                                {
                                    Game1.player.reduceActiveItemByOne();
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 14
0
 public VoidshroomDataInjector(IMonitor monitor)
 {
     this.monitor = monitor;
     VoidshroomSpore.setIndex(); //get an item index for voidshroom spores if one isn't already set.
     this.spore = new VoidshroomSpore();
 }