Skip to content

Commit 0ae5497

Browse files
Sakura_TASakura_TA
authored andcommitted
Fix VFE issue syncing Command_SetItemsToSpawn
Should fix VFE-Faction Machanoid_ FishTrapper being able to set products The issue is that Command_SetItemsToSpawn is actualing using a ThingComp as param instead of Thing, witch can't be synced as Thing. Added function for command with comp_building.
1 parent 136418f commit 0ae5497

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Source/Mods/VanillaExpandedFramework.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections;
33
using System.Collections.Generic;
44
using System.Linq;
5+
using System.Net.NetworkInformation;
56
using System.Reflection;
67
using System.Reflection.Emit;
78
using System.Runtime.Serialization;
@@ -93,6 +94,16 @@ private static void SyncCommandWithBuilding(SyncWorker sync, ref Command command
9394
else
9495
building.SetValue(sync.Read<Thing>());
9596
}
97+
private static void SyncCommandWithCompBuilding(SyncWorker sync, ref Command command)
98+
{
99+
var traverse = Traverse.Create(command);
100+
var building = traverse.Field("building");
101+
102+
if (sync.isWriting)
103+
sync.Write(building.GetValue() as ThingComp);
104+
else
105+
building.SetValue(sync.Read<ThingComp>());
106+
}
96107

97108
#endregion
98109

@@ -634,7 +645,7 @@ private static void PatchVanillaFurnitureExpanded()
634645

635646
var type = AccessTools.TypeByName("VanillaFurnitureExpanded.Command_SetItemsToSpawn");
636647
MpCompat.RegisterLambdaDelegate(type, "ProcessInput", 1);
637-
MP.RegisterSyncWorker<Command>(SyncCommandWithBuilding, type, shouldConstruct: true);
648+
MP.RegisterSyncWorker<Command>(SyncCommandWithCompBuilding, type, shouldConstruct: true);
638649

639650
MpCompat.RegisterLambdaMethod("VanillaFurnitureExpanded.CompRockSpawner", "CompGetGizmosExtra", 0);
640651

0 commit comments

Comments
 (0)