* Merge BreakOnWeightlessMove and BreakOnMove. Provide different theshold for weightless movement. * Adjust WeightlessMovementThresholds. Put a thing I forgot to put in the doafterargs. * Make DoAfterArgs only use OnMove to determine whether to check for movement and MoveThreshold to determine the threshold regardless of weightlessness. Gave DistanceThreshold a default value which will always be checked now. * Fix issue introduced by merge. * Use interaction system for determining whether a distance is within range * Fix incorrect doafter args introduced by previous merge. Forgor to commit these. * Exorcise ghost. The execution system should have been deleted when I merged previously. For a reason I cannot comprehend it came back, but only the execution system. * Exorcise ghost Pt. 2 * Allow for movement check to be overriden in zero g and adjust doafter args where needed. You can now override checking for movement in zero g with the BreakOnWeightlessMove bool. By default it will check. The following doafters were made to ignore the movement check in zero g: - Healing yourself with healing items, - Removing embedded projectiles, - Using tools like welders and crowbars * Adjust distance for cuffing/uncuffing to work. Make injections not break on weightless movement. * Fix evil incorrect and uneeded comments
92 lines
2.7 KiB
C#
92 lines
2.7 KiB
C#
using Content.Shared.DoAfter;
|
|
using Content.Shared.Interaction;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Wires;
|
|
using Robust.Shared.Audio;
|
|
|
|
namespace Content.Shared.VendingMachines;
|
|
|
|
public abstract partial class SharedVendingMachineSystem
|
|
{
|
|
public bool TryAccessMachine(EntityUid uid,
|
|
VendingMachineRestockComponent restock,
|
|
VendingMachineComponent machineComponent,
|
|
EntityUid user,
|
|
EntityUid target)
|
|
{
|
|
if (!TryComp<WiresPanelComponent>(target, out var panel) || !panel.Open)
|
|
{
|
|
if (_net.IsServer)
|
|
{
|
|
Popup.PopupCursor(Loc.GetString("vending-machine-restock-needs-panel-open",
|
|
("this", uid),
|
|
("user", user),
|
|
("target", target)),
|
|
user);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public bool TryMatchPackageToMachine(EntityUid uid,
|
|
VendingMachineRestockComponent component,
|
|
VendingMachineComponent machineComponent,
|
|
EntityUid user,
|
|
EntityUid target)
|
|
{
|
|
if (!component.CanRestock.Contains(machineComponent.PackPrototypeId))
|
|
{
|
|
if (_net.IsServer)
|
|
{
|
|
Popup.PopupCursor(Loc.GetString("vending-machine-restock-invalid-inventory", ("this", uid), ("user", user),
|
|
("target", target)), user);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
private void OnAfterInteract(EntityUid uid, VendingMachineRestockComponent component, AfterInteractEvent args)
|
|
{
|
|
if (args.Target is not { } target || !args.CanReach || args.Handled)
|
|
return;
|
|
|
|
if (!TryComp<VendingMachineComponent>(args.Target, out var machineComponent))
|
|
return;
|
|
|
|
if (!TryMatchPackageToMachine(uid, component, machineComponent, args.User, target))
|
|
return;
|
|
|
|
if (!TryAccessMachine(uid, component, machineComponent, args.User, target))
|
|
return;
|
|
|
|
args.Handled = true;
|
|
|
|
var doAfterArgs = new DoAfterArgs(EntityManager, args.User, (float) component.RestockDelay.TotalSeconds, new RestockDoAfterEvent(), target,
|
|
target: target, used: uid)
|
|
{
|
|
BreakOnMove = true,
|
|
BreakOnDamage = true,
|
|
NeedHand = true
|
|
};
|
|
|
|
if (!_doAfter.TryStartDoAfter(doAfterArgs))
|
|
return;
|
|
|
|
if (_net.IsServer)
|
|
{
|
|
Popup.PopupEntity(Loc.GetString("vending-machine-restock-start", ("this", uid), ("user", args.User),
|
|
("target", target)),
|
|
args.User,
|
|
PopupType.Medium);
|
|
}
|
|
|
|
Audio.PlayPredicted(component.SoundRestockStart, uid, args.User);
|
|
}
|
|
}
|