mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-02 18:17:09 +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>
51 lines
1.6 KiB
C#
51 lines
1.6 KiB
C#
using JetBrains.Annotations;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
|
|
namespace Robust.Server.GameObjects;
|
|
|
|
[UsedImplicitly]
|
|
public sealed partial class ServerOccluderSystem : OccluderSystem
|
|
{
|
|
[Dependency] private MetaDataSystem _metadata = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<OccluderComponent, MetaFlagRemoveAttemptEvent>(OnFlagRemoveAttempt);
|
|
}
|
|
|
|
private void OnFlagRemoveAttempt(Entity<OccluderComponent> ent, ref MetaFlagRemoveAttemptEvent args)
|
|
{
|
|
if (ent.Comp is { Enabled: true, LifeStage: <= ComponentLifeStage.Running })
|
|
args.ToRemove &= ~MetaDataFlags.PvsPriority;
|
|
}
|
|
|
|
protected override void OnCompStartup(EntityUid uid, OccluderComponent component, ComponentStartup args)
|
|
{
|
|
base.OnCompStartup(uid, component, args);
|
|
_metadata.SetFlag(uid, MetaDataFlags.PvsPriority, component.Enabled);
|
|
}
|
|
|
|
protected override void OnCompRemoved(EntityUid uid, OccluderComponent component, ComponentRemove args)
|
|
{
|
|
base.OnCompRemoved(uid, component, args);
|
|
_metadata.SetFlag(uid, MetaDataFlags.PvsPriority, false);
|
|
}
|
|
|
|
public override void SetEnabled(EntityUid uid, bool enabled, OccluderComponent? comp = null, MetaDataComponent? meta = null)
|
|
{
|
|
if (!Resolve(uid, ref comp, false))
|
|
return;
|
|
|
|
if (enabled == comp.Enabled)
|
|
return;
|
|
|
|
if (!Resolve(uid, ref meta))
|
|
return;
|
|
|
|
base.SetEnabled(uid, enabled, comp, meta);
|
|
_metadata.SetFlag((uid, meta), MetaDataFlags.PvsPriority, enabled);
|
|
}
|
|
}
|