-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:SokyranTheDragon/Multiplayer into…
… session-rework # Conflicts: # Source/Client/Comp/World/MultiplayerWorldComp.cs
- Loading branch information
Showing
41 changed files
with
569 additions
and
334 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
using System; | ||
using HarmonyLib; | ||
using RimWorld; | ||
using RimWorld.Planet; | ||
using Verse; | ||
|
||
namespace Multiplayer.Client.Factions; | ||
|
||
[HarmonyPatch(typeof(SettlementUtility), nameof(SettlementUtility.AttackNow))] | ||
static class AttackNowPatch | ||
{ | ||
static void Prefix(Caravan caravan) | ||
{ | ||
FactionContext.Push(caravan.Faction); | ||
} | ||
|
||
static void Finalizer() | ||
{ | ||
FactionContext.Pop(); | ||
} | ||
} | ||
|
||
[HarmonyPatch(typeof(GetOrGenerateMapUtility), nameof(GetOrGenerateMapUtility.GetOrGenerateMap), new []{ typeof(int), typeof(IntVec3), typeof(WorldObjectDef) })] | ||
static class MapGenFactionPatch | ||
{ | ||
static void Prefix(int tile) | ||
{ | ||
var mapParent = Find.WorldObjects.MapParentAt(tile); | ||
if (Multiplayer.Client != null && mapParent == null) | ||
Log.Warning($"Couldn't set the faction context for map gen at {tile}: no world object"); | ||
|
||
FactionContext.Push(mapParent?.Faction); | ||
} | ||
|
||
static void Finalizer() | ||
{ | ||
FactionContext.Pop(); | ||
} | ||
} | ||
|
||
[HarmonyPatch(typeof(CaravanEnterMapUtility), nameof(CaravanEnterMapUtility.Enter), new[] { typeof(Caravan), typeof(Map), typeof(Func<Pawn, IntVec3>), typeof(CaravanDropInventoryMode), typeof(bool) })] | ||
static class CaravanEnterFactionPatch | ||
{ | ||
static void Prefix(Caravan caravan) | ||
{ | ||
FactionContext.Push(caravan.Faction); | ||
} | ||
|
||
static void Finalizer() | ||
{ | ||
FactionContext.Pop(); | ||
} | ||
} | ||
|
||
[HarmonyPatch(typeof(WealthWatcher), nameof(WealthWatcher.ForceRecount))] | ||
static class WealthRecountFactionPatch | ||
{ | ||
static void Prefix(WealthWatcher __instance) | ||
{ | ||
FactionContext.Push(__instance.map.ParentFaction); | ||
} | ||
|
||
static void Finalizer() | ||
{ | ||
FactionContext.Pop(); | ||
} | ||
} | ||
|
||
[HarmonyPatch(typeof(FactionIdeosTracker), nameof(FactionIdeosTracker.RecalculateIdeosBasedOnPlayerPawns))] | ||
static class RecalculateFactionIdeosContext | ||
{ | ||
static void Prefix(FactionIdeosTracker __instance) | ||
{ | ||
FactionContext.Push(__instance.faction); | ||
} | ||
|
||
static void Finalizer() | ||
{ | ||
FactionContext.Pop(); | ||
} | ||
} | ||
|
||
[HarmonyPatch(typeof(Bill), nameof(Bill.ValidateSettings))] | ||
static class BillValidateSettingsPatch | ||
{ | ||
static void Prefix(Bill __instance) | ||
{ | ||
if (Multiplayer.Client == null) return; | ||
FactionContext.Push(__instance.pawnRestriction?.Faction); // todo HostFaction, SlaveFaction? | ||
} | ||
|
||
static void Finalizer() | ||
{ | ||
if (Multiplayer.Client == null) return; | ||
FactionContext.Pop(); | ||
} | ||
} | ||
|
||
[HarmonyPatch(typeof(Bill_Production), nameof(Bill_Production.ValidateSettings))] | ||
static class BillProductionValidateSettingsPatch | ||
{ | ||
static void Prefix(Bill_Production __instance, ref Map __state) | ||
{ | ||
if (Multiplayer.Client == null) return; | ||
|
||
var zoneManager = __instance.storeZone?.zoneManager ?? __instance.includeFromZone?.zoneManager; | ||
if (__instance.Map != null && zoneManager != null) | ||
{ | ||
__instance.Map.PushFaction(zoneManager.map.MpComp().GetFactionId(zoneManager)); | ||
__state = __instance.Map; | ||
} | ||
} | ||
|
||
static void Finalizer(Map __state) | ||
{ | ||
__state?.PopFaction(); | ||
} | ||
} |
Oops, something went wrong.