-
-
Save spacechase0/72815c4a8222c1072c8529abf016d33a to your computer and use it in GitHub Desktop.
Custom NPCs Spouse Room
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void locChanged( object sender, EventArgsCurrentLocationChanged args ) | |
{ | |
if ( args.NewLocation.name == "FarmHouse" ) | |
{ | |
var house = args.NewLocation as FarmHouse; | |
var displayingSpouseRoom = Helper.Reflection.GetPrivateField<bool>(house, "displayingSpouseRoom"); | |
if (displayingSpouseRoom.GetValue() && Game1.player.isMarried() ) | |
{ | |
var data = CustomNpcData.get(Game1.player.getSpouse().name); | |
if (data == null) | |
return; | |
showCustomSpouseRoom( house, displayingSpouseRoom, data); | |
} | |
} | |
} | |
private void showCustomSpouseRoom( FarmHouse house, IPrivateField<bool> displayingSpouseRoom, CustomNpcData data ) | |
{ | |
var map = Helper.Content.Load<Map>(Path.Combine(data.Directory, "spouse-room.tbin")); | |
int num = 0; | |
var adjustMapLightPropertiesForLamp = Helper.Reflection.GetPrivateMethod(house, "adjustMapLightPropertiesForLamp"); | |
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); | |
Point point = new Point(num % 5 * 6, num / 5 * 9); | |
((IDictionary<string, PropertyValue>)house.map.Properties).Remove("DayTiles"); | |
((IDictionary<string, PropertyValue>)house.map.Properties).Remove("NightTiles"); | |
for (int index1 = 0; index1 < rectangle.Width; ++index1) | |
{ | |
for (int index2 = 0; index2 < rectangle.Height; ++index2) | |
{ | |
if (map.GetLayer("Back").Tiles[point.X + index1, point.Y + index2] != null) | |
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); | |
if (map.GetLayer("Buildings").Tiles[point.X + index1, point.Y + index2] != null) | |
{ | |
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); | |
adjustMapLightPropertiesForLamp.Invoke(map.GetLayer("Buildings").Tiles[point.X + index1, point.Y + index2].TileIndex, rectangle.X + index1, rectangle.Y + index2, "Buildings"); | |
} | |
else | |
house.map.GetLayer("Buildings").Tiles[rectangle.X + index1, rectangle.Y + index2] = (Tile)null; | |
if (index2 < rectangle.Height - 1 && map.GetLayer("Front").Tiles[point.X + index1, point.Y + index2] != null) | |
{ | |
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); | |
adjustMapLightPropertiesForLamp.Invoke(map.GetLayer("Front").Tiles[point.X + index1, point.Y + index2].TileIndex, rectangle.X + index1, rectangle.Y + index2, "Front"); | |
} | |
else if (index2 < rectangle.Height - 1) | |
house.map.GetLayer("Front").Tiles[rectangle.X + index1, rectangle.Y + index2] = (Tile)null; | |
if (index1 == 4 && index2 == 4) | |
house.map.GetLayer("Back").Tiles[rectangle.X + index1, rectangle.Y + index2].Properties.Add(new KeyValuePair<string, PropertyValue>("NoFurniture", new PropertyValue("T"))); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment