Skip to content

Commit

Permalink
Renaming of scriber classes and small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Byte-Nova committed Oct 30, 2024
1 parent 1d5e8c2 commit 3551ac1
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 43 deletions.
4 changes: 2 additions & 2 deletions Source/Client/Dialogs/RT_Dialog_ItemListing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ private void DrawCustomRow(Rect rect, Thing thing, int index)
if (itemName.Length > 1) itemName = char.ToUpper(itemName[0]) + itemName.Substring(1);
else itemName = itemName.ToUpper();

if (RTScriberHelper.CheckIfThingIsHuman(thing))
if (ScriberHelper.CheckIfThingIsHuman(thing))
{
Widgets.Label(fixedRect, $"[H] {itemName}");
}

else if (RTScriberHelper.CheckIfThingIsAnimal(thing))
else if (ScriberHelper.CheckIfThingIsAnimal(thing))
{
Widgets.Label(fixedRect, $"[A] {itemName}");
}
Expand Down
6 changes: 3 additions & 3 deletions Source/Client/Dialogs/RT_Dialog_TransferMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public void GenerateTradeList()
{
foreach (Pawn pawn in SessionValues.chosenCaravan.pawns)
{
if (RTScriberHelper.CheckIfThingIsHuman(pawn))
if (ScriberHelper.CheckIfThingIsHuman(pawn))
{
if (allowHumans)
{
Expand All @@ -308,7 +308,7 @@ public void GenerateTradeList()
}
}

else if (RTScriberHelper.CheckIfThingIsAnimal(pawn))
else if (ScriberHelper.CheckIfThingIsAnimal(pawn))
{
if (allowAnimals)
{
Expand Down Expand Up @@ -347,7 +347,7 @@ public void GenerateTradeList()
{
foreach (Pawn pawn in pawnsInMap)
{
if (RTScriberHelper.CheckIfThingIsAnimal(pawn))
if (ScriberHelper.CheckIfThingIsAnimal(pawn))
{
if (allowAnimals)
{
Expand Down
34 changes: 9 additions & 25 deletions Source/Client/Managers/OnlineActivityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,15 @@ public static HumanFile[] GetActivityHumans()

if (SessionValues.isActivityHost)
{
foreach (Pawn pawn in OnlineActivityManager.activityMap.mapPawns.AllPawns.Where(fetch => fetch.Faction == Faction.OfPlayer && RTScriberHelper.CheckIfThingIsHuman(fetch)))
foreach (Pawn pawn in OnlineActivityManager.activityMap.mapPawns.AllPawns.Where(fetch => fetch.Faction == Faction.OfPlayer && ScriberHelper.CheckIfThingIsHuman(fetch)))
{
toGet.Add(HumanScriber.HumanToString(pawn));
}
}

else
{
foreach (Pawn pawn in SessionValues.chosenCaravan.PawnsListForReading.Where(fetch => RTScriberHelper.CheckIfThingIsHuman(fetch)))
foreach (Pawn pawn in SessionValues.chosenCaravan.PawnsListForReading.Where(fetch => ScriberHelper.CheckIfThingIsHuman(fetch)))
{
toGet.Add(HumanScriber.HumanToString(pawn));
}
Expand All @@ -328,15 +328,15 @@ public static AnimalFile[] GetActivityAnimals()

if (SessionValues.isActivityHost)
{
foreach (Pawn pawn in OnlineActivityManager.activityMap.mapPawns.AllPawns.Where(fetch => fetch.Faction == Faction.OfPlayer && RTScriberHelper.CheckIfThingIsAnimal(fetch)))
foreach (Pawn pawn in OnlineActivityManager.activityMap.mapPawns.AllPawns.Where(fetch => fetch.Faction == Faction.OfPlayer && ScriberHelper.CheckIfThingIsAnimal(fetch)))
{
toGet.Add(AnimalScriber.AnimalToString(pawn));
}
}

else
{
foreach (Pawn pawn in SessionValues.chosenCaravan.PawnsListForReading.Where(fetch => fetch.Faction == Faction.OfPlayer && RTScriberHelper.CheckIfThingIsAnimal(fetch)))
foreach (Pawn pawn in SessionValues.chosenCaravan.PawnsListForReading.Where(fetch => fetch.Faction == Faction.OfPlayer && ScriberHelper.CheckIfThingIsAnimal(fetch)))
{
toGet.Add(AnimalScriber.AnimalToString(pawn));
}
Expand Down Expand Up @@ -392,8 +392,8 @@ public static ActionTargetType[] GetActionTypes(Job job)
if (target.Thing == null) targetTypeList.Add(ActionTargetType.Cell);
else
{
if (RTScriberHelper.CheckIfThingIsHuman(target.Thing)) targetTypeList.Add(ActionTargetType.Human);
else if (RTScriberHelper.CheckIfThingIsAnimal(target.Thing)) targetTypeList.Add(ActionTargetType.Animal);
if (ScriberHelper.CheckIfThingIsHuman(target.Thing)) targetTypeList.Add(ActionTargetType.Human);
else if (ScriberHelper.CheckIfThingIsAnimal(target.Thing)) targetTypeList.Add(ActionTargetType.Animal);
else targetTypeList.Add(ActionTargetType.Thing);
}
}
Expand Down Expand Up @@ -525,9 +525,9 @@ public static CreationOrderData CreateCreationOrder(Thing thing)
{
CreationOrderData creationOrder = new CreationOrderData();

if (RTScriberHelper.CheckIfThingIsHuman(thing)) creationOrder._creationType = CreationType.Human;
else if (RTScriberHelper.CheckIfThingIsAnimal(thing)) creationOrder._creationType = CreationType.Animal;
else if (RTScriberHelper.CheckIfThingIsCorpse(thing)) creationOrder._creationType = CreationType.Corpse;
if (ScriberHelper.CheckIfThingIsHuman(thing)) creationOrder._creationType = CreationType.Human;
else if (ScriberHelper.CheckIfThingIsAnimal(thing)) creationOrder._creationType = CreationType.Animal;
else if (ScriberHelper.CheckIfThingIsCorpse(thing)) creationOrder._creationType = CreationType.Corpse;
else creationOrder._creationType = CreationType.Thing;

// Modify position based on center cell because RimWorld doesn't store it by default
Expand Down Expand Up @@ -642,8 +642,6 @@ public static PawnJobData CreateJobOrder(Pawn pawn, Job job)

public static void ReceiveCreationOrder(CreationOrderData data)
{
if (!CheckIfCanExecuteOrder()) return;

Thing toCreate = null;

switch(data._creationType)
Expand Down Expand Up @@ -681,8 +679,6 @@ public static void ReceiveCreationOrder(CreationOrderData data)

public static void ReceiveDestructionOrder(DestructionOrderData data)
{
if (!CheckIfCanExecuteOrder()) return;

// If we receive a hash that doesn't exist or we are host we ignore it
Thing toDestroy = OnlineActivityManagerHelper.GetThingFromID(data._thingHash);
if (toDestroy != null && !SessionValues.isActivityHost)
Expand All @@ -694,8 +690,6 @@ public static void ReceiveDestructionOrder(DestructionOrderData data)

public static void ReceiveDamageOrder(DamageOrderData data)
{
if (!CheckIfCanExecuteOrder()) return;

try
{
BodyPartRecord bodyPartRecord = new BodyPartRecord();
Expand All @@ -720,8 +714,6 @@ public static void ReceiveDamageOrder(DamageOrderData data)

public static void ReceiveHediffOrder(HediffOrderData data)
{
if (!CheckIfCanExecuteOrder()) return;

try
{
Pawn toTarget = null;
Expand Down Expand Up @@ -776,8 +768,6 @@ public static void ReceiveHediffOrder(HediffOrderData data)

public static void ReceiveGameConditionOrder(GameConditionOrderData data)
{
if (!CheckIfCanExecuteOrder()) return;

try
{
GameCondition gameCondition = null;
Expand All @@ -804,8 +794,6 @@ public static void ReceiveGameConditionOrder(GameConditionOrderData data)

public static void ReceiveWeatherOrder(WeatherOrderData data)
{
if (!CheckIfCanExecuteOrder()) return;

try
{
WeatherDef weatherDef = DefDatabase<WeatherDef>.AllDefs.First(fetch => fetch.defName == data._weatherDefName);
Expand All @@ -818,8 +806,6 @@ public static void ReceiveWeatherOrder(WeatherOrderData data)

public static void ReceiveTimeSpeedOrder(TimeSpeedOrderData data)
{
if (!CheckIfCanExecuteOrder()) return;

try
{
OnlineActivityQueues.SetTimeSpeedQueue(data._targetTimeSpeed);
Expand All @@ -830,8 +816,6 @@ public static void ReceiveTimeSpeedOrder(TimeSpeedOrderData data)

public static void ReceiveJobOrder(PawnJobData data)
{
if (!CheckIfCanExecuteOrder()) return;

try
{
Pawn pawn = OnlineActivityManagerHelper.GetPawnFromID(data._pawnId, OnlineActivityTargetFaction.NonFaction);
Expand Down
2 changes: 1 addition & 1 deletion Source/Client/Managers/RimworldManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public static Pawn[] GetPawnsFromMap(Map map, Faction faction, bool includeAnima
else
{
if (includeAnimals) return map.mapPawns.AllPawns.Where(fetch => fetch.Faction == faction).ToArray();
else return map.mapPawns.AllPawns.Where(fetch => fetch.Faction == faction && !RTScriberHelper.CheckIfThingIsAnimal(fetch)).ToArray();
else return map.mapPawns.AllPawns.Where(fetch => fetch.Faction == faction && !ScriberHelper.CheckIfThingIsAnimal(fetch)).ToArray();
}
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Client/Managers/SiteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private static void PrepareSendPawnScreen()
List<string> pawnNames = new List<string>();
foreach (Pawn pawn in pawns)
{
if (RTScriberHelper.CheckIfThingIsHuman(pawn)) pawnNames.Add(pawn.Label);
if (ScriberHelper.CheckIfThingIsHuman(pawn)) pawnNames.Add(pawn.Label);
}

RT_Dialog_ListingWithButton d1 = new RT_Dialog_ListingWithButton("Pawn Selection", "Select the pawn you wish to send",
Expand All @@ -210,7 +210,7 @@ public static void SendPawnToSite()
List<Pawn> caravanHumans = new List<Pawn>();
foreach (Pawn pawn in caravanPawns)
{
if (RTScriberHelper.CheckIfThingIsHuman(pawn)) caravanHumans.Add(pawn);
if (ScriberHelper.CheckIfThingIsHuman(pawn)) caravanHumans.Add(pawn);
}

Pawn pawnToSend = caravanHumans[DialogManager.dialogButtonListingResultInt];
Expand Down
4 changes: 2 additions & 2 deletions Source/Client/Managers/TransferManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public static class TransferManagerHelper

public static void AddThingToTransferManifest(Thing thing, int thingCount)
{
if (RTScriberHelper.CheckIfThingIsHuman(thing))
if (ScriberHelper.CheckIfThingIsHuman(thing))
{
Pawn pawn = thing as Pawn;

Expand All @@ -378,7 +378,7 @@ public static void AddThingToTransferManifest(Thing thing, int thingCount)
RimworldManager.RemovePawnFromGame(pawn);
}

else if (RTScriberHelper.CheckIfThingIsAnimal(thing))
else if (ScriberHelper.CheckIfThingIsAnimal(thing))
{
Pawn pawn = thing as Pawn;

Expand Down
8 changes: 4 additions & 4 deletions Source/Client/Patches/OnlineActivityPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static bool DoPre(Thing __instance)
OnlineActivityClock.creationOrderBuffer.Add(order);

//KEEP ALWAYS AS AT THE BOTTOM AS POSSIBLE
if (RTScriberHelper.CheckIfThingIsHuman(__instance) || RTScriberHelper.CheckIfThingIsAnimal(__instance))
if (ScriberHelper.CheckIfThingIsHuman(__instance) || ScriberHelper.CheckIfThingIsAnimal(__instance))
{
OnlineActivityManagerHelper.AddPawnToMap((Pawn)__instance);
}
Expand All @@ -72,7 +72,7 @@ public static bool DoPre(Thing __instance)
// IF COMING FROM HOST
if (OnlineActivityQueues.queuedThing == __instance)
{
if (RTScriberHelper.CheckIfThingIsHuman(__instance) || RTScriberHelper.CheckIfThingIsAnimal(__instance))
if (ScriberHelper.CheckIfThingIsHuman(__instance) || ScriberHelper.CheckIfThingIsAnimal(__instance))
{
OnlineActivityManagerHelper.AddPawnToMap((Pawn)__instance);
}
Expand Down Expand Up @@ -105,7 +105,7 @@ public static bool DoPre(Thing __instance)
OnlineActivityClock.destructionOrderBuffer.Add(order);

//KEEP ALWAYS AS AT THE BOTTOM AS POSSIBLE
if (RTScriberHelper.CheckIfThingIsHuman(__instance) || RTScriberHelper.CheckIfThingIsAnimal(__instance))
if (ScriberHelper.CheckIfThingIsHuman(__instance) || ScriberHelper.CheckIfThingIsAnimal(__instance))
{
OnlineActivityManagerHelper.RemovePawnFromMap((Pawn)__instance);
}
Expand All @@ -119,7 +119,7 @@ public static bool DoPre(Thing __instance)
// IF COMING FROM HOST
if (OnlineActivityQueues.queuedThing == __instance)
{
if (RTScriberHelper.CheckIfThingIsHuman(__instance) || RTScriberHelper.CheckIfThingIsAnimal(__instance))
if (ScriberHelper.CheckIfThingIsHuman(__instance) || ScriberHelper.CheckIfThingIsAnimal(__instance))
{
OnlineActivityManagerHelper.RemovePawnFromMap((Pawn)__instance);
}
Expand Down
8 changes: 4 additions & 4 deletions Source/Client/Scribers/RTScriber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private static void GetMapThings(MapFile mapFile, Map map, bool factionThings, b

foreach (Thing thing in map.listerThings.AllThings)
{
if (!RTScriberHelper.CheckIfThingIsHuman(thing) && !RTScriberHelper.CheckIfThingIsAnimal(thing))
if (!ScriberHelper.CheckIfThingIsHuman(thing) && !ScriberHelper.CheckIfThingIsAnimal(thing))
{
ThingFile thingData = ThingScriber.ThingToString(thing, thing.stackCount);

Expand All @@ -246,7 +246,7 @@ private static void GetMapHumans(MapFile mapFile, Map map, bool factionHumans, b

foreach (Thing thing in map.listerThings.AllThings)
{
if (RTScriberHelper.CheckIfThingIsHuman(thing))
if (ScriberHelper.CheckIfThingIsHuman(thing))
{
HumanFile humanData = HumanScriber.HumanToString(thing as Pawn);

Expand All @@ -270,7 +270,7 @@ private static void GetMapAnimals(MapFile mapFile, Map map, bool factionAnimals,

foreach (Thing thing in map.listerThings.AllThings)
{
if (RTScriberHelper.CheckIfThingIsAnimal(thing))
if (ScriberHelper.CheckIfThingIsAnimal(thing))
{
AnimalFile animalData = AnimalScriber.AnimalToString(thing as Pawn);

Expand Down Expand Up @@ -503,7 +503,7 @@ private static void SetMapRoofs(Map map)
}
}

public static class RTScriberHelper
public static class ScriberHelper
{
public static bool CheckIfThingIsHuman(Thing thing)
{
Expand Down

0 comments on commit 3551ac1

Please sign in to comment.