Add verbs to Two Way Levers, make some odds and ends recyclable. (#12660)

This commit is contained in:
Mervill
2022-11-19 08:05:44 -08:00
committed by GitHub
parent 6a59e1b376
commit ac828008a3
9 changed files with 81 additions and 1 deletions

View File

@@ -17,6 +17,7 @@ using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.Player;
using Content.Server.Recycling.Components;
namespace Content.Server.Cuffs.Components
{
@@ -270,6 +271,8 @@ namespace Content.Server.Cuffs.Components
{
sprite.LayerSetState(0, cuff.BrokenState); // TODO: safety check to see if RSI contains the state?
}
_entMan.AddComponent<RecyclableComponent>(cuffsToRemove.Value);
}
CanStillInteract = _entMan.TryGetComponent(Owner, out HandsComponent? handsComponent) && handsComponent.SortedHands.Count() > CuffedHandCount;

View File

@@ -1,6 +1,7 @@
using Content.Server.MachineLinking.Components;
using Content.Shared.Interaction;
using Content.Shared.MachineLinking;
using Content.Shared.Verbs;
namespace Content.Server.MachineLinking.System
{
@@ -8,11 +9,15 @@ namespace Content.Server.MachineLinking.System
{
[Dependency] private readonly SignalLinkerSystem _signalSystem = default!;
const string _leftToggleImage = "rotate_ccw.svg.192dpi.png";
const string _rightToggleImage = "rotate_cw.svg.192dpi.png";
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<TwoWayLeverComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<TwoWayLeverComponent, ActivateInWorldEvent>(OnActivated);
SubscribeLocalEvent<TwoWayLeverComponent, GetVerbsEvent<InteractionVerb>>(OnGetInteractionVerbs);
}
private void OnInit(EntityUid uid, TwoWayLeverComponent component, ComponentInit args)
@@ -33,6 +38,56 @@ namespace Content.Server.MachineLinking.System
_ => throw new ArgumentOutOfRangeException()
};
StateChanged(uid, component);
args.Handled = true;
}
private void OnGetInteractionVerbs(EntityUid uid, TwoWayLeverComponent component, GetVerbsEvent<InteractionVerb> args)
{
InteractionVerb verbLeft = new()
{
Act = () =>
{
component.State = component.State switch
{
TwoWayLeverState.Middle => TwoWayLeverState.Left,
TwoWayLeverState.Right => TwoWayLeverState.Middle,
_ => throw new ArgumentOutOfRangeException()
};
StateChanged(uid, component);
},
Message = Loc.GetString("two-way-lever-cant"),
Disabled = component.State == TwoWayLeverState.Left,
IconTexture = $"/Textures/Interface/VerbIcons/{_leftToggleImage}",
Text = Loc.GetString("two-way-lever-left"),
};
args.Verbs.Add(verbLeft);
InteractionVerb verbRight = new()
{
Act = () =>
{
component.State = component.State switch
{
TwoWayLeverState.Left => TwoWayLeverState.Middle,
TwoWayLeverState.Middle => TwoWayLeverState.Right,
_ => throw new ArgumentOutOfRangeException()
};
StateChanged(uid, component);
},
Message = Loc.GetString("two-way-lever-cant"),
Disabled = component.State == TwoWayLeverState.Right,
IconTexture = $"/Textures/Interface/VerbIcons/{_rightToggleImage}",
Text = Loc.GetString("two-way-lever-right"),
};
args.Verbs.Add(verbRight);
}
private void StateChanged(EntityUid uid, TwoWayLeverComponent component)
{
if (component.State == TwoWayLeverState.Middle)
component.NextSignalLeft = !component.NextSignalLeft;
@@ -48,7 +103,6 @@ namespace Content.Server.MachineLinking.System
};
_signalSystem.InvokePort(uid, port);
args.Handled = true;
}
}
}

View File

@@ -43,5 +43,7 @@ namespace Content.Server.Recycling.Components
// Ratelimit sounds to avoid spam
public TimeSpan LastSound;
public int ItemsProcessed;
}
}

View File

@@ -8,6 +8,7 @@ using Content.Server.Recycling.Components;
using Content.Shared.Audio;
using Content.Shared.Body.Components;
using Content.Shared.Emag.Systems;
using Content.Shared.Examine;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction.Events;
using Content.Shared.Recycling;
@@ -33,11 +34,17 @@ namespace Content.Server.Recycling
public override void Initialize()
{
SubscribeLocalEvent<RecyclerComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<RecyclerComponent, StartCollideEvent>(OnCollide);
SubscribeLocalEvent<RecyclerComponent, GotEmaggedEvent>(OnEmagged);
SubscribeLocalEvent<RecyclerComponent, SuicideEvent>(OnSuicide);
}
private void OnExamined(EntityUid uid, RecyclerComponent component, ExaminedEvent args)
{
args.PushMarkup(Loc.GetString("recycler-count-items", ("items", component.ItemsProcessed)));
}
private void OnSuicide(EntityUid uid, RecyclerComponent component, SuicideEvent args)
{
if (args.Handled) return;
@@ -119,6 +126,8 @@ namespace Content.Server.Recycling
SoundSystem.Play(component.Sound.GetSound(), Filter.Pvs(component.Owner, entityManager: EntityManager), component.Owner, AudioHelpers.WithVariation(0.01f).WithVolume(-3));
component.LastSound = _timing.CurTime;
}
component.ItemsProcessed++;
}
private bool CanGib(RecyclerComponent component, EntityUid entity)

View File

@@ -11,3 +11,9 @@ machine-upgrade-not-upgraded = [color=yellow]{CAPITALIZE($upgraded)}[/color] not
upgrade-power-draw = power draw
upgrade-max-charge = max charge
upgrade-power-supply = power supply
two-way-lever-left = push left
two-way-lever-right = push right
two-way-lever-cant = can't push the lever that way!
recycler-count-items = Recycled {$items} objects.

View File

@@ -146,6 +146,7 @@
- type: Tag
tags:
- PetWearable
- type: Recyclable
- type: entity
parent: ClothingMaskBase

View File

@@ -23,6 +23,8 @@
reagents:
- ReagentId: Water
Quantity: 50
- type: TrashOnEmpty
solution: drink
- type: entity
parent: DrinkBase

View File

@@ -30,6 +30,7 @@
- Document
- type: Appearance
- type: PaperVisuals
- type: Recyclable
- type: entity
parent: Paper
@@ -76,6 +77,7 @@
sprite: Objects/Misc/bureaucracy.rsi
heldPrefix: pen
size: 2
- type: Recyclable
- type: entity
name: Cybersun pen

View File

@@ -12,3 +12,4 @@
sprite: Objects/Fun/toys.rsi
layers:
- state: foamdart
- type: Recyclable