forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some MobState Refactoring (space-wizards#1382)
# Description This PR does *some* refactoring of MobState in preparation for adding a more in-depth SoftCritical system, mostly adding code support for the new threshold existing in the first place. Additionally, the MobStateComponent now also includes several DataFields that allow more precise fine tuning of what all mobs are allowed to do in each state, as opposed to hardcoding a majority of these interactions. The actual SoftCritical state isn't currently used by anything, and so is a largely vestigial feature. It would have to be added individually to mobs, such as the BaseMobSpeciesOrganic when the time comes to actually add this feature. # Changelog :cl: - add: Lots of refactoring of the Mob State Systerm in preparation for implementing a much more detailed Soft Critical state. --------- Signed-off-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com>
- Loading branch information
1 parent
5767be1
commit 1e9cb1c
Showing
6 changed files
with
278 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,105 @@ | ||
using Content.Shared.Damage; | ||
using Content.Shared.Mobs.Systems; | ||
using Robust.Shared.GameStates; | ||
using Robust.Shared.Serialization; | ||
|
||
namespace Content.Shared.Mobs.Components | ||
namespace Content.Shared.Mobs.Components; | ||
|
||
/// <summary> | ||
/// When attached to an <see cref="DamageableComponent"/>, | ||
/// this component will handle critical and death behaviors for mobs. | ||
/// Additionally, it handles sending effects to clients | ||
/// (such as blur effect for unconsciousness) and managing the health HUD. | ||
/// </summary> | ||
[RegisterComponent] | ||
[NetworkedComponent] | ||
[AutoGenerateComponentState] | ||
public sealed partial class MobStateComponent : Component | ||
{ | ||
/// <summary> | ||
/// When attached to an <see cref="DamageableComponent"/>, | ||
/// this component will handle critical and death behaviors for mobs. | ||
/// Additionally, it handles sending effects to clients | ||
/// (such as blur effect for unconsciousness) and managing the health HUD. | ||
/// </summary> | ||
[RegisterComponent] | ||
[NetworkedComponent] | ||
[AutoGenerateComponentState] | ||
[Access(typeof(MobStateSystem), typeof(MobThresholdSystem))] | ||
public sealed partial class MobStateComponent : Component | ||
{ | ||
//default mobstate is always the lowest state level | ||
[AutoNetworkedField, ViewVariables] | ||
public MobState CurrentState { get; set; } = MobState.Alive; | ||
|
||
[DataField] | ||
[AutoNetworkedField] | ||
public HashSet<MobState> AllowedStates = new() | ||
{ | ||
MobState.Alive, | ||
MobState.Critical, | ||
MobState.Dead | ||
}; | ||
} | ||
/// Whether this mob will be allowed to issue movement commands when in the Critical MobState. | ||
/// </summary> | ||
[DataField] | ||
public bool AllowMovementWhileCrit; | ||
|
||
/// <summary> | ||
/// Whether this mob will be allowed to issue movement commands when in the Soft-Crit MobState. | ||
/// </summary> | ||
[DataField] | ||
public bool AllowMovementWhileSoftCrit; | ||
|
||
/// <summary> | ||
/// Whether this mob will be allowed to issue movement commands when in the Dead MobState. | ||
/// This is provided for completeness sake, and *probably* shouldn't be used by default. | ||
/// </summary> | ||
[DataField] | ||
public bool AllowMovementWhileDead; | ||
|
||
/// <summary> | ||
/// Whether this mob will be allowed to talk while in the Critical MobState. | ||
/// </summary> | ||
[DataField] | ||
public bool AllowTalkingWhileCrit = true; | ||
|
||
/// <summary> | ||
/// Whether this mob will be allowed to talk while in the SoftCritical MobState. | ||
/// </summary> | ||
[DataField] | ||
public bool AllowTalkingWhileSoftCrit = true; | ||
|
||
/// <summary> | ||
/// Whether this mob will be allowed to talk while in the Dead MobState. | ||
/// This is provided for completeness sake, and *probably* shouldn't be used by default. | ||
/// </summary> | ||
[DataField] | ||
public bool AllowTalkingWhileDead; | ||
|
||
/// <summary> | ||
/// Whether this mob is forced to be downed when entering the Critical MobState. | ||
/// </summary> | ||
[DataField] | ||
public bool DownWhenCrit = true; | ||
|
||
/// <summary> | ||
/// Whether this mob is forced to be downed when entering the SoftCritical MobState. | ||
/// </summary> | ||
[DataField] | ||
public bool DownWhenSoftCrit = true; | ||
|
||
/// <summary> | ||
/// Whether this mob is forced to be downed when entering the Dead MobState. | ||
/// </summary> | ||
[DataField] | ||
public bool DownWhenDead = true; | ||
|
||
/// <summary> | ||
/// Whether this mob is allowed to perform hand interactions while in the Critical MobState. | ||
/// </summary> | ||
[DataField] | ||
public bool AllowHandInteractWhileCrit; | ||
|
||
/// <summary> | ||
/// Whether this mob is allowed to perform hand interactions while in the SoftCritical MobState. | ||
/// </summary> | ||
[DataField] | ||
public bool AllowHandInteractWhileSoftCrit; | ||
|
||
/// <summary> | ||
/// Whether this mob is allowed to perform hand interactions while in the Dead MobState. | ||
/// This is provided for completeness sake, and *probably* shouldn't be used by default. | ||
/// </summary> | ||
[DataField] | ||
public bool AllowHandInteractWhileDead; | ||
|
||
//default mobstate is always the lowest state level | ||
[AutoNetworkedField, ViewVariables] | ||
public MobState CurrentState { get; set; } = MobState.Alive; | ||
|
||
[DataField] | ||
[AutoNetworkedField] | ||
public HashSet<MobState> AllowedStates = new() | ||
{ | ||
MobState.Alive, | ||
MobState.Critical, | ||
MobState.SoftCritical, | ||
MobState.Dead | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.