-
Notifications
You must be signed in to change notification settings - Fork 8
IConfigurableHousing
The IConfigurableHousing
is an Interface implementation.
It allows you to make your Housing Values an Overridable Housing Value to allow either:
- Other Modders
- Server Owners
To customize Housing Values for your items.
The implementation of the IConfigurableHousing
can be used on Any Housing Item.
Below is the Implementation of the IConfigurableHousing
:
The implementation uses a specific data structure and is setup in a specific way for it to be able to work.
Working with the implementation will be confusing to start with as it is not a normal implementation of the Housing Values setup.
private static readonly HousingModel defaults = new(
typeof(Item),
"Some Item",
HomeFurnishingValue.RoomCategory.,
skillValue: 2,
typeForRoomLimit: "Storage",
diminishingReturn: 0.2f);
Here is each component broken down and explained:
typeof(Item)
This is The item you are connecting the Resolver too.
"Some Item"
This is The Items Display Name
HomeFurnishingValue.RoomCategory
This is the Room Category to use for your item, It is an Enum.
skillValue: int
This is the Housing Value for having this item in the correct room
typeForRoomLimit: ""
This is the Check to see if there are any other of this type in the same room for the Diminishing Return
diminishingReturn: 0.0f
The Diminishing Return is how much to reduce the Skill Value by based on more then 1 of the same type in the same room, 0 = No Skill Value for duplicates, 1 = Full Skill Value even with duplicates, Inbetween are % values
These are the values that are required when using this on the Your Housing Items.
Anything Marked with an Asterixis (//*) is Required
public partial class RandomItem : WorldObjectItem<RandomObject>, IConfigurableHousing
{
public override LocString DisplayDescription => Localizer.DoStr("Description");
private static readonly HousingModel defaults = new(
typeof(RandomItem), //*
"Random Item", //*
roomType: HomeFurnishingValue.RoomCategory.General, //*
skillValue: 5, //*
typeForRoomLimit: "Storage", //*
diminishingReturn: 0f); //*
public override HomeFurnishingValue HomeValue => HousingVal;
public static HomeFurnishingValue HousingVal => EMHousingResolver.Obj.ResolveHomeValue(typeof(RandomItem));
static RandomItem() => EMHousingResolver.AddDefaults(defaults);
}
And thats it! you can now override the housing values with other mods and the EM Configure Plugin (Built In)