Skip to content

Commit

Permalink
NetSyncEnabled fixes (space-wizards#4811)
Browse files Browse the repository at this point in the history
* NetSyncEnabled fixes

* A
  • Loading branch information
ElectroJr committed Jan 5, 2024
1 parent 9e6d0aa commit f2e9ed0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Robust.Client/Player/PlayerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,14 @@ public override bool SetAttachedEntity(ICommonSession? session, EntityUid? uid,
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)}.");
Expand Down
6 changes: 2 additions & 4 deletions Robust.Shared/GameObjects/EntityManager.Components.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,8 @@ private void AddComponentInternal<T>(EntityUid uid, T component, ComponentRegist
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);
Expand Down
1 change: 1 addition & 0 deletions Robust.Shared/Player/SharedPlayerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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!;
Expand Down

0 comments on commit f2e9ed0

Please sign in to comment.