mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* Remove Shared System IPrototypeManager instances * Remove RecipeManager IPrototypeManager instance * Fix ItemSystem IPrototypeManager refs, use TryComp * SharedItemSystem changes, EntWhitelist CompName * HasComponent->HasComp
65 lines
2 KiB
C#
65 lines
2 KiB
C#
using Content.Shared.Database;
|
|
using Content.Shared.Examine;
|
|
using Content.Shared.Lock;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Singularity.Components;
|
|
using Content.Shared.Verbs;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Shared.Singularity.EntitySystems;
|
|
|
|
public abstract partial class SharedEmitterSystem : EntitySystem
|
|
{
|
|
[Dependency] private SharedPopupSystem _popup = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<EmitterComponent, ExaminedEvent>(OnExamined);
|
|
SubscribeLocalEvent<EmitterComponent, GetVerbsEvent<Verb>>(OnGetVerb);
|
|
}
|
|
|
|
private void OnGetVerb(Entity<EmitterComponent> ent, ref GetVerbsEvent<Verb> args)
|
|
{
|
|
if (!args.CanAccess || !args.CanInteract || !args.CanComplexInteract || args.Hands == null)
|
|
return;
|
|
|
|
if (TryComp<LockComponent>(ent.Owner, out var lockComp) && lockComp.Locked)
|
|
return;
|
|
|
|
if (ent.Comp.SelectableTypes.Count < 2)
|
|
return;
|
|
|
|
foreach (var type in ent.Comp.SelectableTypes)
|
|
{
|
|
var proto = ProtoMan.Index(type);
|
|
|
|
var v = new Verb
|
|
{
|
|
Priority = 1,
|
|
Category = VerbCategory.SelectType,
|
|
Text = proto.Name,
|
|
Disabled = type == ent.Comp.BoltType,
|
|
Impact = LogImpact.Medium,
|
|
DoContactInteraction = true,
|
|
Act = () =>
|
|
{
|
|
ent.Comp.BoltType = type;
|
|
Dirty(ent);
|
|
_popup.PopupClient(Loc.GetString("emitter-component-type-set", ("type", proto.Name)), ent.Owner);
|
|
},
|
|
};
|
|
args.Verbs.Add(v);
|
|
}
|
|
}
|
|
|
|
private void OnExamined(Entity<EmitterComponent> ent, ref ExaminedEvent args)
|
|
{
|
|
if (ent.Comp.SelectableTypes.Count < 2)
|
|
return;
|
|
|
|
var proto = ProtoMan.Index(ent.Comp.BoltType);
|
|
args.PushMarkup(Loc.GetString("emitter-component-current-type", ("type", proto.Name)));
|
|
}
|
|
}
|