示例#1
0
        public static bool Prefix(Vector2 tileLocation, Farmer who, NetPoint ___humanDoor, NetInt ___tileX, NetInt ___tileY, Building __instance)
        {
            int doorWidth = 2;
            int xDist     = (int)tileLocation.X - (___humanDoor.X + ___tileX.Value);

            if (who.IsLocalPlayer && CabinHelper.IsElevatorBuilding(__instance) &&
                xDist < doorWidth && xDist >= 0 && tileLocation.Y == ___humanDoor.Y + ___tileY.Value)
            {
                if (who.mount != null)
                {
                    Game1.showRedMessage(Game1.content.LoadString("Strings\\Buildings:DismountBeforeEntering"));
                    return(false);
                }
                if (who.team.buildLock.IsLocked())
                {
                    Game1.showRedMessage(Game1.content.LoadString("Strings\\Buildings:CantEnter"));
                    return(false);
                }

                //indoors.Value.isStructure.Value = true;

                who.currentLocation.playSoundAt("crystal", tileLocation);

                if (Game1.activeClickableMenu == null)
                {
                    Game1.activeClickableMenu = new ElevatorMenu();
                }

                return(false);
            }
            return(true);
        }
示例#2
0
 public static bool Prefix(Building __instance)
 {
     if (CabinHelper.IsElevatorBuilding(__instance))
     {
         __instance.texture = new Lazy <Texture2D>(() => ModEntry.ElevatorBuildingTexture);
         return(false);
     }
     return(true);
 }
示例#3
0
 private void ReloadTextures()
 {
     foreach (Building building in Game1.getFarm().buildings)
     {
         if (CabinHelper.IsElevatorBuilding(building))
         {
             Monitor.Log("(Re)loading an elevator building texture");
             building.resetTexture();                    //Otherwise the clients will just see a shed
         }
     }
 }
示例#4
0
        public static bool Postfix(bool b, int xTile, int yTile, Farmer who, Building __instance, NetPoint ___humanDoor, bool __result, NetInt ___tileX, NetInt ___tileY)
        {
            if (!CabinHelper.IsElevatorBuilding(__instance))
            {
                return(__result);
            }


            int doorWidth = 2;
            int dist      = xTile - (___tileX.Value + ___humanDoor.X);

            if (___humanDoor.X >= 0 && yTile == ___tileY.Value + ___humanDoor.Y &&
                dist < doorWidth && dist >= 0)
            {
                return(true);
            }

            return(false);
        }
        public static bool Prefix(NetFarmerRoot f)
        {
            if (f.Value.Name.Length == 0)
            {
                //Don't create a cabin unless there is an elevator building
                bool elevatorBuildingExists = false;
                foreach (Building building in Game1.getFarm().buildings)
                {
                    if (CabinHelper.IsElevatorBuilding(building))
                    {
                        elevatorBuildingExists = true;
                        break;
                    }
                }
                if (!elevatorBuildingExists)
                {
                    return(true);
                }

                //A new player has joined. If there is less then 10 spots availible, mark up until 10
                int emptyPlaces = 0;
                foreach (Farmer player in Game1.getAllFarmhands())
                {
                    if (player.Name.Length == 0)
                    {
                        emptyPlaces++;
                    }
                }

                Console.WriteLine($"Generating {10 - emptyPlaces} new cabins");

                if (emptyPlaces < 10)
                {
                    for (int i = 0; i <= 10 - emptyPlaces; i++)                    //Make up to 10
                    {
                        CabinHelper.AddNewCabin(Game1.random.Next(1, 4));
                    }
                }
            }

            return(true);
        }