Пример #1
0
        private NetCollection <NPC> GetVillagers()
        {
            var allNpcs      = new NetCollection <NPC>();
            var locationList = Context.IsMainPlayer
                                ? this.Helper.Multiplayer.GetActiveLocations().Concat(Game1.locations)
                                : this.Helper.Multiplayer.GetActiveLocations();

            foreach (GameLocation location in locationList)
            {
                foreach (NPC npc in location.characters)
                {
                    if (npc == null)
                    {
                        continue;
                    }
                    if (!allNpcs.Contains(npc) &&
                        !ModConstants.ExcludedVillagers.Contains(npc.Name) &&
                        npc.isVillager())
                    {
                        allNpcs.Add(npc);
                    }
                }
            }

            return(allNpcs);
        }
Пример #2
0
 private void ButtonPressed(object sender, ButtonPressedEventArgs e)
 {
     if (e.Button == this.Config.UpdateGreenhouses && Context.IsMainPlayer)
     {
         NetCollection <Building> ToBuild = new NetCollection <Building>();
         foreach (Building building in Game1.getFarm().buildings)
         {
             bool create = true;
             if (building.buildingType.Value.Contains("Cabin"))
             {
                 foreach (Building greenhouse in Game1.getFarm().buildings)
                 {
                     if (greenhouse.buildingType.Value.Equals("Greenhouse") && greenhouse.owner.Value == (building.indoors.Value as Cabin).getFarmhand().Value.UniqueMultiplayerID)
                     {
                         create = false;
                         break;
                     }
                 }
                 if (create)
                 {
                     ToBuild.Add(CreateGreenhouse(building));
                 }
             }
         }
         foreach (Building building in ToBuild)
         {
             Game1.getFarm().buildings.Add(building);
         }
         Game1.chatBox.addMessage("Greanhouses Created: " + ToBuild.Count.ToString(), Color.White);
         NetCollection <Building> ToDestroy = new NetCollection <Building>();
         foreach (Building building in Game1.getFarm().buildings)
         {
             bool destroy = true;
             if (building.buildingType.Value.Equals("Greenhouse"))
             {
                 foreach (Building cabin in Game1.getFarm().buildings)
                 {
                     if (cabin.buildingType.Value.Contains("Cabin") && building.owner.Value == (cabin.indoors.Value as Cabin).getFarmhand().Value.UniqueMultiplayerID)
                     {
                         destroy = false;
                         break;
                     }
                 }
                 if (destroy)
                 {
                     ToDestroy.Add(building);
                 }
             }
         }
         foreach (Building building in ToDestroy)
         {
             Game1.getFarm().buildings.Remove(building);
         }
         Game1.chatBox.addMessage("Greanhouses Removed: " + ToBuild.Count.ToString(), Color.White);
     }
 }
Пример #3
0
            public static void ReplaceProjectile(NetCollection <Projectile> projectiles, Projectile original)
            {
                //Log.Debug($"RSV: Entered transpiler, woohoo!");
                NetCharacterRef firerInfo = Helper.Reflection.GetField <NetCharacterRef>(original, "theOneWhoFiredMe").GetValue();
                Monster         monster   = (Monster)firerInfo.Get(Game1.currentLocation);

                try
                {
                    if (monster.modData["RSV_bloomDebuff"] != "true")
                    {
                        projectiles.Add(original);
                        return;
                    }
                }
                catch
                {
                    projectiles.Add(original);
                    return;
                }
                float xVelocity = Helper.Reflection.GetField <NetFloat>(original, "xVelocity").GetValue().Value;
                float yVelocity = Helper.Reflection.GetField <NetFloat>(original, "yVelocity").GetValue().Value;

                monster.currentLocation.projectiles.Add(new MistProjectile(rotation, xVelocity, yVelocity, monster.Position + new Vector2(0f, -32f), monster.currentLocation, monster));
            }
Пример #4
0
        private void SaveCreating(object sender, SaveCreatingEventArgs e)
        {
            NetCollection <Building> ToBuild = new NetCollection <Building>();

            foreach (Building building in Game1.getFarm().buildings)
            {
                if (building.buildingType.Value.Contains("Cabin"))
                {
                    ToBuild.Add(CreateGreenhouse(building));
                }
            }
            foreach (Building building in ToBuild)
            {
                Game1.getFarm().buildings.Add(building);
            }
            Game1.chatBox.addMessage("Greanhouses Created: " + ToBuild.Count.ToString(), Color.White);
        }
Пример #5
0
        private NetCollection <NPC> GetAllVillagers()
        {
            var allNPCs = new NetCollection <NPC>();

            foreach (GameLocation location in Game1.locations)
            {
                foreach (NPC npc in location.characters)
                {
                    if (npc == null)
                    {
                        continue;
                    }
                    if (!allNPCs.Contains(npc) &&
                        !ModConstants.ExcludedVillagers.Contains(npc.Name) &&
                        npc.isVillager())
                    {
                        allNPCs.Add(npc);
                    }
                }
            }
            return(allNPCs);
        }
Пример #6
0
 public void NewDay()
 {
     if (Game1.IsClient)
     {
         return;
     }
     readyChecks.Clear();
     luauIngredients.Clear();
     if (grangeDisplay.Count > 0)
     {
         for (int i = 0; i < grangeDisplay.Count; i++)
         {
             Item item = grangeDisplay[i];
             grangeDisplay[i] = null;
             if (item != null)
             {
                 returnedDonations.Add(item);
                 newLostAndFoundItems.Value = true;
             }
         }
     }
     grangeDisplay.Clear();
     movieInvitations.Clear();
 }
Пример #7
0
        private IEnumerable <NPC> GetCharacters()
        {
            var n = new NetCollection <NPC>();

            foreach (var variable in Game1.currentLocation.characters)
            {
                if (Config.RenderMonster && variable is Monster)
                {
                    n.Add(variable);
                }
                else if (Config.RenderPet && variable is Pet)
                {
                    n.Add(variable);
                }
                else if (Config.RenderHorse && variable is Horse)
                {
                    n.Add(variable);
                }
                else if (variable is TrashBear)
                {
                }
                else if (Config.RenderJunimo && variable is Junimo)
                {
                    n.Add(variable);
                }
                else if (variable is JunimoHarvester)
                {
                }
                else if (Config.RenderChild && variable is Child)
                {
                    n.Add(variable);
                }
                else if (Config.RenderVillager && !(variable is Monster) && !(variable is Pet) &&
                         !(variable is Horse) && !(variable is Junimo) && !(variable is Child))
                {
                    n.Add(variable);
                }
            }

            return(n);
        }
Пример #8
0
        public override bool onRelease(GameLocation location, int x, int y, Farmer who)
        {
            usingBow[who] = false;

            if (this.attachments[0] != null)
            {
                StardewValley.Object one = (StardewValley.Object) this.attachments[0].getOne();
                --this.attachments[0].Stack;
                if (this.attachments[0].Stack <= 0)
                {
                    this.attachments[0] = (StardewValley.Object)null;
                }
                int x1 = this.AimingAt.X;
                int y1 = this.AimingAt.Y;
                //int num1 = Math.Min(20, (int)Vector2.Distance(new Vector2((float)who.getStandingX(), (float)(who.getStandingY() - 64)), new Vector2((float)x1, (float)y1)) / 20);
                Vector2 velocityTowardPoint = Utility.getVelocityTowardPoint(new Point(who.getStandingX(), who.getStandingY() + 64), new Vector2((float)x1, (float)(y1 + 64)), (float)(15 + Game1.random.Next(4, 6)) * (1f + who.weaponSpeedModifier));
                //int num2 = 4;
                int heldLen = UseTime.Value;
                velocityTowardPoint *= heldLen / 100f;

                //if (num1 > num2 && !this.canPlaySound)
                {
                    int num3 = 1;
                    BasicProjectile.onCollisionBehavior collisionBehavior = (BasicProjectile.onCollisionBehavior)null;
                    string collisionSound = "hammer";
                    float  num4           = 2;
                    switch (one.ParentSheetIndex)
                    {
                    case 378:
                        num3 = 10;
                        ++one.ParentSheetIndex;
                        break;

                    case 380:
                        num3 = 20;
                        ++one.ParentSheetIndex;
                        break;

                    case 382:
                        num3 = 15;
                        ++one.ParentSheetIndex;
                        break;

                    case 384:
                        num3 = 30;
                        ++one.ParentSheetIndex;
                        break;

                    case 386:
                        num3 = 50;
                        ++one.ParentSheetIndex;
                        break;

                    case 388:
                        num3 = 2;
                        ++one.ParentSheetIndex;
                        break;

                    case 390:
                        num3 = 5;
                        ++one.ParentSheetIndex;
                        break;

                    case 441:
                        num3 = 20;
                        collisionBehavior = new BasicProjectile.onCollisionBehavior(BasicProjectile.explodeOnImpact);
                        collisionSound    = "explosion";
                        break;
                    }
                    if (one.Category == -5)
                    {
                        collisionSound = "slimedead";
                    }
                    NetCollection <Projectile> projectiles     = location.projectiles;
                    BasicProjectile            basicProjectile = new BasicProjectile((int)((double)num4 * (double)(num3 + Game1.random.Next(-(num3 / 2), num3 + 2)) * (1.0 + (double)who.attackIncreaseModifier)), one.ParentSheetIndex, 0, 0, (float)(Math.PI / (64.0 + (double)Game1.random.Next(-63, 64))), velocityTowardPoint.X, velocityTowardPoint.Y, new Vector2((float)(who.getStandingX() - 16), (float)(who.getStandingY() - 64 - 8)), collisionSound, "", false, true, location, (Character)who, true, collisionBehavior);
                    basicProjectile.IgnoreLocationCollision = Game1.currentLocation.currentEvent != null;
                    projectiles.Add((Projectile)basicProjectile);
                }
            }
            else
            {
                Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Slingshot.cs.14254"));
            }
            return(true);
        }
Пример #9
0
        public override void DoFunction(GameLocation location, int x, int y, int power, Farmer who)
        {
            //base.DoFunction(location, x, y, power, who);
            if (this.GetEnergyManager().hasEnoughEnergy(this.getEnergyConsumptionRate()) == true)
            {
            }
            else
            {
                Game1.showRedMessage("Out of energy!");
                return;
            }
            this.baseDoFunction(location, x, y, power, who);
            power = who.toolPower;
            //who.Stamina -= (float)(2 * (power + 1)) - (float)who.MiningLevel * 0.1f;
            //Drain energy here;
            this.GetEnergyManager().consumeEnergy(this.getEnergyConsumptionRate());
            //Double check to prevent animation from happening with even no power


            Utility.clampToTile(new Vector2((float)x, (float)y));
            int     num1  = x / 64;
            int     num2  = y / 64;
            Vector2 index = new Vector2((float)num1, (float)num2);

            if (location.performToolAction((Tool)this, num1, num2))
            {
                return;
            }
            StardewValley.Object @object = (StardewValley.Object)null;
            location.Objects.TryGetValue(index, out @object);
            if (@object == null)
            {
                if (who.FacingDirection == 0 || who.FacingDirection == 2)
                {
                    num1 = (x - 8) / 64;
                    location.Objects.TryGetValue(new Vector2((float)num1, (float)num2), out @object);
                    if (@object == null)
                    {
                        num1 = (x + 8) / 64;
                        location.Objects.TryGetValue(new Vector2((float)num1, (float)num2), out @object);
                    }
                }
                else
                {
                    num2 = (y + 8) / 64;
                    location.Objects.TryGetValue(new Vector2((float)num1, (float)num2), out @object);
                    if (@object == null)
                    {
                        num2 = (y - 8) / 64;
                        location.Objects.TryGetValue(new Vector2((float)num1, (float)num2), out @object);
                    }
                }
                x = num1 * 64;
                y = num2 * 64;
                if (location.terrainFeatures.ContainsKey(index) && location.terrainFeatures[index].performToolAction((Tool)this, 0, index, location))
                {
                    location.terrainFeatures.Remove(index);
                }
            }
            index = new Vector2((float)num1, (float)num2);
            if (@object != null)
            {
                if (@object.Name.Equals("Stone"))
                {
                    location.playSound("hammer");
                    if (@object.MinutesUntilReady > 0)
                    {
                        int num3 = Math.Max(1, this.UpgradeLevel + 1);
                        @object.MinutesUntilReady -= num3;
                        @object.shakeTimer         = 200;
                        if (@object.MinutesUntilReady > 0)
                        {
                            Game1.createRadialDebris(Game1.currentLocation, 14, num1, num2, Game1.random.Next(2, 5), false, -1, false, -1);
                            return;
                        }
                    }
                    if (@object.ParentSheetIndex < 200 && !Game1.objectInformation.ContainsKey(@object.ParentSheetIndex + 1))
                    {
                        MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(@object.ParentSheetIndex + 1, 300f, 1, 2, new Vector2((float)(x - x % 64), (float)(y - y % 64)), true, @object.Flipped)
                        {
                            alphaFade = 0.01f
                        });
                    }
                    else
                    {
                        MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(47, new Vector2((float)(num1 * 64), (float)(num2 * 64)), Color.Gray, 10, false, 80f, 0, -1, -1f, -1, 0));
                    }
                    Game1.createRadialDebris(location, 14, num1, num2, Game1.random.Next(2, 5), false, -1, false, -1);
                    MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(46, new Vector2((float)(num1 * 64), (float)(num2 * 64)), Color.White, 10, false, 80f, 0, -1, -1f, -1, 0)
                    {
                        motion       = new Vector2(0.0f, -0.6f),
                        acceleration = new Vector2(0.0f, 1f / 500f),
                        alphaFade    = 0.015f
                    });
                    if (!location.Name.StartsWith("UndergroundMine"))
                    {
                        if (@object.ParentSheetIndex == 343 || @object.ParentSheetIndex == 450)
                        {
                            Random random = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame / 2 + num1 * 2000 + num2);
                            if (random.NextDouble() < 0.035 && Game1.stats.DaysPlayed > 1U)
                            {
                                Game1.createObjectDebris(535 + (Game1.stats.DaysPlayed <= 60U || random.NextDouble() >= 0.2 ? (Game1.stats.DaysPlayed <= 120U || random.NextDouble() >= 0.2 ? 0 : 2) : 1), num1, num2, this.getLastFarmerToUse().UniqueMultiplayerID);
                            }
                            if (random.NextDouble() < 0.035 * (who.professions.Contains(21) ? 2.0 : 1.0) && Game1.stats.DaysPlayed > 1U)
                            {
                                Game1.createObjectDebris(382, num1, num2, this.getLastFarmerToUse().UniqueMultiplayerID);
                            }
                            if (random.NextDouble() < 0.01 && Game1.stats.DaysPlayed > 1U)
                            {
                                Game1.createObjectDebris(390, num1, num2, this.getLastFarmerToUse().UniqueMultiplayerID);
                            }
                        }
                        Revitalize.ModCore.ModHelper.Reflection.GetMethod(location, "breakStone").Invoke(@object.ParentSheetIndex, num1, num2, who, new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame / 2 + num1 * 4000 + num2));
                    }
                    else
                    {
                        Game1.mine.checkStoneForItems(@object.ParentSheetIndex, num1, num2, who);
                    }
                    if (@object.MinutesUntilReady > 0)
                    {
                        return;
                    }
                    location.Objects.Remove(new Vector2((float)num1, (float)num2));
                    location.playSound("stoneCrack");
                    ++Game1.stats.RocksCrushed;
                }
                else if (@object.Name.Contains("Boulder"))
                {
                    location.playSound("hammer");
                    if (this.UpgradeLevel < 2)
                    {
                        Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Pickaxe.cs.14194")));
                    }
                    else
                    {
                        if (num1 == this.boulderTileX && num2 == this.boulderTileY)
                        {
                            this.hitsToBoulder += power + 1;
                            @object.shakeTimer  = 190;
                        }
                        else
                        {
                            this.hitsToBoulder = 0;
                            this.boulderTileX  = num1;
                            this.boulderTileY  = num2;
                        }
                        if (this.hitsToBoulder < 4)
                        {
                            return;
                        }
                        location.removeObject(index, false);
                        MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(5, new Vector2((float)(64.0 * (double)index.X - 32.0), (float)(64.0 * ((double)index.Y - 1.0))), Color.Gray, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0)
                        {
                            delayBeforeAnimationStart = 0
                        });
                        MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(5, new Vector2((float)(64.0 * (double)index.X + 32.0), (float)(64.0 * ((double)index.Y - 1.0))), Color.Gray, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0)
                        {
                            delayBeforeAnimationStart = 200
                        });
                        MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(5, new Vector2(64f * index.X, (float)(64.0 * ((double)index.Y - 1.0) - 32.0)), Color.Gray, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0)
                        {
                            delayBeforeAnimationStart = 400
                        });
                        MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(5, new Vector2(64f * index.X, (float)(64.0 * (double)index.Y - 32.0)), Color.Gray, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0)
                        {
                            delayBeforeAnimationStart = 600
                        });
                        MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(25, new Vector2(64f * index.X, 64f * index.Y), Color.White, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, 128, 0));
                        MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(25, new Vector2((float)(64.0 * (double)index.X + 32.0), 64f * index.Y), Color.White, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, 128, 0)
                        {
                            delayBeforeAnimationStart = 250
                        });
                        MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(25, new Vector2((float)(64.0 * (double)index.X - 32.0), 64f * index.Y), Color.White, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, 128, 0)
                        {
                            delayBeforeAnimationStart = 500
                        });
                        location.playSound("boulderBreak");
                        ++Game1.stats.BouldersCracked;
                    }
                }
                else
                {
                    if ([email protected]((Tool)this, location))
                    {
                        return;
                    }
                    @object.performRemoveAction(index, location);
                    if (@object.Type.Equals((object)"Crafting") && @object.Fragility != 2)
                    {
                        NetCollection <Debris> debris1 = Game1.currentLocation.debris;
                        int       objectIndex          = @object.bigCraftable.Value ? [email protected] : @object.ParentSheetIndex;
                        Vector2   toolLocation         = who.GetToolLocation(false);
                        Rectangle boundingBox          = who.GetBoundingBox();
                        double    x1 = (double)boundingBox.Center.X;
                        boundingBox = who.GetBoundingBox();
                        double  y1             = (double)boundingBox.Center.Y;
                        Vector2 playerPosition = new Vector2((float)x1, (float)y1);
                        Debris  debris2        = new Debris(objectIndex, toolLocation, playerPosition);
                        debris1.Add(debris2);
                    }
                    Game1.currentLocation.Objects.Remove(index);
                }
            }
            else
            {
                location.playSound("woodyHit");
                if (location.doesTileHaveProperty(num1, num2, "Diggable", "Back") == null)
                {
                    return;
                }
                MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(12, new Vector2((float)(num1 * 64), (float)(num2 * 64)), Color.White, 8, false, 80f, 0, -1, -1f, -1, 0)
                {
                    alphaFade = 0.015f
                });
            }
        }
 public bool buildStructure(Building b, Vector2 tileLocation, Farmer who, bool skipSafetyChecks = false)
 {
     if (!skipSafetyChecks)
     {
         for (int y = 0; y < (int)b.tilesHigh; y++)
         {
             for (int x = 0; x < (int)b.tilesWide; x++)
             {
                 pokeTileForConstruction(new Vector2(tileLocation.X + (float)x, tileLocation.Y + (float)y));
             }
         }
         for (int y2 = 0; y2 < (int)b.tilesHigh; y2++)
         {
             for (int x2 = 0; x2 < (int)b.tilesWide; x2++)
             {
                 Vector2 currentGlobalTilePosition = new Vector2(tileLocation.X + (float)x2, tileLocation.Y + (float)y2);
                 if (!buildings.Contains(b) || !b.occupiesTile(currentGlobalTilePosition))
                 {
                     if (!isBuildable(currentGlobalTilePosition))
                     {
                         return(false);
                     }
                     foreach (Farmer farmer in farmers)
                     {
                         if (farmer.GetBoundingBox().Intersects(new Microsoft.Xna.Framework.Rectangle(x2 * 64, y2 * 64, 64, 64)))
                         {
                             return(false);
                         }
                     }
                 }
             }
         }
         if (b.humanDoor.Value != new Point(-1, -1))
         {
             Vector2 doorPos = tileLocation + new Vector2(b.humanDoor.X, b.humanDoor.Y + 1);
             if ((!buildings.Contains(b) || !b.occupiesTile(doorPos)) && !isBuildable(doorPos) && !isPath(doorPos))
             {
                 return(false);
             }
         }
         string finalCheckResult = b.isThereAnythingtoPreventConstruction(this);
         if (finalCheckResult != null)
         {
             Game1.addHUDMessage(new HUDMessage(finalCheckResult, Color.Red, 3500f));
             return(false);
         }
     }
     b.tileX.Value = (int)tileLocation.X;
     b.tileY.Value = (int)tileLocation.Y;
     if (b.indoors.Value != null && b.indoors.Value is AnimalHouse)
     {
         foreach (long a in (b.indoors.Value as AnimalHouse).animalsThatLiveHere)
         {
             FarmAnimal animal2 = Utility.getAnimal(a);
             if (animal2 != null)
             {
                 animal2.homeLocation.Value = tileLocation;
                 animal2.home = b;
             }
             else if (animal2 == null && (b.indoors.Value as AnimalHouse).animals.ContainsKey(a))
             {
                 animal2 = (b.indoors.Value as AnimalHouse).animals[a];
                 animal2.homeLocation.Value = tileLocation;
                 animal2.home = b;
             }
         }
     }
     if (b.indoors.Value != null)
     {
         foreach (Warp warp in b.indoors.Value.warps)
         {
             warp.TargetX = b.humanDoor.X + (int)b.tileX;
             warp.TargetY = b.humanDoor.Y + (int)b.tileY + 1;
         }
     }
     if (!buildings.Contains(b))
     {
         buildings.Add(b);
     }
     return(true);
 }