-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Corporeal StatusEffects #43706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Corporeal StatusEffects #43706
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| using Content.Shared.Eye; | ||
| using Content.Shared.StatusEffectNew; | ||
| using Robust.Server.GameObjects; | ||
| using Robust.Shared.GameObjects; | ||
|
|
||
| namespace Content.Server.Eye.EntitySystems; | ||
|
|
||
| /// <summary> | ||
| /// Refreshes visibility layer modifiers contributed by active status effects. | ||
| /// </summary> | ||
| public sealed class VisibilityModifierStatusSystem : EntitySystem | ||
| { | ||
| [Dependency] private readonly VisibilitySystem _visibility = default!; | ||
|
|
||
| /// <inheritdoc /> | ||
| public override void Initialize() | ||
| { | ||
| SubscribeLocalEvent<VisibilityModifierStatusComponent, StatusEffectAppliedEvent>(OnStatusApplied); | ||
| SubscribeLocalEvent<VisibilityModifierStatusComponent, StatusEffectRemovedEvent>(OnStatusRemoved); | ||
| SubscribeLocalEvent<VisibilityModifierStatusComponent, StatusEffectRelayedEvent<RefreshVisibilityModifiersEvent>>(OnRefreshVisibilityModifiers); | ||
| } | ||
|
|
||
| private void OnStatusApplied(Entity<VisibilityModifierStatusComponent> ent, ref StatusEffectAppliedEvent args) | ||
| { | ||
| _visibility.RefreshVisibility(args.Target); | ||
| } | ||
|
|
||
| private void OnStatusRemoved(Entity<VisibilityModifierStatusComponent> ent, ref StatusEffectRemovedEvent args) | ||
| { | ||
| _visibility.RefreshVisibility(args.Target); | ||
| } | ||
|
|
||
| private void OnRefreshVisibilityModifiers( | ||
| Entity<VisibilityModifierStatusComponent> ent, | ||
| ref StatusEffectRelayedEvent<RefreshVisibilityModifiersEvent> args) | ||
| { | ||
| var ev = args.Args; | ||
|
|
||
| foreach (var layer in ent.Comp.AddVisibility) | ||
| { | ||
| ev.AddLayer((ushort) layer); | ||
| } | ||
|
|
||
| foreach (var layer in ent.Comp.RemoveVisibility) | ||
| { | ||
| ev.RemoveLayer((ushort) layer); | ||
| } | ||
|
|
||
| args.Args = ev; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,5 @@ | ||
| using Content.Server.GameTicking; | ||
| using Content.Shared.Eye; | ||
| using Content.Shared.Revenant.Components; | ||
| using Content.Shared.Revenant.EntitySystems; | ||
| using Robust.Server.GameObjects; | ||
|
|
||
| namespace Content.Server.Revenant.EntitySystems; | ||
|
|
||
| public sealed class CorporealSystem : SharedCorporealSystem | ||
| { | ||
| [Dependency] private readonly VisibilitySystem _visibilitySystem = default!; | ||
| [Dependency] private readonly GameTicker _ticker = default!; | ||
|
|
||
| public override void OnStartup(EntityUid uid, CorporealComponent component, ComponentStartup args) | ||
| { | ||
| base.OnStartup(uid, component, args); | ||
|
|
||
| if (TryComp<VisibilityComponent>(uid, out var visibility)) | ||
| { | ||
| _visibilitySystem.RemoveLayer((uid, visibility), (int) VisibilityFlags.Ghost, false); | ||
| _visibilitySystem.AddLayer((uid, visibility), (int) VisibilityFlags.Normal, false); | ||
| _visibilitySystem.RefreshVisibility(uid, visibility); | ||
| } | ||
| } | ||
|
|
||
| public override void OnShutdown(EntityUid uid, CorporealComponent component, ComponentShutdown args) | ||
| { | ||
| base.OnShutdown(uid, component, args); | ||
|
|
||
| if (TryComp<VisibilityComponent>(uid, out var visibility) && _ticker.RunLevel != GameRunLevel.PostRound) | ||
| { | ||
| _visibilitySystem.AddLayer((uid, visibility), (int) VisibilityFlags.Ghost, false); | ||
| _visibilitySystem.RemoveLayer((uid, visibility), (int) VisibilityFlags.Normal, false); | ||
| _visibilitySystem.RefreshVisibility(uid, visibility); | ||
| } | ||
| } | ||
| } | ||
| public sealed class CorporealSystem : SharedCorporealSystem; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| using System.Collections.Generic; | ||
| using Robust.Shared.GameObjects; | ||
|
|
||
| namespace Content.Shared.Eye; | ||
|
|
||
| /// <summary> | ||
| /// Applies visibility layer changes while the owning status effect is active. | ||
| /// Use only on status effect entities. | ||
| /// </summary> | ||
| [RegisterComponent] | ||
| public sealed partial class VisibilityModifierStatusComponent : Component | ||
| { | ||
| /// <summary> | ||
| /// Visibility layers added while the effect is active. | ||
| /// </summary> | ||
| [DataField] | ||
| public List<VisibilityFlags> AddVisibility = new(); | ||
|
|
||
| /// <summary> | ||
| /// Visibility layers removed while the effect is active. | ||
| /// </summary> | ||
| [DataField] | ||
| public List<VisibilityFlags> RemoveVisibility = new(); | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| using Content.Shared.Physics; | ||
|
|
||
| namespace Content.Shared.Revenant.Components; | ||
|
|
||
| /// <summary> | ||
| /// Makes the target solid and visible. | ||
| /// Use only in conjunction with the new status effect system, on the status effect entity. | ||
| /// </summary> | ||
| [RegisterComponent] | ||
| public sealed partial class CorporealStatusEffectComponent : Component | ||
| { | ||
| /// <summary> | ||
| /// The collision mask applied while the target is corporeal. | ||
| /// </summary> | ||
| [DataField] | ||
| public int CollisionMask = (int)(CollisionGroup.SmallMobMask | CollisionGroup.GhostImpassable); | ||
|
|
||
| /// <summary> | ||
| /// The collision layer applied while the target is corporeal. | ||
| /// </summary> | ||
| [DataField] | ||
| public int CollisionLayer = (int)CollisionGroup.SmallMobLayer; | ||
|
|
||
| /// <summary> | ||
| /// The collision mask restored when the corporeal effect ends. | ||
| /// </summary> | ||
| [DataField] | ||
| public int RemovedCollisionMask = (int)CollisionGroup.GhostImpassable; | ||
|
|
||
| /// <summary> | ||
| /// The collision layer restored when the corporeal effect ends. | ||
| /// </summary> | ||
| [DataField] | ||
| public int RemovedCollisionLayer = 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
| using Content.Shared.Physics; | ||
| using Robust.Shared.Physics; | ||
| using System.Linq; | ||
| using Content.Shared.Movement.Systems; | ||
| using Content.Shared.Revenant.Components; | ||
| using Content.Shared.StatusEffectNew; | ||
| using Robust.Shared.Physics.Systems; | ||
| using Robust.Shared.Prototypes; | ||
|
|
||
| namespace Content.Shared.Revenant.EntitySystems; | ||
|
|
||
|
|
@@ -14,50 +15,42 @@ namespace Content.Shared.Revenant.EntitySystems; | |
| /// </summary> | ||
| public abstract class SharedCorporealSystem : EntitySystem | ||
| { | ||
| public static readonly EntProtoId CorporealStatusEffect = "StatusEffectCorporeal"; | ||
|
|
||
| [Dependency] private readonly SharedAppearanceSystem _appearance = default!; | ||
| [Dependency] private readonly MovementSpeedModifierSystem _movement = default!; | ||
| [Dependency] private readonly SharedPhysicsSystem _physics = default!; | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
|
|
||
| SubscribeLocalEvent<CorporealComponent, ComponentStartup>(OnStartup); | ||
| SubscribeLocalEvent<CorporealComponent, ComponentShutdown>(OnShutdown); | ||
| SubscribeLocalEvent<CorporealComponent, RefreshMovementSpeedModifiersEvent>(OnRefresh); | ||
| } | ||
|
|
||
| private void OnRefresh(EntityUid uid, CorporealComponent component, RefreshMovementSpeedModifiersEvent args) | ||
| { | ||
| args.ModifySpeed(component.MovementSpeedDebuff, component.MovementSpeedDebuff); | ||
| SubscribeLocalEvent<CorporealStatusEffectComponent, StatusEffectAppliedEvent>(OnApplied); | ||
| SubscribeLocalEvent<CorporealStatusEffectComponent, StatusEffectRemovedEvent>(OnRemoved); | ||
| } | ||
|
|
||
| public virtual void OnStartup(EntityUid uid, CorporealComponent component, ComponentStartup args) | ||
| public virtual void OnApplied(Entity<CorporealStatusEffectComponent> ent, ref StatusEffectAppliedEvent args) | ||
| { | ||
| _appearance.SetData(uid, RevenantVisuals.Corporeal, true); | ||
| _appearance.SetData(args.Target, RevenantVisuals.Corporeal, true); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel the same way about the appearance data as I do the collision groups. I'd love to find a more generic solution but I'm drawing a blank.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer to leave it until the revenant system is refactored |
||
|
|
||
| if (TryComp<FixturesComponent>(uid, out var fixtures) && fixtures.FixtureCount >= 1) | ||
| if (TryComp<FixturesComponent>(args.Target, out var fixtures) && fixtures.FixtureCount >= 1) | ||
| { | ||
| var fixture = fixtures.Fixtures.First(); | ||
|
|
||
| _physics.SetCollisionMask(uid, fixture.Key, fixture.Value, (int) (CollisionGroup.SmallMobMask | CollisionGroup.GhostImpassable), fixtures); | ||
| _physics.SetCollisionLayer(uid, fixture.Key, fixture.Value, (int) CollisionGroup.SmallMobLayer, fixtures); | ||
| _physics.SetCollisionMask(args.Target, fixture.Key, fixture.Value, ent.Comp.CollisionMask, fixtures); | ||
| _physics.SetCollisionLayer(args.Target, fixture.Key, fixture.Value, ent.Comp.CollisionLayer, fixtures); | ||
| } | ||
| _movement.RefreshMovementSpeedModifiers(uid); | ||
| } | ||
|
|
||
| public virtual void OnShutdown(EntityUid uid, CorporealComponent component, ComponentShutdown args) | ||
| public virtual void OnRemoved(Entity<CorporealStatusEffectComponent> ent, ref StatusEffectRemovedEvent args) | ||
| { | ||
| _appearance.SetData(uid, RevenantVisuals.Corporeal, false); | ||
| _appearance.SetData(args.Target, RevenantVisuals.Corporeal, false); | ||
|
|
||
| if (TryComp<FixturesComponent>(uid, out var fixtures) && fixtures.FixtureCount >= 1) | ||
| if (TryComp<FixturesComponent>(args.Target, out var fixtures) && fixtures.FixtureCount >= 1) | ||
| { | ||
| var fixture = fixtures.Fixtures.First(); | ||
|
|
||
| _physics.SetCollisionMask(uid, fixture.Key, fixture.Value, (int) CollisionGroup.GhostImpassable, fixtures); | ||
| _physics.SetCollisionLayer(uid, fixture.Key, fixture.Value, 0, fixtures); | ||
| _physics.SetCollisionMask(args.Target, fixture.Key, fixture.Value, ent.Comp.RemovedCollisionMask, fixtures); | ||
| _physics.SetCollisionLayer(args.Target, fixture.Key, fixture.Value, ent.Comp.RemovedCollisionLayer, fixtures); | ||
| } | ||
| component.MovementSpeedDebuff = 1; //just so we can avoid annoying code elsewhere | ||
| _movement.RefreshMovementSpeedModifiers(uid); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.