-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(traits): add new trait Hemophilia
- Loading branch information
1 parent
bd11307
commit b4b2fd3
Showing
5 changed files
with
73 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Content.Shared.Damage; | ||
namespace Content.Server.Traits.Assorted; | ||
|
||
/// <summary> | ||
/// This is used for the Hemophilia trait. | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class HemophiliaComponent : Component | ||
{ | ||
// <summary> | ||
// What the BleedReductionAmount should be multiplied by. | ||
// </summary> | ||
[DataField(required: true)] | ||
public float BleedReductionModifier = 1f; | ||
|
||
/// <summary> | ||
/// The damage increase from this trait. | ||
/// </summary> | ||
[DataField(required: true)] | ||
public DamageModifierSet DamageModifiers = default!; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Content.Server.Body.Systems; | ||
using Content.Server.Body.Components; | ||
using Content.Shared.Damage; | ||
|
||
namespace Content.Server.Traits.Assorted; | ||
|
||
public sealed class HemophiliaSystem : EntitySystem | ||
{ | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<HemophiliaComponent, ComponentStartup>(OnStartup); | ||
SubscribeLocalEvent<HemophiliaComponent, DamageModifyEvent>(OnDamageModify); | ||
} | ||
|
||
private void OnStartup(EntityUid uid, HemophiliaComponent component, ComponentStartup args) | ||
{ | ||
if (!TryComp<BloodstreamComponent>(uid, out var bloodstream)) | ||
return; | ||
|
||
bloodstream.BleedReductionAmount *= component.BleedReductionModifier; | ||
} | ||
|
||
private void OnDamageModify(EntityUid uid, HemophiliaComponent component, DamageModifyEvent args) | ||
{ | ||
args.Damage = DamageSpecifier.ApplyModifierSet(args.Damage, component.DamageModifiers); | ||
} | ||
} |
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