Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions Content.Server/Eye/EntitySystems/VisibilityModifierStatusSystem.cs
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;
}
}
34 changes: 1 addition & 33 deletions Content.Server/Revenant/EntitySystems/CorporealSystem.cs
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;
8 changes: 5 additions & 3 deletions Content.Server/Revenant/EntitySystems/RevenantSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Numerics;
using Content.Server.Actions;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Eye.EntitySystems;
using Content.Server.GameTicking;
using Content.Server.Store.Systems;
using Content.Shared.Alert;
Expand All @@ -16,6 +17,7 @@
using Content.Shared.Popups;
using Content.Shared.Revenant;
using Content.Shared.Revenant.Components;
using Content.Shared.Revenant.EntitySystems;
using Content.Shared.StatusEffect;
using Content.Shared.Store.Components;
using Content.Shared.Stunnable;
Expand All @@ -37,7 +39,7 @@ public sealed partial class RevenantSystem : EntitySystem
[Dependency] private readonly PhysicsSystem _physics = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly SharedEyeSystem _eye = default!;
[Dependency] private readonly StatusEffectsSystem _statusEffects = default!;
[Dependency] private readonly Content.Shared.StatusEffectNew.StatusEffectsSystem _newStatusEffects = default!;
Comment thread
Pok27 marked this conversation as resolved.
[Dependency] private readonly SharedInteractionSystem _interact = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedStunSystem _stun = default!;
Expand Down Expand Up @@ -111,7 +113,7 @@ private void OnExamine(EntityUid uid, RevenantComponent component, ExaminedEvent

private void OnDamage(EntityUid uid, RevenantComponent component, DamageChangedEvent args)
{
if (!HasComp<CorporealComponent>(uid) || args.DamageDelta == null)
if (!_newStatusEffects.HasStatusEffect(uid, SharedCorporealSystem.CorporealStatusEffect) || args.DamageDelta == null)
return;

var essenceDamage = args.DamageDelta.GetTotal().Float() * component.DamageToEssenceCoefficient * -1;
Expand Down Expand Up @@ -165,7 +167,7 @@ private bool TryUseAbility(EntityUid uid, RevenantComponent component, FixedPoin

ChangeEssenceAmount(uid, -abilityCost, component, false);

_statusEffects.TryAddStatusEffect<CorporealComponent>(uid, "Corporeal", TimeSpan.FromSeconds(debuffs.Y), false);
_newStatusEffects.TryAddStatusEffectDuration(uid, SharedCorporealSystem.CorporealStatusEffect, TimeSpan.FromSeconds(debuffs.Y));
_stun.TryAddStunDuration(uid, TimeSpan.FromSeconds(debuffs.X));

return true;
Expand Down
24 changes: 24 additions & 0 deletions Content.Shared/Eye/VisibilityModifierStatusComponent.cs
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();
}
15 changes: 0 additions & 15 deletions Content.Shared/Revenant/Components/CorporealComponent.cs

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;
}
39 changes: 16 additions & 23 deletions Content.Shared/Revenant/EntitySystems/SharedCorporealSystem.cs
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;

Expand All @@ -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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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);
}
}
2 changes: 2 additions & 0 deletions Content.Shared/StatusEffectNew/StatusEffectSystem.Relay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Content.Shared.StatusEffectNew.Components;
using Content.Shared.Stunnable;
using Robust.Shared.Player;
using Robust.Shared.GameObjects;

namespace Content.Shared.StatusEffectNew;

Expand All @@ -31,6 +32,7 @@
SubscribeLocalEvent<StatusEffectContainerComponent, StandUpAttemptEvent>(RefRelayStatusEffectEvent);
SubscribeLocalEvent<StatusEffectContainerComponent, StunEndAttemptEvent>(RefRelayStatusEffectEvent);
SubscribeLocalEvent<StatusEffectContainerComponent, RefreshStaminaCritThresholdEvent>(RefRelayStatusEffectEvent);
SubscribeLocalEvent<StatusEffectContainerComponent, RefreshVisibilityModifiersEvent>(RefRelayStatusEffectEvent);

Check failure on line 35 in Content.Shared/StatusEffectNew/StatusEffectSystem.Relay.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 1: cannot convert from 'method group' to 'Robust.Shared.GameObjects.EntityEventRefHandler<Content.Shared.StatusEffectNew.Components.StatusEffectContainerComponent, RefreshVisibilityModifiersEvent>'

Check failure on line 35 in Content.Shared/StatusEffectNew/StatusEffectSystem.Relay.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'RefreshVisibilityModifiersEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 35 in Content.Shared/StatusEffectNew/StatusEffectSystem.Relay.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 1: cannot convert from 'method group' to 'Robust.Shared.GameObjects.EntityEventRefHandler<Content.Shared.StatusEffectNew.Components.StatusEffectContainerComponent, RefreshVisibilityModifiersEvent>'

Check failure on line 35 in Content.Shared/StatusEffectNew/StatusEffectSystem.Relay.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'RefreshVisibilityModifiersEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 35 in Content.Shared/StatusEffectNew/StatusEffectSystem.Relay.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Argument 1: cannot convert from 'method group' to 'Robust.Shared.GameObjects.EntityEventRefHandler<Content.Shared.StatusEffectNew.Components.StatusEffectContainerComponent, RefreshVisibilityModifiersEvent>'

Check failure on line 35 in Content.Shared/StatusEffectNew/StatusEffectSystem.Relay.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'RefreshVisibilityModifiersEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 35 in Content.Shared/StatusEffectNew/StatusEffectSystem.Relay.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Argument 1: cannot convert from 'method group' to 'Robust.Shared.GameObjects.EntityEventRefHandler<Content.Shared.StatusEffectNew.Components.StatusEffectContainerComponent, RefreshVisibilityModifiersEvent>'

Check failure on line 35 in Content.Shared/StatusEffectNew/StatusEffectSystem.Relay.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'RefreshVisibilityModifiersEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 35 in Content.Shared/StatusEffectNew/StatusEffectSystem.Relay.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 1: cannot convert from 'method group' to 'Robust.Shared.GameObjects.EntityEventRefHandler<Content.Shared.StatusEffectNew.Components.StatusEffectContainerComponent, RefreshVisibilityModifiersEvent>'

Check failure on line 35 in Content.Shared/StatusEffectNew/StatusEffectSystem.Relay.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'RefreshVisibilityModifiersEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 35 in Content.Shared/StatusEffectNew/StatusEffectSystem.Relay.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 1: cannot convert from 'method group' to 'Robust.Shared.GameObjects.EntityEventRefHandler<Content.Shared.StatusEffectNew.Components.StatusEffectContainerComponent, RefreshVisibilityModifiersEvent>'

Check failure on line 35 in Content.Shared/StatusEffectNew/StatusEffectSystem.Relay.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'RefreshVisibilityModifiersEvent' could not be found (are you missing a using directive or an assembly reference?)
SubscribeLocalEvent<StatusEffectContainerComponent, CanSeeAttemptEvent>(RelayStatusEffectEvent);
SubscribeLocalEvent<StatusEffectContainerComponent, FlashAttemptEvent>(RefRelayStatusEffectEvent);

Expand Down
1 change: 0 additions & 1 deletion Resources/Prototypes/Entities/Mobs/NPCs/living_light.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
BaseUnshaded: dead_glow
- type: StatusEffects
allowed:
- Corporeal
- Electrocution
- type: Fixtures
fixtures:
Expand Down
3 changes: 0 additions & 3 deletions Resources/Prototypes/Entities/Mobs/NPCs/revenant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
sprite: Mobs/Ghosts/revenant.rsi
layers:
- state: active
- type: StatusEffects
allowed:
- Corporeal
- type: Damageable
damageModifierSet: ManifestedSpirit
- type: Injurable
Expand Down
18 changes: 18 additions & 0 deletions Resources/Prototypes/Entities/StatusEffects/misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,21 @@
- MobState
- Blindable
- type: BlindnessStatusEffect

# Makes a revenant corporeal and vulnerable
- type: entity
parent: StatusEffectBase
id: StatusEffectCorporeal
name: corporeal
components:
- type: StatusEffectAlert
alert: Corporeal
- type: MovementModStatusEffect
walkSpeedModifier: 0.66
sprintSpeedModifier: 0.66
- type: CorporealStatusEffect
- type: VisibilityModifierStatus
addVisibility:
- Normal
removeVisibility:
- Ghost
4 changes: 0 additions & 4 deletions Resources/Prototypes/status_effects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
id: Muted
alert: Muted

- type: statusEffect
id: Corporeal
alert: Corporeal

- type: statusEffect
id: Pacified #cannot attack

Expand Down
Loading