Better Godmode (#37020)
* Commit * Oversights oops * breaking changes * unbreaking changes * Compatibility with AfterFullyEaten * Fixed * Update Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs --------- Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
4407eab96b
commit
62c380fc53
@@ -12,6 +12,7 @@ using Content.Shared.Movement.Systems;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Timing;
|
||||
using System.Numerics;
|
||||
using Content.Shared.Damage.Components;
|
||||
|
||||
namespace Content.Server.Body.Systems;
|
||||
|
||||
@@ -110,6 +111,9 @@ public sealed class BodySystem : SharedBodySystem
|
||||
return new HashSet<EntityUid>();
|
||||
}
|
||||
|
||||
if (HasComp<GodmodeComponent>(bodyId))
|
||||
return new HashSet<EntityUid>();
|
||||
|
||||
var xform = Transform(bodyId);
|
||||
if (xform.MapUid is null)
|
||||
return new HashSet<EntityUid>();
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Server.Destructible;
|
||||
using Content.Server.Examine;
|
||||
using Content.Server.Polymorph.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Body.Components;
|
||||
@@ -24,6 +26,7 @@ public sealed class ImmovableRodSystem : EntitySystem
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly DamageableSystem _damageable = default!;
|
||||
[Dependency] private readonly DestructibleSystem _destructible = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly SharedMapSystem _map = default!;
|
||||
|
||||
@@ -127,7 +130,7 @@ public sealed class ImmovableRodSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
QueueDel(ent);
|
||||
_destructible.DestroyEntity(ent);
|
||||
}
|
||||
|
||||
private void OnExamined(EntityUid uid, ImmovableRodComponent component, ExaminedEvent args)
|
||||
|
||||
@@ -20,6 +20,7 @@ using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Timing;
|
||||
using System.Linq;
|
||||
using Content.Server.Construction.Completions;
|
||||
using Content.Server.Jittering;
|
||||
using Content.Shared.Jittering;
|
||||
using Content.Shared.Power;
|
||||
@@ -38,6 +39,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||
[Dependency] private readonly SharedDestructibleSystem _destructible = default!;
|
||||
[Dependency] private readonly RandomHelperSystem _randomHelper = default!;
|
||||
[Dependency] private readonly JitteringSystem _jitter = default!;
|
||||
|
||||
@@ -123,10 +125,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
if (solution.Volume > containerSolution.AvailableVolume)
|
||||
continue;
|
||||
|
||||
var dev = new DestructionEventArgs();
|
||||
RaiseLocalEvent(item, dev);
|
||||
|
||||
QueueDel(item);
|
||||
_destructible.DestroyEntity(item);
|
||||
}
|
||||
|
||||
_solutionContainersSystem.TryAddSolution(containerSoln.Value, solution);
|
||||
|
||||
@@ -52,6 +52,7 @@ public sealed class FoodSystem : EntitySystem
|
||||
[Dependency] private readonly ReactiveSystem _reaction = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
|
||||
[Dependency] private readonly SharedDestructibleSystem _destructible = default!;
|
||||
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
||||
[Dependency] private readonly SharedInteractionSystem _interaction = default!;
|
||||
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
|
||||
@@ -336,6 +337,11 @@ public sealed class FoodSystem : EntitySystem
|
||||
if (ev.Cancelled)
|
||||
return;
|
||||
|
||||
var attemptEv = new DestructionAttemptEvent();
|
||||
RaiseLocalEvent(food, attemptEv);
|
||||
if (attemptEv.Cancelled)
|
||||
return;
|
||||
|
||||
var afterEvent = new AfterFullyEatenEvent(user);
|
||||
RaiseLocalEvent(food, ref afterEvent);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.Damage.Events;
|
||||
using Content.Shared.Destructible;
|
||||
using Content.Shared.Rejuvenate;
|
||||
using Content.Shared.Slippery;
|
||||
using Content.Shared.StatusEffect;
|
||||
@@ -18,6 +19,7 @@ public abstract class SharedGodmodeSystem : EntitySystem
|
||||
SubscribeLocalEvent<GodmodeComponent, BeforeStatusEffectAddedEvent>(OnBeforeStatusEffect);
|
||||
SubscribeLocalEvent<GodmodeComponent, BeforeStaminaDamageEvent>(OnBeforeStaminaDamage);
|
||||
SubscribeLocalEvent<GodmodeComponent, SlipAttemptEvent>(OnSlipAttempt);
|
||||
SubscribeLocalEvent<GodmodeComponent, DestructionAttemptEvent>(OnDestruction);
|
||||
}
|
||||
|
||||
private void OnSlipAttempt(EntityUid uid, GodmodeComponent component, SlipAttemptEvent args)
|
||||
@@ -40,6 +42,11 @@ public abstract class SharedGodmodeSystem : EntitySystem
|
||||
args.Cancelled = true;
|
||||
}
|
||||
|
||||
private void OnDestruction(Entity<GodmodeComponent> ent, ref DestructionAttemptEvent args)
|
||||
{
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
public virtual void EnableGodmode(EntityUid uid, GodmodeComponent? godmode = null)
|
||||
{
|
||||
godmode ??= EnsureComp<GodmodeComponent>(uid);
|
||||
|
||||
@@ -5,12 +5,18 @@ public abstract class SharedDestructibleSystem : EntitySystem
|
||||
/// <summary>
|
||||
/// Force entity to be destroyed and deleted.
|
||||
/// </summary>
|
||||
public void DestroyEntity(EntityUid owner)
|
||||
public bool DestroyEntity(EntityUid owner)
|
||||
{
|
||||
var eventArgs = new DestructionEventArgs();
|
||||
var ev = new DestructionAttemptEvent();
|
||||
RaiseLocalEvent(owner, ev);
|
||||
if (ev.Cancelled)
|
||||
return false;
|
||||
|
||||
var eventArgs = new DestructionEventArgs();
|
||||
RaiseLocalEvent(owner, eventArgs);
|
||||
|
||||
QueueDel(owner);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -23,6 +29,14 @@ public abstract class SharedDestructibleSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised before an entity is about to be destroyed and deleted
|
||||
/// </summary>
|
||||
public sealed class DestructionAttemptEvent : CancellableEntityEventArgs
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised when entity is destroyed and about to be deleted.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user