Proto-kinetic crusher (#16277)

Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com>
This commit is contained in:
metalgearsloth
2023-05-14 13:15:18 +10:00
committed by GitHub
parent 356bf96039
commit 6417bb4fa0
68 changed files with 926 additions and 312 deletions

View File

@@ -1,8 +1,5 @@
using Content.Server.Actions;
using Content.Server.Popups;
using Content.Server.PowerCell;
using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Light;
@@ -11,10 +8,7 @@ using Content.Shared.Toggleable;
using Content.Shared.Verbs;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
@@ -37,7 +31,6 @@ namespace Content.Server.Light.EntitySystems
{
base.Initialize();
SubscribeLocalEvent<HandheldLightComponent, ComponentRemove>(OnRemove);
SubscribeLocalEvent<HandheldLightComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<HandheldLightComponent, ExaminedEvent>(OnExamine);
@@ -45,41 +38,7 @@ namespace Content.Server.Light.EntitySystems
SubscribeLocalEvent<HandheldLightComponent, ActivateInWorldEvent>(OnActivate);
SubscribeLocalEvent<HandheldLightComponent, GetItemActionsEvent>(OnGetActions);
SubscribeLocalEvent<HandheldLightComponent, ToggleActionEvent>(OnToggleAction);
SubscribeLocalEvent<HandheldLightComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
SubscribeLocalEvent<HandheldLightComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
}
private void OnEntInserted(
EntityUid uid,
HandheldLightComponent component,
EntInsertedIntoContainerMessage args)
{
// Not guaranteed to be the correct container for our slot, I don't care.
UpdateLevel(uid, component);
}
private void OnEntRemoved(
EntityUid uid,
HandheldLightComponent component,
EntRemovedFromContainerMessage args)
{
// Ditto above
UpdateLevel(uid, component);
}
private void OnGetActions(EntityUid uid, HandheldLightComponent component, GetItemActionsEvent args)
{
if (component.ToggleAction == null
&& _proto.TryIndex(component.ToggleActionId, out InstantActionPrototype? act))
{
component.ToggleAction = new(act);
}
if (component.ToggleAction != null)
args.Actions.Add(component.ToggleAction);
}
private void OnToggleAction(EntityUid uid, HandheldLightComponent component, ToggleActionEvent args)
@@ -114,11 +73,6 @@ namespace Content.Server.Light.EntitySystems
return (byte?) ContentHelpers.RoundToNearestLevels(battery.CurrentCharge / battery.MaxCharge * 255, 255, HandheldLightComponent.StatusLevels);
}
private void OnRemove(EntityUid uid, HandheldLightComponent component, ComponentRemove args)
{
_activeLights.Remove(component);
}
private void OnActivate(EntityUid uid, HandheldLightComponent component, ActivateInWorldEvent args)
{
if (args.Handled)
@@ -144,36 +98,6 @@ namespace Content.Server.Light.EntitySystems
: Loc.GetString("handheld-light-component-on-examine-is-off-message"));
}
public override void Shutdown()
{
base.Shutdown();
_activeLights.Clear();
}
public override void Update(float frameTime)
{
var toRemove = new RemQueue<HandheldLightComponent>();
foreach (var handheld in _activeLights)
{
var uid = handheld.Owner;
if (handheld.Deleted)
{
toRemove.Add(handheld);
continue;
}
if (Paused(uid)) continue;
TryUpdate(uid, handheld, frameTime);
}
foreach (var light in toRemove)
{
_activeLights.Remove(light);
}
}
private void AddToggleLightVerb(EntityUid uid, HandheldLightComponent component, GetVerbsEvent<ActivationVerb> args)
{
if (!args.CanAccess || !args.CanInteract)