Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Source/Client/Comp/Map/MultiplayerMapComp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ public CustomFactionMapData GetCurrentCustomFactionData()
return customFactionData[Faction.OfPlayer.loadID];
}

public CustomFactionMapData GetCustomFactionData(Faction faction)
{
return customFactionData[faction.loadID];
}

public void Notify_ThingDespawned(Thing t)
{
foreach (var data in customFactionData.Values)
Expand Down
33 changes: 33 additions & 0 deletions Source/Client/Factions/Forbiddables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,39 @@ namespace Multiplayer.Client
{
// todo handle conversion to singleplayer and PostSplitOff

[HarmonyPatch(typeof(ForbidUtility), nameof(ForbidUtility.IsForbidden),
typeof(Thing), typeof(Faction))]
static class IsForbiddenPatch
{
static bool Prefix(Thing t, Faction faction, ref bool __result)
{
if (Multiplayer.Client == null || faction == null || !faction.IsPlayer) return true; // singleplayer: run vanilla

ThingWithComps thingWithComps = t as ThingWithComps;
if (thingWithComps == null)
{
__result = false;
return false;
}
CompForbiddable compForbiddable = thingWithComps.compForbiddable;

if(compForbiddable == null) {
__result = false;
return false;
}

if(!t.Spawned)
{
__result = false;
return false;
}

__result = !t.Map.MpComp().GetCustomFactionData(faction).unforbidden.Contains(t); // use faction-specific data directly
return false; // skip vanilla
}

}

[HarmonyPatch(typeof(CompForbiddable), nameof(CompForbiddable.Forbidden), MethodType.Getter)]
static class GetForbidPatch
{
Expand Down
Loading