mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-06-09 10:06:34 +02:00
83c2a1be11
* [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>
64 lines
2.0 KiB
C#
64 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using Robust.Client.Timing;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Network.Messages;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Robust.Client.Prototypes
|
|
{
|
|
public sealed partial class ClientPrototypeManager : PrototypeManager
|
|
{
|
|
[Dependency] private INetManager _netManager = default!;
|
|
#if TOOLS
|
|
[Dependency] private IClientGameTiming _timing = default!;
|
|
#endif
|
|
[Dependency] private IGameControllerInternal _controller = default!;
|
|
[Dependency] private IReloadManager _reload = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
_netManager.RegisterNetMessage<MsgReloadPrototypes>(accept: NetMessageAccept.Server);
|
|
|
|
_reload.Register("/Prototypes", "*.yml");
|
|
_reload.OnChanged += ReloadPrototypeQueue;
|
|
}
|
|
|
|
public override void LoadDefaultPrototypes(Dictionary<Type, HashSet<string>>? changed = null)
|
|
{
|
|
LoadDirectory(new("/EnginePrototypes/"), changed: changed);
|
|
LoadDirectory(_controller.Options.PrototypeDirectory, changed: changed);
|
|
ResolveResults();
|
|
}
|
|
|
|
private void ReloadPrototypeQueue(ResPath file)
|
|
{
|
|
if (file.Extension != "yml")
|
|
return;
|
|
|
|
#if TOOLS
|
|
var sw = Stopwatch.StartNew();
|
|
|
|
var msg = new MsgReloadPrototypes
|
|
{
|
|
Paths = [file]
|
|
};
|
|
_netManager.ClientSendMessage(msg);
|
|
|
|
// Reloading prototypes modifies entities. This currently causes some state management debug asserts to
|
|
// fail. To avoid this, we set `IGameTiming.ApplyingState` to true, even though this isn't really applying a
|
|
// server state.
|
|
using var _ = _timing.StartStateApplicationArea();
|
|
ReloadPrototypes([file]);
|
|
|
|
Sawmill.Info($"Reloaded prototypes in {sw.ElapsedMilliseconds} ms");
|
|
#endif
|
|
}
|
|
}
|
|
}
|