@@ -7,6 +7,7 @@ using Content.Server.Mech.Systems;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Mech;
|
||||
using Content.Shared.Mech.Equipment.Components;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.Wall;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Map;
|
||||
@@ -115,17 +116,17 @@ public sealed class MechGrabberSystem : EntitySystem
|
||||
|
||||
private void OnInteract(EntityUid uid, MechGrabberComponent component, InteractNoHandEvent args)
|
||||
{
|
||||
if (args.Handled || args.Target == null)
|
||||
if (args.Handled || args.Target is not {} target)
|
||||
return;
|
||||
|
||||
var xform = Transform(args.Target.Value);
|
||||
if (xform.Anchored || HasComp<WallMountComponent>(args.Target.Value))
|
||||
var xform = Transform(target);
|
||||
if (xform.Anchored || HasComp<WallMountComponent>(target) || HasComp<MobStateComponent>(target))
|
||||
return;
|
||||
|
||||
if (component.ItemContainer.ContainedEntities.Count >= component.MaxContents)
|
||||
return;
|
||||
|
||||
if (!TryComp<MechComponent>(args.User, out var mech))
|
||||
if (!TryComp<MechComponent>(args.User, out var mech) || mech.PilotSlot.ContainedEntity == target)
|
||||
return;
|
||||
|
||||
if (mech.Energy + component.GrabEnergyDelta < 0)
|
||||
@@ -134,17 +135,17 @@ public sealed class MechGrabberSystem : EntitySystem
|
||||
if (component.Token != null)
|
||||
return;
|
||||
|
||||
if (!_interaction.InRangeUnobstructed(args.User, args.Target.Value))
|
||||
if (!_interaction.InRangeUnobstructed(args.User, target))
|
||||
return;
|
||||
|
||||
args.Handled = true;
|
||||
component.Token = new();
|
||||
component.AudioStream = _audio.PlayPvs(component.GrabSound, uid);
|
||||
_doAfter.DoAfter(new DoAfterEventArgs(args.User, component.GrabDelay, component.Token.Token, args.Target, uid)
|
||||
_doAfter.DoAfter(new DoAfterEventArgs(args.User, component.GrabDelay, component.Token.Token, target, uid)
|
||||
{
|
||||
BreakOnTargetMove = true,
|
||||
BreakOnUserMove = true,
|
||||
UsedFinishedEvent = new MechGrabberGrabFinishedEvent(args.Target.Value),
|
||||
UsedFinishedEvent = new MechGrabberGrabFinishedEvent(target),
|
||||
UsedCancelledEvent = new MechGrabberGrabCancelledEvent()
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Mech.Components;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Tools;
|
||||
using Content.Server.Wires;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.FixedPoint;
|
||||
@@ -52,6 +53,7 @@ public sealed class MechSystem : SharedMechSystem
|
||||
SubscribeLocalEvent<MechComponent, DamageChangedEvent>(OnDamageChanged);
|
||||
SubscribeLocalEvent<MechComponent, MechEquipmentRemoveMessage>(OnRemoveEquipmentMessage);
|
||||
|
||||
SubscribeLocalEvent<MechPilotComponent, ToolUserAttemptUseEvent>(OnToolUseAttempt);
|
||||
SubscribeLocalEvent<MechPilotComponent, InhaleLocationEvent>(OnInhale);
|
||||
SubscribeLocalEvent<MechPilotComponent, ExhaleLocationEvent>(OnExhale);
|
||||
SubscribeLocalEvent<MechPilotComponent, AtmosExposedGetAirEvent>(OnExpose);
|
||||
@@ -137,6 +139,12 @@ public sealed class MechSystem : SharedMechSystem
|
||||
ToggleMechUi(uid, component);
|
||||
}
|
||||
|
||||
private void OnToolUseAttempt(EntityUid uid, MechPilotComponent component, ref ToolUserAttemptUseEvent args)
|
||||
{
|
||||
if (args.Target == component.Mech)
|
||||
args.Cancelled = true;
|
||||
}
|
||||
|
||||
private void OnAlternativeVerb(EntityUid uid, MechComponent component, GetVerbsEvent<AlternativeVerb> args)
|
||||
{
|
||||
if (!args.CanAccess || !args.CanInteract || component.Broken)
|
||||
|
||||
@@ -119,6 +119,11 @@ namespace Content.Server.Tools
|
||||
if (!Resolve(tool, ref toolComponent, false))
|
||||
return false;
|
||||
|
||||
var ev = new ToolUserAttemptUseEvent(user, target);
|
||||
RaiseLocalEvent(user, ref ev);
|
||||
if (ev.Cancelled)
|
||||
return false;
|
||||
|
||||
if (!ToolStartUse(tool, user, fuel, toolQualitiesNeeded, toolComponent))
|
||||
return false;
|
||||
|
||||
@@ -173,6 +178,11 @@ namespace Content.Server.Tools
|
||||
if (!Resolve(tool, ref toolComponent, false))
|
||||
return false;
|
||||
|
||||
var ev = new ToolUserAttemptUseEvent(user, target);
|
||||
RaiseLocalEvent(user, ref ev);
|
||||
if (ev.Cancelled)
|
||||
return false;
|
||||
|
||||
if (!ToolStartUse(tool, user, fuel, toolQualitiesNeeded, toolComponent))
|
||||
return false;
|
||||
|
||||
@@ -306,6 +316,23 @@ namespace Content.Server.Tools
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event raised on the user of a tool to see if they can actually use it.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public struct ToolUserAttemptUseEvent
|
||||
{
|
||||
public EntityUid User;
|
||||
public EntityUid? Target;
|
||||
public bool Cancelled = false;
|
||||
|
||||
public ToolUserAttemptUseEvent(EntityUid user, EntityUid? target)
|
||||
{
|
||||
User = user;
|
||||
Target = target;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempt event called *after* any do afters to see if the tool usage should succeed or not.
|
||||
/// You can use this event to consume any fuel needed.
|
||||
|
||||
@@ -4,9 +4,9 @@ using Content.Shared.Access.Systems;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Destructible;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Components;
|
||||
using Content.Shared.Interaction.Events;
|
||||
@@ -18,7 +18,6 @@ using Content.Shared.Popups;
|
||||
using Content.Shared.Weapons.Melee;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
@@ -374,7 +373,7 @@ public abstract class SharedMechSystem : EntitySystem
|
||||
if (!Resolve(uid, ref component))
|
||||
return false;
|
||||
|
||||
return IsEmpty(component) && _actionBlocker.CanMove(toInsert) && HasComp<BodyComponent>(toInsert);
|
||||
return IsEmpty(component) && _actionBlocker.CanMove(toInsert) && HasComp<SharedHandsComponent>(toInsert);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
mech-verb-enter = Enter
|
||||
mech-verb-exit = Exit
|
||||
mech-verb-exit = Remove pilot
|
||||
|
||||
mech-equipment-begin-install = Installing the {THE($item)}...
|
||||
mech-equipment-finish-install = Finished installing the {THE($item)}
|
||||
|
||||
Reference in New Issue
Block a user