Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fake constructables being moved to GlobalRoot #2254

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions NitroxClient/GameLogic/Spawning/Bases/ModuleEntitySpawner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public static IEnumerator RestoreModule(Transform parent, ModuleEntity moduleEnt
moduleTransform.localRotation = moduleEntity.Transform.LocalRotation.ToUnity();
moduleTransform.localScale = moduleEntity.Transform.LocalScale.ToUnity();
ApplyModuleData(moduleEntity, moduleObject, result);
MoveToGlobalRoot(moduleObject);

if (parent && parent.TryGetComponent(out NitroxCyclops nitroxCyclops) && nitroxCyclops.Virtual)
{
Expand Down Expand Up @@ -129,6 +130,21 @@ public static void FillObject(ModuleEntity moduleEntity, Constructable construct
moduleEntity.IsInside = constructable.isInside;
}

/// <summary>
/// We don't want constructables to be put in CellRoots but in GlobalRoot, because when a player has simulation ownership over a base,
/// they also need to keep loaded everything which could be related to the said base (e.g. power relays)
/// </summary>
public static void MoveToGlobalRoot(GameObject gameObject)
{
if (!gameObject.TryGetComponent(out LargeWorldEntity largeWorldEntity))
{
return;
}

largeWorldEntity.cellLevel = LargeWorldEntity.CellLevel.Global;
largeWorldEntity.Start();
}

public static ModuleEntity From(Constructable constructable)
{
ModuleEntity module = ModuleEntity.MakeEmpty();
Expand Down
2 changes: 2 additions & 0 deletions NitroxPatcher/Patches/Dynamic/Builder_TryPlace_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ public static void GhostCreated(Constructable constructable)
}
else
{
ModuleEntitySpawner.MoveToGlobalRoot(ghostObject);

ModuleEntity module = ModuleEntitySpawner.From(constructable);
module.Id = ghostId;
module.ParentId = parentId;
Expand Down
21 changes: 0 additions & 21 deletions NitroxPatcher/Patches/Dynamic/LargeWorldEntity_Awake_Patch.cs

This file was deleted.