NetSyncEnabled fixes (#4811)

* NetSyncEnabled fixes

* A
This commit is contained in:
Leon Friedrich
2024-01-04 23:11:09 -05:00
committed by GitHub
parent 9e6d0aa44a
commit f2e9ed0b73
3 changed files with 7 additions and 5 deletions

View File

@@ -162,11 +162,14 @@ namespace Robust.Client.Player
return true;
}
if (!EntManager.EnsureComponent(uid.Value, out EyeComponent eye))
if (!EntManager.HasComponent<EyeComponent>(uid.Value))
{
if (_client.RunLevel != ClientRunLevel.SinglePlayerGame)
Sawmill.Warning($"Attaching local player to an entity {EntManager.ToPrettyString(uid)} without an eye. This eye will not be netsynced and may cause issues.");
var eye = (EyeComponent) Factory.GetComponent(typeof(EyeComponent));
eye.Owner = uid.Value;
eye.NetSyncEnabled = false;
EntManager.AddComponent(uid.Value, eye);
}
Sawmill.Info($"Attaching local player to {EntManager.ToPrettyString(uid)}.");

View File

@@ -318,10 +318,8 @@ namespace Robust.Shared.GameObjects
metadata ??= MetaQuery.GetComponentInternal(uid);
metadata.NetComponents.Add(netId, component);
}
else
{
component.Networked = false;
}
component.Networked = reg.NetID != null;
var eventArgs = new AddedComponentEventArgs(new ComponentEventArgs(component, uid), reg);
ComponentAdded?.Invoke(eventArgs);

View File

@@ -12,6 +12,7 @@ namespace Robust.Shared.Player;
internal abstract partial class SharedPlayerManager : ISharedPlayerManager
{
[Dependency] protected readonly IEntityManager EntManager = default!;
[Dependency] protected readonly IComponentFactory Factory = default!;
[Dependency] protected readonly ILogManager LogMan = default!;
[Dependency] protected readonly IGameTiming Timing = default!;
[Dependency] private readonly INetManager _netMan = default!;