Exosuit: Ripley (#12668)
* mechs * interaction relay * atmos handling * fuck around with interaction events SPAGHETTI CODE OH MY GOD * more sprites and whatever the hell * more mech shit * more shit for equipment * starting equipment (for nukie mechs and such) * equipment cycling * starting with some of the ui * a fat chunk of ui prototyping * done tinkering with ui * a bunch of ui stuff and what have yous * cleaning up grabber and state handling * make the ui actually functional + watch me port a million icons I swear i'll prune the sprites later blease * start on construction * construction yo mamma * remove some unused files * fix a silly * make the graph sane * make it actually constructible. * print the boards as well, bozo * rebalance part prices * eject action also i appease the russians by remembering to localize * Punch Shit * make mech integrity and repairs work * Make the UI more based STOMP STOMP STOMP STOMP * make equipment even more based * batteries and other such delights * make the ui look pimpin af * make the construction mega based * UI but so epic * equipment * some sweat tweaks * damage rebalancing * restructure tech * fix some shit * mechs inherit access * make icons actually use sprite specifiers * TRAILING COMMAA!!!!! * fix a mild indentation sin * undo this change because it isn't needed * actually fix this * secret webeditting shhhh * place this tech here * comments * foo
This commit is contained in:
73
Content.Server/Mech/Systems/MechEquipmentSystem.cs
Normal file
73
Content.Server/Mech/Systems/MechEquipmentSystem.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Mech.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Mech.Equipment.Components;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.Mech.Systems;
|
||||
|
||||
/// <summary>
|
||||
/// Handles the insertion of mech equipment into mechs.
|
||||
/// </summary>
|
||||
public sealed class MechEquipmentSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly MechSystem _mech = default!;
|
||||
[Dependency] private readonly DoAfterSystem _doAfter = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<MechEquipmentComponent, AfterInteractEvent>(OnUsed);
|
||||
SubscribeLocalEvent<MechEquipmentComponent, MechEquipmentInstallFinished>(OnFinished);
|
||||
SubscribeLocalEvent<MechEquipmentComponent, MechEquipmentInstallCancelled>(OnCancelled);
|
||||
}
|
||||
|
||||
private void OnUsed(EntityUid uid, MechEquipmentComponent component, AfterInteractEvent args)
|
||||
{
|
||||
if (component.TokenSource != null)
|
||||
return;
|
||||
|
||||
if (args.Handled || !args.CanReach || args.Target == null)
|
||||
return;
|
||||
|
||||
var mech = args.Target.Value;
|
||||
if (!TryComp<MechComponent>(mech, out var mechComp))
|
||||
return;
|
||||
|
||||
if (args.User == mechComp.PilotSlot.ContainedEntity)
|
||||
return;
|
||||
|
||||
if (mechComp.EquipmentContainer.ContainedEntities.Count >= mechComp.MaxEquipmentAmount)
|
||||
return;
|
||||
|
||||
if (mechComp.EquipmentWhitelist != null && !mechComp.EquipmentWhitelist.IsValid(uid))
|
||||
return;
|
||||
|
||||
_popup.PopupEntity(Loc.GetString("mech-equipment-begin-install", ("item", uid)), mech, Filter.Pvs(mech));
|
||||
|
||||
component.TokenSource = new();
|
||||
_doAfter.DoAfter(new DoAfterEventArgs(args.User, component.InstallDuration, component.TokenSource.Token, mech, uid)
|
||||
{
|
||||
BreakOnStun = true,
|
||||
BreakOnTargetMove = true,
|
||||
BreakOnUserMove = true,
|
||||
UsedFinishedEvent = new MechEquipmentInstallFinished(mech),
|
||||
UsedCancelledEvent = new MechEquipmentInstallCancelled()
|
||||
});
|
||||
}
|
||||
|
||||
private void OnFinished(EntityUid uid, MechEquipmentComponent component, MechEquipmentInstallFinished args)
|
||||
{
|
||||
component.TokenSource = null;
|
||||
_popup.PopupEntity(Loc.GetString("mech-equipment-finish-install", ("item", uid)), args.Mech, Filter.Pvs(args.Mech));
|
||||
|
||||
_mech.InsertEquipment(args.Mech, uid);
|
||||
}
|
||||
|
||||
private void OnCancelled(EntityUid uid, MechEquipmentComponent component, MechEquipmentInstallCancelled args)
|
||||
{
|
||||
component.TokenSource = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user