diff --git a/Common/Data/Excel/HouseFurniturePosData.cs b/Common/Data/Excel/HouseFurniturePosData.cs new file mode 100644 index 0000000..7e641dd --- /dev/null +++ b/Common/Data/Excel/HouseFurniturePosData.cs @@ -0,0 +1,18 @@ +namespace MikuSB.Data.Excel; + +[ResourceEntity("house/FurniturePos.json")] +public class HouseFurniturePosExcel : ExcelResource +{ + public uint AreaId { get; set; } + public uint GroupId { get; set; } + + public override uint GetId() + { + return (AreaId << 48) | (GroupId << 32); + } + + public override void Loaded() + { + GameData.HouseFurniturePosData.TryAdd(GetId(), this); + } +} diff --git a/Common/Data/GameData.cs b/Common/Data/GameData.cs index b0e1e1f..5f81860 100644 --- a/Common/Data/GameData.cs +++ b/Common/Data/GameData.cs @@ -31,6 +31,7 @@ public static class GameData public static Dictionary WeaponPartsData { get; private set; } = []; public static Dictionary GuideData { get; private set; } = []; public static Dictionary DormGiftData { get; private set; } = []; + public static Dictionary HouseFurniturePosData { get; private set; } = []; } public static class GameResourceTemplateId diff --git a/GameServer/Game/Player/PlayerInstance.cs b/GameServer/Game/Player/PlayerInstance.cs index 8d55a77..914d1f1 100644 --- a/GameServer/Game/Player/PlayerInstance.cs +++ b/GameServer/Game/Player/PlayerInstance.cs @@ -327,18 +327,30 @@ public class PlayerInstance(PlayerGameData data) private static IEnumerable<(uint Gid, uint Sid, uint Value)> BuildGirlFurnitureAttrs() { - // Unlock some furniture slots for every girl - // Each furniture attr int stores 10 slots using 3 bits per slot - // Value below means slot 0..9 = 1 const uint furnitureUnlockedValue = 153391689; + var groupFurnitureByArea = new Dictionary(); + foreach (var pos in GameData.HouseFurniturePosData.Values) + { + var areaId = pos.AreaId; + var groupId = pos.GroupId; + uint selectedIndex = 1; + var shift = (groupId - 1) * 3; + if (!groupFurnitureByArea.TryGetValue(areaId, out var packed)) packed = 0; + packed |= (selectedIndex << (int)shift); + groupFurnitureByArea[areaId] = packed; + } for (uint girlId = 0; girlId <= 50; girlId++) { - // FurnitureStart..FurnitureEnd = 10..19 + var baseSid = girlId * 50; for (uint offset = 10; offset <= 19; offset++) { - uint sid = (girlId * 50) + offset; - yield return (101, sid, furnitureUnlockedValue); + yield return (101, baseSid + offset, furnitureUnlockedValue); + } + + if (groupFurnitureByArea.TryGetValue(girlId, out var groupValue)) + { + yield return (101, baseSid + 20, groupValue); } } }