mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-02 10:07:15 +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>
62 lines
1.8 KiB
C#
62 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using Robust.Server.Console;
|
|
using Robust.Server.Player;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Log;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Network.Messages;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Robust.Server.Prototypes
|
|
{
|
|
public sealed partial class ServerPrototypeManager : PrototypeManager
|
|
{
|
|
#if TOOLS
|
|
[Dependency] private IPlayerManager _playerManager = default!;
|
|
[Dependency] private IConGroupController _conGroups = default!;
|
|
#endif
|
|
[Dependency] private INetManager _netManager = default!;
|
|
[Dependency] private IBaseServerInternal _server = default!;
|
|
|
|
public ServerPrototypeManager()
|
|
{
|
|
RegisterIgnore("shader");
|
|
RegisterIgnore("uiTheme");
|
|
RegisterIgnore("font");
|
|
}
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
_netManager.RegisterNetMessage<MsgReloadPrototypes>(HandleReloadPrototypes, NetMessageAccept.Server);
|
|
}
|
|
|
|
private void HandleReloadPrototypes(MsgReloadPrototypes msg)
|
|
{
|
|
#if TOOLS
|
|
if (!_playerManager.TryGetSessionByChannel(msg.MsgChannel, out var player) ||
|
|
!_conGroups.CanAdminReloadPrototypes(player))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var sw = Stopwatch.StartNew();
|
|
|
|
ReloadPrototypes(msg.Paths);
|
|
|
|
Sawmill.Info($"Reloaded prototypes in {sw.ElapsedMilliseconds} ms");
|
|
#endif
|
|
}
|
|
|
|
public override void LoadDefaultPrototypes(Dictionary<Type, HashSet<string>>? changed = null)
|
|
{
|
|
LoadDirectory(new("/EnginePrototypes/"), changed: changed);
|
|
LoadDirectory(_server.Options.PrototypeDirectory, changed: changed);
|
|
ResolveResults();
|
|
}
|
|
}
|
|
}
|