-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into Nikko--Toybox
- Loading branch information
Showing
7 changed files
with
128 additions
and
1 deletion.
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
14 changes: 14 additions & 0 deletions
14
Content.Shared/Floofstation/Traits/Components/FixtureDensityModifier.cs
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,14 @@ | ||
namespace Content.Shared.Floofstation.Traits.Components; | ||
|
||
[RegisterComponent] | ||
public sealed partial class FixtureDensityModifierComponent : Component | ||
{ | ||
/// <summary> | ||
/// The minimum and maximum density that may be used as input for and achieved as a result of application of this component. | ||
/// </summary> | ||
[DataField] | ||
public float Min = float.Epsilon, Max = float.PositiveInfinity; | ||
|
||
[DataField] | ||
public float Factor = 1f; | ||
} |
35 changes: 35 additions & 0 deletions
35
Content.Shared/Floofstation/Traits/TraitStatModifierSystem.cs
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,35 @@ | ||
using Content.Shared.Contests; | ||
using Content.Shared.Floofstation.Traits.Components; | ||
using Robust.Shared.Physics; | ||
using Robust.Shared.Physics.Systems; | ||
|
||
namespace Content.Shared.Floofstation.Traits; | ||
|
||
public sealed partial class TraitStatModifierSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly ContestsSystem _contests = default!; | ||
[Dependency] private readonly FixtureSystem _fixtures = default!; | ||
[Dependency] private readonly SharedPhysicsSystem _physics = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<FixtureDensityModifierComponent, MapInitEvent>(OnInitDensity); // Traits are added after CharacterSpawnedEvent so it's fine™ | ||
} | ||
|
||
private void OnInitDensity(Entity<FixtureDensityModifierComponent> ent, ref MapInitEvent args) | ||
{ | ||
if (!TryComp<FixturesComponent>(ent.Owner, out var fixtures)) | ||
return; | ||
|
||
foreach (var (id, fix) in fixtures.Fixtures) | ||
{ | ||
if (!fix.Hard || fix.Density < ent.Comp.Min || fix.Density > ent.Comp.Max) | ||
continue; | ||
|
||
var result = Math.Clamp(fix.Density * ent.Comp.Factor, ent.Comp.Min, ent.Comp.Max); | ||
_physics.SetDensity(ent, id, fix, result, update: false, fixtures); | ||
} | ||
|
||
_fixtures.FixtureUpdate(ent, true, true, fixtures); | ||
} | ||
} |
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
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