Esempio n. 1
0
 public void RemoveExitLocation(Location tile)
 {
     additionalExitLocations.Remove(new Vector2(tile.X, tile.Y));
 }
Esempio n. 2
0
        public override void DayUpdate(int dayOfMonth)
        {
            {
                // skip Farm.dayUpdate, call BuildableGameLocation.dayUpdate and anything further
                // up the chain of inheritance.
                // Don't try this at home, kids, this is ultimate example of how NOT to do things.
                // thanks to https://stackoverflow.com/a/32562464 for this ugly workaround.
                var ptr = typeof(BuildableGameLocation).GetMethod("DayUpdate").MethodHandle.GetFunctionPointer();
                var grandparentDayUpdate = (Action <int>)Activator.CreateInstance(typeof(Action <int>), this, ptr);
                grandparentDayUpdate(dayOfMonth);
            }

            for (int index = this.animals.Count() - 1; index >= 0; --index)
            {
                this.animals.Pairs.ElementAt <KeyValuePair <long, FarmAnimal> >(index).Value.dayUpdate((GameLocation)this);
            }

            /*if (Game1.whichFarm == 4 && !Game1.player.mailReceived.Contains("henchmanGone"))
             * {
             *  Game1.spawnMonstersAtNight = true;
             * }*/
            this.lastItemShipped = null;
            for (int index = this.characters.Count - 1; index >= 0; --index)
            {
                if (this.characters[index] is JunimoHarvester)
                {
                    this.characters.RemoveAt(index);
                }
            }
            for (int index = this.characters.Count - 1; index >= 0; --index)
            {
                if (this.characters[index] is Monster && (this.characters[index] as Monster).wildernessFarmMonster)
                {
                    this.characters.RemoveAt(index);
                }
            }
            if (this.characters.Count > 5)
            {
                int num = 0;
                for (int index = this.characters.Count - 1; index >= 0; --index)
                {
                    if (this.characters[index] is GreenSlime && Game1.random.NextDouble() < 0.035)
                    {
                        this.characters.RemoveAt(index);
                        ++num;
                    }
                }
                if (num > 0)
                {
                    Game1.showGlobalMessage(Game1.content.LoadString(num == 1 ? "Strings\\Locations:Farm_1SlimeEscaped" : "Strings\\Locations:Farm_NSlimesEscaped", (object)num));
                }
            }
            // stuff for handling specific Game1.whichFarm (hardwood stump/geode spawning) - ommited, doesn't concern expansion

            ICollection <Vector2> source = (ICollection <Vector2>) new List <Vector2>(this.terrainFeatures.Keys);

            for (int index = source.Count - 1; index >= 0; --index)
            {
                if (this.terrainFeatures[source.ElementAt <Vector2>(index)] is HoeDirt && (this.terrainFeatures[source.ElementAt <Vector2>(index)] as HoeDirt).crop == null && Game1.random.NextDouble() <= 0.1)
                {
                    this.terrainFeatures.Remove(source.ElementAt <Vector2>(index));
                }
            }
            if (this.terrainFeatures.Count() > 0 && Game1.currentSeason.Equals("fall") && (Game1.dayOfMonth > 1 && Game1.random.NextDouble() < 0.05))
            {
                for (int index = 0; index < 10; ++index)
                {
                    TerrainFeature terrainFeature = this.terrainFeatures.Pairs.ElementAt <KeyValuePair <Vector2, TerrainFeature> >(Game1.random.Next(this.terrainFeatures.Count())).Value;
                    if (terrainFeature is Tree && (int)((NetFieldBase <int, NetInt>)(terrainFeature as Tree).growthStage) >= 5 && !(bool)((NetFieldBase <bool, NetBool>)(terrainFeature as Tree).tapped))
                    {
                        (terrainFeature as Tree).treeType.Value = 7;
                        (terrainFeature as Tree).loadSprite();
                        break;
                    }
                }
            }
            if (this.framework.config.enableCrows)
            {
                this.addCrows();
            }
            if (!Game1.currentSeason.Equals("winter"))
            {
                spawnWeedsAndStones(Game1.currentSeason.Equals("summer") ? 30 : 20, false, true);
            }
            spawnWeeds(false);
            if (dayOfMonth == 1)
            {
                for (int index = this.terrainFeatures.Count() - 1; index >= 0; --index)
                {
                    KeyValuePair <Vector2, TerrainFeature> keyValuePair = this.terrainFeatures.Pairs.ElementAt <KeyValuePair <Vector2, TerrainFeature> >(index);
                    if (keyValuePair.Value is HoeDirt)
                    {
                        keyValuePair = this.terrainFeatures.Pairs.ElementAt <KeyValuePair <Vector2, TerrainFeature> >(index);
                        if ((keyValuePair.Value as HoeDirt).crop == null && Game1.random.NextDouble() < 0.8)
                        {
                            NetVector2Dictionary <TerrainFeature, NetRef <TerrainFeature> > terrainFeatures = this.terrainFeatures;
                            keyValuePair = this.terrainFeatures.Pairs.ElementAt <KeyValuePair <Vector2, TerrainFeature> >(index);
                            Vector2 key = keyValuePair.Key;
                            terrainFeatures.Remove(key);
                        }
                    }
                }
                spawnWeedsAndStones(20, false, false);
                if (Game1.currentSeason.Equals("spring") && Game1.stats.DaysPlayed > 1U)
                {
                    spawnWeedsAndStones(40, false, false);
                    spawnWeedsAndStones(40, true, false);
                    for (int index = 0; index < 15; ++index)
                    {
                        int     xTile   = Game1.random.Next(this.map.DisplayWidth / 64);
                        int     yTile   = Game1.random.Next(this.map.DisplayHeight / 64);
                        Vector2 vector2 = new Vector2((float)xTile, (float)yTile);
                        Object  @object;
                        this.objects.TryGetValue(vector2, out @object);
                        if (@object == null && this.doesTileHaveProperty(xTile, yTile, "Diggable", "Back") != null && (this.isTileLocationOpen(new Location(xTile * 64, yTile * 64)) && !this.isTileOccupied(vector2, "")) && this.doesTileHaveProperty(xTile, yTile, "Water", "Back") == null)
                        {
                            this.terrainFeatures.Add(vector2, (TerrainFeature) new Grass(1, 4));
                        }
                    }
                    this.growWeedGrass(40);
                }
            }
            base.growWeedGrass(1);
        }