forked from space-wizards/space-station-14
-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #228 from TGRCdev/mucin-species-fix
Mucin speed boost now only affects Gastropoids
- Loading branch information
Showing
7 changed files
with
170 additions
and
5 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
Content.Server/Chemistry/TileReactions/EnsureTileReaction.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,47 @@ | ||
using Content.Server.Fluids.EntitySystems; | ||
using Content.Shared.Chemistry.Components; | ||
using Content.Shared.Chemistry.Reaction; | ||
using Content.Shared.Chemistry.Reagent; | ||
using Content.Shared.FixedPoint; | ||
using Content.Shared.Tag; | ||
using JetBrains.Annotations; | ||
using Robust.Shared.Map; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server.Chemistry.TileReactions | ||
{ | ||
[UsedImplicitly] | ||
[DataDefinition] | ||
public sealed partial class EnsureTileReaction : ITileReaction | ||
{ | ||
[DataField, ViewVariables] | ||
public ComponentRegistry Components = new(); | ||
|
||
[DataField, ViewVariables] | ||
public HashSet<ProtoId<TagPrototype>> Tags = new(); | ||
|
||
[DataField, ViewVariables] | ||
public bool Override = false; | ||
|
||
public FixedPoint2 TileReact(TileRef tile, | ||
ReagentPrototype reagent, | ||
FixedPoint2 reactVolume, | ||
IEntityManager entityManager, | ||
List<ReagentData>? data) | ||
{ | ||
if (reactVolume < 5) | ||
return FixedPoint2.Zero; | ||
|
||
if (entityManager.EntitySysManager.GetEntitySystem<PuddleSystem>() | ||
.TrySpillAt(tile, new Solution(reagent.ID, reactVolume, data), out var puddleUid, false, false)) | ||
{ | ||
entityManager.AddComponents(puddleUid, Components, Override); | ||
entityManager.EntitySysManager.GetEntitySystem<TagSystem>().AddTags(puddleUid, Tags); | ||
|
||
return reactVolume; | ||
} | ||
|
||
return FixedPoint2.Zero; | ||
} | ||
} | ||
} |
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,11 @@ | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Fluids.Components | ||
{ | ||
[RegisterComponent, NetworkedComponent] | ||
public sealed partial class PropulsedByComponent : Component | ||
{ | ||
[ViewVariables(VVAccess.ReadOnly)] | ||
public HashSet<Entity<PropulsionComponent>> Sources = new(); | ||
} | ||
} |
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.Whitelist; | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Fluids.Components | ||
{ | ||
/// <summary> | ||
/// This object will speed up the movement speed of entities | ||
/// when collided with | ||
/// | ||
/// Used for mucin | ||
/// | ||
/// This partially replicates SpeedModifierContactsComponent because that | ||
/// component is already heavily coupled with existing puddle code. | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent] | ||
[AutoGenerateComponentState] | ||
public sealed partial class PropulsionComponent : Component | ||
{ | ||
[DataField, ViewVariables] | ||
[AutoNetworkedField] | ||
public float WalkSpeedModifier = 1.0f; | ||
|
||
[AutoNetworkedField] | ||
[DataField, ViewVariables] | ||
public float SprintSpeedModifier = 1.0f; | ||
|
||
/// <summary> | ||
/// If an entity passes this, apply the speed modifier. | ||
/// Passes all entities if not defined. | ||
/// </summary> | ||
[AutoNetworkedField] | ||
[DataField, ViewVariables] | ||
public EntityWhitelist? Whitelist; | ||
} | ||
} |
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,62 @@ | ||
using System.Linq; | ||
using Content.Shared.Fluids.Components; | ||
using Content.Shared.Movement.Components; | ||
using Content.Shared.Movement.Systems; | ||
using Content.Shared.Whitelist; | ||
using Robust.Shared.Physics.Events; | ||
|
||
namespace Content.Shared.Fluids.EntitySystems; | ||
|
||
public sealed class PropulsionSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SpeedModifierContactsSystem _speedModifier = default!; | ||
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<PropulsionComponent, ComponentInit>(OnComponentInit); | ||
SubscribeLocalEvent<PropulsionComponent, StartCollideEvent>(OnStartCollide); | ||
SubscribeLocalEvent<PropulsionComponent, EndCollideEvent>(OnEndCollide); | ||
SubscribeLocalEvent<PropulsedByComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshSpeed); | ||
} | ||
|
||
public void OnComponentInit(Entity<PropulsionComponent> ent, ref ComponentInit args) | ||
{ | ||
EnsureComp<SpeedModifierContactsComponent>(ent); | ||
} | ||
|
||
public void OnStartCollide(Entity<PropulsionComponent> ent, ref StartCollideEvent args) | ||
{ | ||
if (!HasComp<MovementSpeedModifierComponent>(args.OtherEntity)) | ||
return; | ||
|
||
if (_whitelistSystem.IsWhitelistFail(ent.Comp.Whitelist, args.OtherEntity)) | ||
return; | ||
|
||
_speedModifier.AddModifiedEntity(args.OtherEntity); | ||
|
||
var propulse = EnsureComp<PropulsedByComponent>(args.OtherEntity); | ||
propulse.Sources.Add(ent); | ||
} | ||
|
||
public void OnEndCollide(Entity<PropulsionComponent> ent, ref EndCollideEvent args) | ||
{ | ||
if (TryComp<PropulsedByComponent>(args.OtherEntity, out var propulse)) | ||
{ | ||
propulse.Sources.Remove(ent); | ||
} | ||
} | ||
|
||
public static void OnRefreshSpeed(Entity<PropulsedByComponent> ent, ref RefreshMovementSpeedModifiersEvent args) | ||
{ | ||
ent.Comp.Sources.RemoveWhere((ent) => !ent.Owner.IsValid() || ent.Comp.Deleted); | ||
|
||
if (ent.Comp.Sources.Count == 0) | ||
return; | ||
|
||
var modifier = ent.Comp.Sources.First(); | ||
args.ModifySpeed(modifier.Comp.WalkSpeedModifier, modifier.Comp.SprintSpeedModifier); | ||
} | ||
} |
Binary file not shown.
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