Exemplo n.º 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);
        }
Exemplo n.º 2
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);
        }
 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);
 }