Skip to content
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

Salt can reveal revenants #278

Merged
merged 3 commits into from
Sep 19, 2024
Merged
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
7 changes: 7 additions & 0 deletions Content.Client/Revenant/RevealRevenantOnCollideSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Content.Shared.Revenant.EntitySystems;

namespace Content.Client.Revenant;

public sealed partial class RevealRevenantOnCollideSystem : SharedRevealRevenantOnCollideSystem
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using Content.Shared.Revenant.EntitySystems;
using Content.Shared.Revenant.Components;
using Content.Shared.Physics;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Physics.Collision.Shapes;
using Robust.Shared.Physics;

namespace Content.Server.Revenant.EntitySystems;

public sealed partial class RevealRevenantOnCollideSystem : SharedRevealRevenantOnCollideSystem
{
[Dependency] private readonly FixtureSystem _fixtures = default!;
[Dependency] private readonly CollisionWakeSystem _collisionWake = default!;

private const string FixtureId = "revenantReveal";

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RevealRevenantOnCollideComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<RevealRevenantOnCollideComponent, ComponentShutdown>(OnShutdown);
}

private IPhysShape GetOrCreateShape(EntityUid uid, FixturesComponent? fixtures = null)
{
if (Resolve(uid, ref fixtures))
if (fixtures.Fixtures.TryGetValue("fix1", out var fix))
return fix.Shape;

return new PhysShapeCircle(0.35f);
}

private void OnStartup(EntityUid uid, RevealRevenantOnCollideComponent comp, ComponentStartup args)
{
var fixtures = EnsureComp<FixturesComponent>(uid);
_fixtures.TryCreateFixture(uid,
GetOrCreateShape(uid, fixtures),
FixtureId,
hard: false,
collisionMask: (int)CollisionGroup.GhostImpassable,
collisionLayer: (int)CollisionGroup.GhostImpassable,
manager: fixtures
);

// Disable collision wake so that it can trigger collisions even when sitting still
var collisionWake = EnsureComp<CollisionWakeComponent>(uid);
_collisionWake.SetEnabled(uid, false, collisionWake);
}

private void OnShutdown(EntityUid uid, RevealRevenantOnCollideComponent comp, ComponentShutdown args)
{
_fixtures.DestroyFixture(uid, FixtureId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Robust.Shared.GameStates;

namespace Content.Shared.Revenant.Components;

[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class RevealRevenantOnCollideComponent : Component
{
/// <summary>
/// Popup text to show the revenant upon revealing. Works with
/// localization strings as well.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public string PopupText = "revenant-revealed-default";

[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public TimeSpan RevealTime = TimeSpan.FromSeconds(5);

[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public TimeSpan? StunTime;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Content.Shared.Revenant.Components;
using Content.Shared.Popups;
using Content.Shared.StatusEffect;
using Content.Shared.Stunnable;
using Robust.Shared.Physics.Events;
using Robust.Shared.Timing;

namespace Content.Shared.Revenant.EntitySystems;

public abstract class SharedRevealRevenantOnCollideSystem : EntitySystem
{
[Dependency] private readonly StatusEffectsSystem _status = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedStunSystem _stun = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;

[ValidatePrototypeId<StatusEffectPrototype>]
private const string CorporealStatusId = "Corporeal";
[ValidatePrototypeId<StatusEffectPrototype>]
private const string StunStatusId = "Stun";

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RevealRevenantOnCollideComponent, StartCollideEvent>(OnCollideStart);
}

public void OnCollideStart(EntityUid uid, RevealRevenantOnCollideComponent comp, StartCollideEvent args)
{
if (!HasComp<RevenantComponent>(args.OtherEntity))
return;

if (!string.IsNullOrEmpty(comp.PopupText) && !_status.HasStatusEffect(args.OtherEntity, CorporealStatusId))
_popup.PopupClient(
Loc.GetString(comp.PopupText, ("revealer", uid), ("revenant", args.OtherEntity)),
args.OtherEntity,
args.OtherEntity
);

_status.TryAddStatusEffect<CorporealComponent>(args.OtherEntity, CorporealStatusId, comp.RevealTime, true);

if (comp.StunTime != null && !_status.HasStatusEffect(args.OtherEntity, StunStatusId))
_stun.TryStun(args.OtherEntity, comp.StunTime.Value, true);
}
}
5 changes: 4 additions & 1 deletion Resources/Locale/en-US/revenant/revenant.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ revenant-exorcise-begin-user = You begin exorcising {$revenant} with {THE($bible
revenant-exorcise-begin-other = {CAPITALIZE(THE($user))} begins to exorcise {$revenant} with {THE($bible)}...
revenant-exorcise-begin-target = {CAPITALIZE(THE($user))} is exorcising you with {THE($bible)}!

revenant-exorcise-success = {$revenant}'s energy fades away...
revenant-exorcise-success = {$revenant}'s energy fades away...

revenant-revealed-default = {CAPITALIZE(THE($revealer))} weakens your ethereal cloak!
revenant-revealed-salt = The salt puddle weakens your ethereal cloak!
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Objects/Materials/ore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@
- type: Tag
tags:
- Salt
- type: RevealRevenantOnCollide
- type: Stack
stackType: SaltOre
- type: Sprite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
bibleUserOnly: true
- type: Summonable
specialItem: SpawnPointGhostRemilia
- type: RevealRevenantOnCollide
- type: ReactionMixer
mixMessage: "bible-mixing-success"
reactionTypes:
Expand Down
5 changes: 5 additions & 0 deletions Resources/Prototypes/Reagents/Consumable/Food/condiments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@
damage:
types:
Poison: 4
tileReactions:
- !type:EnsureTileReaction
components:
- type: RevealRevenantOnCollide
popupText: revenant-revealed-salt

- type: reagent
id: Syrup
Expand Down
Loading