mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-01 17:47:24 +02:00
* [Dependency] source generator No more reflection, no more codegen at runtime Also various changes to Roslyn helpers to make this easier to write. Requires all types with dependencies to be partial and not have readonly dependency fields. An analyzer enforces this at warning level, the previous injection strategies have remained in the code *for now* as a fallback. No fallback is available for [field: Dependency] properties, due to a Roslyn bug. Code Fixes exist. We love Roslyn * Apply dependencies generator changes to all code * Release notes * Preprocessor got hands * Handle nullable dependencies These are bad but gotta deal with it. * Apply suggestions from code review Co-authored-by: Moony <moony@hellomouse.net> * Fine, let's not use collection expressions --------- Co-authored-by: Moony <moony@hellomouse.net>
66 lines
1.7 KiB
C#
66 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Log;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Timing;
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
namespace Robust.Shared.Player;
|
|
|
|
internal abstract partial class SharedPlayerManager : ISharedPlayerManager
|
|
{
|
|
[Dependency] protected IEntityManager EntManager = default!;
|
|
[Dependency] protected IComponentFactory Factory = default!;
|
|
[Dependency] protected ILogManager LogMan = default!;
|
|
[Dependency] protected IGameTiming Timing = default!;
|
|
[Dependency] private INetManager _netMan = default!;
|
|
|
|
protected ISawmill Sawmill = default!;
|
|
|
|
public event EventHandler<SessionStatusEventArgs>? PlayerStatusChanged;
|
|
|
|
[ViewVariables]
|
|
public virtual int MaxPlayers { get; protected set; }
|
|
|
|
[ViewVariables]
|
|
public int PlayerCount => InternalSessions.Count;
|
|
|
|
[ViewVariables]
|
|
public ICommonSession? LocalSession { get; protected set; }
|
|
|
|
[ViewVariables]
|
|
public NetUserId? LocalUser => LocalSession?.UserId;
|
|
|
|
[ViewVariables]
|
|
public EntityUid? LocalEntity => LocalSession?.AttachedEntity;
|
|
|
|
public GameTick LastStateUpdate;
|
|
|
|
[ViewVariables]
|
|
protected readonly Dictionary<string, NetUserId> UserIdMap = new();
|
|
|
|
public virtual void Initialize(int maxPlayers)
|
|
{
|
|
MaxPlayers = maxPlayers;
|
|
Sawmill = LogMan.GetSawmill("player");
|
|
}
|
|
|
|
public virtual void Startup()
|
|
{
|
|
}
|
|
|
|
public virtual void Shutdown()
|
|
{
|
|
InternalSessions.Clear();
|
|
UserIdMap.Clear();
|
|
PlayerData.Clear();
|
|
}
|
|
|
|
public bool TryGetUserId(string userName, out NetUserId userId)
|
|
{
|
|
return UserIdMap.TryGetValue(userName, out userId);
|
|
}
|
|
}
|