* 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
94 lines
3.3 KiB
C#
94 lines
3.3 KiB
C#
using Content.Shared.Actions;
|
|
using Content.Shared.Devour.Components;
|
|
using Content.Shared.DoAfter;
|
|
using Content.Shared.Mobs;
|
|
using Content.Shared.Mobs.Components;
|
|
using Content.Shared.Popups;
|
|
using Robust.Shared.Audio;
|
|
using Robust.Shared.Audio.Systems;
|
|
using Robust.Shared.Containers;
|
|
using Robust.Shared.Serialization;
|
|
|
|
namespace Content.Shared.Devour;
|
|
|
|
public abstract class SharedDevourSystem : EntitySystem
|
|
{
|
|
[Dependency] protected readonly SharedAudioSystem _audioSystem = default!;
|
|
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
|
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
|
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
|
|
[Dependency] protected readonly SharedContainerSystem ContainerSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<DevourerComponent, MapInitEvent>(OnInit);
|
|
SubscribeLocalEvent<DevourerComponent, DevourActionEvent>(OnDevourAction);
|
|
}
|
|
|
|
protected void OnInit(EntityUid uid, DevourerComponent component, MapInitEvent args)
|
|
{
|
|
//Devourer doesn't actually chew, since he sends targets right into his stomach.
|
|
//I did it mom, I added ERP content into upstream. Legally!
|
|
component.Stomach = ContainerSystem.EnsureContainer<Container>(uid, "stomach");
|
|
|
|
_actionsSystem.AddAction(uid, ref component.DevourActionEntity, component.DevourAction);
|
|
}
|
|
|
|
/// <summary>
|
|
/// The devour action
|
|
/// </summary>
|
|
protected void OnDevourAction(EntityUid uid, DevourerComponent component, DevourActionEvent args)
|
|
{
|
|
if (args.Handled || component.Whitelist?.IsValid(args.Target, EntityManager) != true)
|
|
return;
|
|
|
|
args.Handled = true;
|
|
var target = args.Target;
|
|
|
|
// Structure and mob devours handled differently.
|
|
if (TryComp(target, out MobStateComponent? targetState))
|
|
{
|
|
switch (targetState.CurrentState)
|
|
{
|
|
case MobState.Critical:
|
|
case MobState.Dead:
|
|
|
|
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, uid, component.DevourTime, new DevourDoAfterEvent(), uid, target: target, used: uid)
|
|
{
|
|
BreakOnMove = true,
|
|
});
|
|
break;
|
|
default:
|
|
_popupSystem.PopupClient(Loc.GetString("devour-action-popup-message-fail-target-alive"), uid,uid);
|
|
break;
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
_popupSystem.PopupClient(Loc.GetString("devour-action-popup-message-structure"), uid, uid);
|
|
|
|
if (component.SoundStructureDevour != null)
|
|
_audioSystem.PlayPredicted(component.SoundStructureDevour, uid, uid, component.SoundStructureDevour.Params);
|
|
|
|
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, uid, component.StructureDevourTime, new DevourDoAfterEvent(), uid, target: target, used: uid)
|
|
{
|
|
BreakOnMove = true,
|
|
});
|
|
}
|
|
}
|
|
|
|
public sealed partial class DevourActionEvent : EntityTargetActionEvent { }
|
|
|
|
[Serializable, NetSerializable]
|
|
public sealed partial class DevourDoAfterEvent : SimpleDoAfterEvent { }
|
|
|
|
[Serializable, NetSerializable]
|
|
public enum FoodPreference : byte
|
|
{
|
|
Humanoid = 0,
|
|
All = 1
|
|
}
|