mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-08 15:27:27 +00:00
* Fix Standing up when Exiting Critical State (#1612) <!-- Guidelines: https://docs.spacestation14.io/en/getting-started/pr-guideline --> <!-- NOTE: All code submitted to this repository is ALWAYS licensed under the AGPL-3.0-or-later license. The REUSE Specification headers or separate .license files indicate a secondary license (e.g., MPL or MIT) solely to facilitate integration for projects that do not use the AGPL license. This secondary license does not replace the fact that AGPL-3.0-or-later remains the primary and binding license. Uncomment and modify the following line if you wish to change the license from the default of AGPL.--> <!--- LICENSE: AGPL --> <!-- What did you change? --> Made buckled Entities not stand up when recovering from critical state. <!-- Discuss how this would affect game balance or explain why it was changed. Link any relevant discussions or issues. --> Just generally annoying having to buckle your patient again - Or have them unbuckle from your rollerbed as you ferry them. <!-- Summary of code changes for easier review. --> Removed redunancies and inserted a check for being buckled before calling the method to stand up when entering the Alive state. <!-- Attach media if the PR makes ingame changes (clothing, items, features, etc). Small fixes/refactors are exempt. Media may be used in SS14 progress reports with credit. --> <img width="104" height="148" alt="grafik" src="https://github.com/user-attachments/assets/c26009f1-e46e-46ae-bd2e-f89f7431dc07" /> <!-- Confirm the following by placing an X in the brackets [X]: --> - [X] I have read and am following the [Pull Request and Changelog Guidelines](https://docs.spacestation14.com/en/general-development/codebase-info/pull-request-guidelines.html). - [X] I have added media to this PR or it does not require an ingame showcase. - [X] I have tested any changes or additions. - [X] I can confirm this PR contains no AI-generated content, and did not use any AI-generated content. <!-- You should understand that not following the above may get your PR closed at maintainer’s discretion --> <!-- List any breaking changes, including namespaces, public class/method/field changes, prototype renames; and provide instructions for fixing them. This will be posted in #codebase-changes. --> **Changelog** <!-- Add a Changelog entry to make players aware of new features or changes that could affect gameplay. Make sure to read the guidelines and take this Changelog template out of the comment block in order for it to show up. Changelog must have a 🆑 symbol, so the bot recognizes the changes and adds them to the game's changelog. --> 🆑 - fix: Fixed buckled patients standing up when recovering from crit. Now they'll stay seated. * Small fix * Add Comments Signed-off-by: Sir Warock <67167466+SirWarock@users.noreply.github.com> * Fix comment? * Returned Useless Import * Update Content.Shared/Mobs/Systems/MobStateSystem.Subscribers.cs Co-authored-by: Quanteey <61941975+Quanteey@users.noreply.github.com> Signed-off-by: Sir Warock <67167466+SirWarock@users.noreply.github.com> * Update Content.Shared/Mobs/Systems/MobStateSystem.Subscribers.cs Co-authored-by: Quanteey <61941975+Quanteey@users.noreply.github.com> Signed-off-by: Sir Warock <67167466+SirWarock@users.noreply.github.com> * Update Content.Shared/Mobs/Systems/MobStateSystem.Subscribers.cs Co-authored-by: Quanteey <61941975+Quanteey@users.noreply.github.com> Signed-off-by: Sir Warock <67167466+SirWarock@users.noreply.github.com> --------- Signed-off-by: Sir Warock <67167466+SirWarock@users.noreply.github.com> Co-authored-by: Quanteey <61941975+Quanteey@users.noreply.github.com>
200 lines
7.7 KiB
C#
200 lines
7.7 KiB
C#
using Content.Shared.Bed.Sleep;
|
|
using Content.Shared.Buckle.Components;
|
|
using Content.Shared.CombatMode.Pacification;
|
|
using Content.Shared.Damage;
|
|
using Content.Shared.Damage.ForceSay;
|
|
using Content.Shared.Emoting;
|
|
using Content.Shared.Hands;
|
|
using Content.Shared.Interaction;
|
|
using Content.Shared.Interaction.Events;
|
|
using Content.Shared.Inventory.Events;
|
|
using Content.Shared.Item;
|
|
using Content.Shared.Mobs.Components;
|
|
using Content.Shared.Movement.Events;
|
|
using Content.Shared.Pointing;
|
|
using Content.Shared.Pulling.Events;
|
|
using Content.Shared.Speech;
|
|
using Content.Shared.Standing;
|
|
using Content.Shared.Strip.Components;
|
|
using Content.Shared.Throwing;
|
|
using Robust.Shared.Physics.Components;
|
|
|
|
namespace Content.Shared.Mobs.Systems;
|
|
|
|
public partial class MobStateSystem
|
|
{
|
|
//General purpose event subscriptions. If you can avoid it register these events inside their own systems
|
|
private void SubscribeEvents()
|
|
{
|
|
SubscribeLocalEvent<MobStateComponent, BeforeGettingStrippedEvent>(OnGettingStripped);
|
|
SubscribeLocalEvent<MobStateComponent, ChangeDirectionAttemptEvent>(CheckAct);
|
|
SubscribeLocalEvent<MobStateComponent, UseAttemptEvent>(CheckAct);
|
|
SubscribeLocalEvent<MobStateComponent, AttackAttemptEvent>(CheckAct);
|
|
SubscribeLocalEvent<MobStateComponent, ConsciousAttemptEvent>(CheckConcious);
|
|
SubscribeLocalEvent<MobStateComponent, ThrowAttemptEvent>(CheckAct);
|
|
SubscribeLocalEvent<MobStateComponent, SpeakAttemptEvent>(OnSpeakAttempt);
|
|
SubscribeLocalEvent<MobStateComponent, IsEquippingAttemptEvent>(OnEquipAttempt);
|
|
SubscribeLocalEvent<MobStateComponent, EmoteAttemptEvent>(CheckAct);
|
|
SubscribeLocalEvent<MobStateComponent, IsUnequippingAttemptEvent>(OnUnequipAttempt);
|
|
SubscribeLocalEvent<MobStateComponent, DropAttemptEvent>(CheckAct);
|
|
SubscribeLocalEvent<MobStateComponent, PickupAttemptEvent>(CheckAct);
|
|
SubscribeLocalEvent<MobStateComponent, StartPullAttemptEvent>(CheckAct);
|
|
SubscribeLocalEvent<MobStateComponent, UpdateCanMoveEvent>(CheckAct);
|
|
SubscribeLocalEvent<MobStateComponent, StandAttemptEvent>(CheckAct);
|
|
SubscribeLocalEvent<MobStateComponent, PointAttemptEvent>(CheckAct);
|
|
SubscribeLocalEvent<MobStateComponent, TryingToSleepEvent>(OnSleepAttempt);
|
|
SubscribeLocalEvent<MobStateComponent, CombatModeShouldHandInteractEvent>(OnCombatModeShouldHandInteract);
|
|
SubscribeLocalEvent<MobStateComponent, AttemptPacifiedAttackEvent>(OnAttemptPacifiedAttack);
|
|
SubscribeLocalEvent<MobStateComponent, DamageModifyEvent>(OnDamageModify);
|
|
|
|
SubscribeLocalEvent<MobStateComponent, UnbuckleAttemptEvent>(OnUnbuckleAttempt);
|
|
}
|
|
|
|
private void OnUnbuckleAttempt(Entity<MobStateComponent> ent, ref UnbuckleAttemptEvent args)
|
|
{
|
|
// TODO is this necessary?
|
|
// Shouldn't the interaction have already been blocked by a general interaction check?
|
|
if (args.User == ent.Owner && IsIncapacitated(ent))
|
|
args.Cancelled = true;
|
|
}
|
|
|
|
private void CheckConcious(Entity<MobStateComponent> ent, ref ConsciousAttemptEvent args)
|
|
{
|
|
switch (ent.Comp.CurrentState)
|
|
{
|
|
case MobState.Dead:
|
|
case MobState.Critical:
|
|
args.Cancelled = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void OnStateExitSubscribers(EntityUid target, MobStateComponent component, MobState state)
|
|
{
|
|
switch (state)
|
|
{
|
|
case MobState.Alive:
|
|
//unused
|
|
break;
|
|
case MobState.Critical:
|
|
//_standing.Stand(target); // DeltaV - Remove Redundancy
|
|
break;
|
|
case MobState.Dead:
|
|
RemComp<CollisionWakeComponent>(target);
|
|
//_standing.Stand(target); // DeltaV - Remove Redundancy
|
|
break;
|
|
case MobState.Invalid:
|
|
//unused
|
|
break;
|
|
default:
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
|
|
private void OnStateEnteredSubscribers(EntityUid target, MobStateComponent component, MobState state)
|
|
{
|
|
// All of the state changes here should already be networked, so we do nothing if we are currently applying a
|
|
// server state.
|
|
if (_timing.ApplyingState)
|
|
return;
|
|
|
|
_blocker.UpdateCanMove(target); //update movement anytime a state changes
|
|
switch (state)
|
|
{
|
|
case MobState.Alive:
|
|
if (!TryComp(target, out BuckleComponent? buckle)
|
|
|| !buckle.Buckled) // DeltaV - Stop buckled mobs from standing up.
|
|
_standing.Stand(target);
|
|
_appearance.SetData(target, MobStateVisuals.State, MobState.Alive);
|
|
break;
|
|
case MobState.Critical:
|
|
_standing.Down(target);
|
|
_appearance.SetData(target, MobStateVisuals.State, MobState.Critical);
|
|
break;
|
|
case MobState.Dead:
|
|
EnsureComp<CollisionWakeComponent>(target);
|
|
_standing.Down(target);
|
|
_appearance.SetData(target, MobStateVisuals.State, MobState.Dead);
|
|
break;
|
|
case MobState.Invalid:
|
|
//unused;
|
|
break;
|
|
default:
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
|
|
#region Event Subscribers
|
|
|
|
private void OnSleepAttempt(EntityUid target, MobStateComponent component, ref TryingToSleepEvent args)
|
|
{
|
|
if (IsDead(target, component))
|
|
args.Cancelled = true;
|
|
}
|
|
|
|
private void OnGettingStripped(EntityUid target, MobStateComponent component, BeforeGettingStrippedEvent args)
|
|
{
|
|
// Incapacitated or dead targets get stripped two or three times as fast. Makes stripping corpses less tedious.
|
|
if (IsDead(target, component))
|
|
args.Multiplier /= 3;
|
|
else if (IsCritical(target, component))
|
|
args.Multiplier /= 2;
|
|
}
|
|
|
|
private void OnSpeakAttempt(EntityUid uid, MobStateComponent component, SpeakAttemptEvent args)
|
|
{
|
|
if (HasComp<AllowNextCritSpeechComponent>(uid))
|
|
{
|
|
RemCompDeferred<AllowNextCritSpeechComponent>(uid);
|
|
return;
|
|
}
|
|
|
|
CheckAct(uid, component, args);
|
|
}
|
|
|
|
private void CheckAct(EntityUid target, MobStateComponent component, CancellableEntityEventArgs args)
|
|
{
|
|
switch (component.CurrentState)
|
|
{
|
|
case MobState.Dead:
|
|
case MobState.Critical:
|
|
args.Cancel();
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void OnEquipAttempt(EntityUid target, MobStateComponent component, IsEquippingAttemptEvent args)
|
|
{
|
|
// is this a self-equip, or are they being stripped?
|
|
if (args.Equipee == target)
|
|
CheckAct(target, component, args);
|
|
}
|
|
|
|
private void OnUnequipAttempt(EntityUid target, MobStateComponent component, IsUnequippingAttemptEvent args)
|
|
{
|
|
// is this a self-equip, or are they being stripped?
|
|
if (args.Unequipee == target)
|
|
CheckAct(target, component, args);
|
|
}
|
|
|
|
private void OnCombatModeShouldHandInteract(EntityUid uid, MobStateComponent component, ref CombatModeShouldHandInteractEvent args)
|
|
{
|
|
// Disallow empty-hand-interacting in combat mode
|
|
// for non-dead mobs
|
|
if (!IsDead(uid, component))
|
|
args.Cancelled = true;
|
|
}
|
|
|
|
private void OnAttemptPacifiedAttack(Entity<MobStateComponent> ent, ref AttemptPacifiedAttackEvent args)
|
|
{
|
|
args.Cancelled = true;
|
|
}
|
|
|
|
private void OnDamageModify(Entity<MobStateComponent> ent, ref DamageModifyEvent args)
|
|
{
|
|
args.Damage *= _damageable.UniversalMobDamageModifier;
|
|
}
|
|
|
|
#endregion
|
|
}
|