Advertisement
spacechase0

Custom NPCs spouse room

Jul 3rd, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.97 KB | None | 0 0
  1.         private void locChanged( object sender, EventArgsCurrentLocationChanged args )
  2.         {
  3.             var npc = Game1.getCharacterFromName("SDV.Penny2");
  4.             if ( args.NewLocation.name == "FarmHouse" )
  5.             {
  6.                 var house = args.NewLocation as FarmHouse;
  7.                 var displayingSpouseRoom = Helper.Reflection.GetPrivateField<bool>(house, "displayingSpouseRoom");
  8.                 if (displayingSpouseRoom.GetValue() && Game1.player.isMarried() )
  9.                 {
  10.                     var data = CustomNpcData.get(Game1.player.getSpouse().name);
  11.                     if (data == null)
  12.                         return;
  13.  
  14.                     showCustomSpouseRoom( house, displayingSpouseRoom, data);
  15.                 }
  16.             }
  17.         }
  18.         private void showCustomSpouseRoom( FarmHouse house, IPrivateField<bool> displayingSpouseRoom, CustomNpcData data )
  19.         {
  20.             var map = Helper.Content.Load<Map>(Path.Combine(data.Directory, "spouse-room.tbin"));
  21.             int num = 0;
  22.             var adjustMapLightPropertiesForLamp = Helper.Reflection.GetPrivateMethod(house, "adjustMapLightPropertiesForLamp");
  23.  
  24.             Microsoft.Xna.Framework.Rectangle rectangle = house.upgradeLevel == 1 ? new Microsoft.Xna.Framework.Rectangle(29, 1, 6, 9) : new Microsoft.Xna.Framework.Rectangle(35, 10, 6, 9);
  25.             Point point = new Point(num % 5 * 6, num / 5 * 9);
  26.             ((IDictionary<string, PropertyValue>)house.map.Properties).Remove("DayTiles");
  27.             ((IDictionary<string, PropertyValue>)house.map.Properties).Remove("NightTiles");
  28.             for (int index1 = 0; index1 < rectangle.Width; ++index1)
  29.             {
  30.                 for (int index2 = 0; index2 < rectangle.Height; ++index2)
  31.                 {
  32.                     if (map.GetLayer("Back").Tiles[point.X + index1, point.Y + index2] != null)
  33.                         house.map.GetLayer("Back").Tiles[rectangle.X + index1, rectangle.Y + index2] = (Tile)new StaticTile(house.map.GetLayer("Back"), house.map.TileSheets[0], BlendMode.Alpha, map.GetLayer("Back").Tiles[point.X + index1, point.Y + index2].TileIndex);
  34.                     if (map.GetLayer("Buildings").Tiles[point.X + index1, point.Y + index2] != null)
  35.                     {
  36.                         house.map.GetLayer("Buildings").Tiles[rectangle.X + index1, rectangle.Y + index2] = (Tile)new StaticTile(house.map.GetLayer("Buildings"), house.map.TileSheets[0], BlendMode.Alpha, map.GetLayer("Buildings").Tiles[point.X + index1, point.Y + index2].TileIndex);
  37.                         adjustMapLightPropertiesForLamp.Invoke(map.GetLayer("Buildings").Tiles[point.X + index1, point.Y + index2].TileIndex, rectangle.X + index1, rectangle.Y + index2, "Buildings");
  38.                     }
  39.                     else
  40.                         house.map.GetLayer("Buildings").Tiles[rectangle.X + index1, rectangle.Y + index2] = (Tile)null;
  41.                     if (index2 < rectangle.Height - 1 && map.GetLayer("Front").Tiles[point.X + index1, point.Y + index2] != null)
  42.                     {
  43.                         house.map.GetLayer("Front").Tiles[rectangle.X + index1, rectangle.Y + index2] = (Tile)new StaticTile(house.map.GetLayer("Front"), house.map.TileSheets[0], BlendMode.Alpha, map.GetLayer("Front").Tiles[point.X + index1, point.Y + index2].TileIndex);
  44.                         adjustMapLightPropertiesForLamp.Invoke(map.GetLayer("Front").Tiles[point.X + index1, point.Y + index2].TileIndex, rectangle.X + index1, rectangle.Y + index2, "Front");
  45.                     }
  46.                     else if (index2 < rectangle.Height - 1)
  47.                         house.map.GetLayer("Front").Tiles[rectangle.X + index1, rectangle.Y + index2] = (Tile)null;
  48.                     if (index1 == 4 && index2 == 4)
  49.                         house.map.GetLayer("Back").Tiles[rectangle.X + index1, rectangle.Y + index2].Properties.Add(new KeyValuePair<string, PropertyValue>("NoFurniture", new PropertyValue("T")));
  50.                 }
  51.             }
  52.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement