forked from space-syndicate/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4245a86
commit 772b361
Showing
19 changed files
with
326 additions
and
32 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
using System.Numerics; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Player; | ||
using Robust.Shared.Enums; | ||
using Robust.Shared.Map; | ||
using Robust.Shared.Utility; | ||
using Robust.Shared.Timing; | ||
using Content.Shared.Mobs.Components; | ||
using Content.Shared.Mobs; | ||
|
||
|
||
namespace Content.Client._CorvaxNext.Overlays; | ||
|
||
public sealed class ListenUpOverlay : Overlay | ||
{ | ||
[Dependency] private readonly IEntityManager _entity = default!; | ||
[Dependency] private readonly IPlayerManager _players = default!; | ||
|
||
private readonly EntityLookupSystem _entityLookup; | ||
private readonly TransformSystem _transformSystem; | ||
private readonly IGameTiming _gameTiming; | ||
private readonly SpriteSystem _spriteSystem; | ||
|
||
private Texture _texture; | ||
|
||
protected float Radius; | ||
protected SpriteSpecifier Sprite; | ||
|
||
public override bool RequestScreenTexture => true; | ||
public override OverlaySpace Space => OverlaySpace.WorldSpace; | ||
|
||
public ListenUpOverlay(float radius, SpriteSpecifier.Rsi sprite) | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
|
||
_transformSystem = _entity.System<TransformSystem>(); | ||
_spriteSystem = _entity.System<SpriteSystem>(); | ||
_entityLookup = _entity.System<EntityLookupSystem>(); | ||
_gameTiming = IoCManager.Resolve<IGameTiming>(); | ||
|
||
Radius = radius; | ||
Sprite = sprite; | ||
|
||
_texture = _spriteSystem.GetFrame(Sprite, _gameTiming.CurTime); | ||
|
||
|
||
ZIndex = -1; | ||
} | ||
|
||
protected override void Draw(in OverlayDrawArgs args) | ||
{ | ||
if (ScreenTexture == null | ||
|| _players.LocalEntity == null | ||
|| (!_entity.TryGetComponent<TransformComponent>(_players.LocalEntity, out var playerTransform))) | ||
return; | ||
|
||
_texture = _spriteSystem.GetFrame(Sprite, _gameTiming.CurTime); | ||
|
||
var handle = args.WorldHandle; | ||
var eye = args.Viewport.Eye; | ||
var eyeRot = eye?.Rotation ?? default; | ||
|
||
var entities = _entityLookup.GetEntitiesInRange<MobStateComponent>(playerTransform.Coordinates, Radius); | ||
|
||
foreach (var (uid, stateComp) in entities) | ||
{ | ||
|
||
if (!_entity.TryGetComponent<SpriteComponent>(uid, out var sprite) | ||
|| !sprite.Visible | ||
|| !_entity.TryGetComponent<TransformComponent>(uid, out var xform) | ||
|| (!_entity.TryGetComponent<MobStateComponent>(uid, out var mobstateComp)) | ||
|| (mobstateComp.CurrentState != MobState.Alive)) | ||
continue; | ||
|
||
Render((uid, sprite, xform), eye?.Position.MapId, handle, eyeRot); | ||
} | ||
handle.SetTransform(Matrix3x2.Identity); | ||
} | ||
|
||
private void Render(Entity<SpriteComponent, TransformComponent> ent, | ||
MapId? map, DrawingHandleWorld handle, Angle eyeRot) | ||
{ | ||
var (uid, sprite, xform) = ent; | ||
|
||
if (uid == _players.LocalEntity | ||
|| xform.MapID != map) | ||
return; | ||
|
||
var position = _transformSystem.GetWorldPosition(xform); | ||
var rotation = Angle.Zero; | ||
|
||
handle.SetTransform(position, rotation); | ||
handle.DrawTexture(_texture, new System.Numerics.Vector2(-0.5f)); | ||
} | ||
} |
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,75 @@ | ||
using Robust.Client.Graphics; | ||
using Robust.Client.Player; | ||
using Content.Shared._CorvaxNext.Resomi.Abilities.Hearing; | ||
using Content.Shared.Actions; | ||
using Content.Shared.DoAfter; | ||
using Robust.Shared.Utility; | ||
using Robust.Shared.Player; | ||
using Content.Shared.GameTicking; | ||
|
||
namespace Content.Client._CorvaxNext.Overlays; | ||
|
||
public sealed class ListenUpSystem : SharedListenUpSkillSystem | ||
{ | ||
[Dependency] private readonly IPlayerManager _player = default!; | ||
[Dependency] private readonly IOverlayManager _overlayMan = default!; | ||
|
||
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!; | ||
|
||
private Entity<BaseActionComponent> action; | ||
|
||
private ListenUpOverlay _listenUpOverlay = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<ListenUpComponent, ComponentStartup>(OnListenStartup); | ||
SubscribeLocalEvent<ListenUpComponent, ComponentShutdown>(OnListenUpShutdown); | ||
|
||
SubscribeLocalEvent<ListenUpComponent, LocalPlayerAttachedEvent>(OnPlayerAttached); | ||
SubscribeLocalEvent<ListenUpComponent, LocalPlayerDetachedEvent>(OnPlayerDetached); | ||
} | ||
private void OnListenStartup(Entity<ListenUpComponent> ent, ref ComponentStartup args) | ||
{ | ||
SwithOverlay(ent, true); | ||
} | ||
|
||
private void OnListenUpShutdown(Entity<ListenUpComponent> ent, ref ComponentShutdown args) | ||
{ | ||
SwithOverlay(ent, false); | ||
} | ||
|
||
private void OnPlayerAttached(Entity<ListenUpComponent> ent, ref LocalPlayerAttachedEvent args) | ||
{ | ||
SwithOverlay(ent, true); | ||
} | ||
|
||
private void OnPlayerDetached(Entity<ListenUpComponent> ent, ref LocalPlayerDetachedEvent args) | ||
{ | ||
SwithOverlay(ent, false); | ||
} | ||
private void UpdateOverlay(bool active, Overlay overlay) | ||
{ | ||
if (_player.LocalEntity == null) | ||
{ | ||
_overlayMan.RemoveOverlay(overlay); | ||
return; | ||
} | ||
|
||
if (active) | ||
_overlayMan.AddOverlay(overlay); | ||
else | ||
_overlayMan.RemoveOverlay(overlay); | ||
} | ||
|
||
private void SwithOverlay(Entity<ListenUpComponent> ent, bool active) | ||
{ | ||
Overlay overlay = ListenUp(ent.Comp.radius, ent.Comp.Sprite); | ||
UpdateOverlay(active, overlay); | ||
} | ||
|
||
private Overlay ListenUp(float radius, SpriteSpecifier.Rsi sprite) | ||
{ | ||
return _listenUpOverlay = new ListenUpOverlay(radius, sprite); | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
Content.Server/_CorvaxNext/Resomi/Abilities/ListenUpSystem.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,22 @@ | ||
using Content.Shared._CorvaxNext.Resomi.Abilities.Hearing; | ||
using Content.Shared.Actions; | ||
using Content.Shared.DoAfter; | ||
using Content.Shared.Movement.Events; | ||
using Content.Shared.Popups; | ||
using Content.Shared.IdentityManagement; | ||
|
||
namespace Content.Server._CorvaxNext.Resomi.Abilities; | ||
|
||
public sealed class ListenUpSystem : EntitySystem | ||
{ | ||
[Dependency] protected readonly SharedPopupSystem _popup = default!; | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<ListenUpComponent, ComponentStartup>(OnListenStartup); | ||
} | ||
private void OnListenStartup(Entity<ListenUpComponent> ent, ref ComponentStartup args) | ||
{ | ||
_popup.PopupEntity(Loc.GetString("listen-up-activated-massage", ("name", Identity.Entity(ent.Owner, EntityManager))), ent.Owner); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Content.Shared/_CorvaxNext/Resomi/Abilities/Hearing/ListenUpComponent.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,13 @@ | ||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Shared._CorvaxNext.Resomi.Abilities.Hearing; | ||
|
||
[RegisterComponent] | ||
public sealed partial class ListenUpComponent : Component | ||
{ | ||
[DataField] | ||
public float radius = 8f; | ||
|
||
[DataField] | ||
public SpriteSpecifier.Rsi Sprite = new SpriteSpecifier.Rsi(new("/Textures/_CorvaxNext/Mobs/Species/Resomi/Abilities/noise_effect.rsi"), "noise"); | ||
} |
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
50 changes: 41 additions & 9 deletions
50
Content.Shared/_CorvaxNext/Resomi/Abilities/Hearing/SharedListenUpSkillSystem.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 |
---|---|---|
@@ -1,20 +1,52 @@ | ||
using Robust.Shared.Timing; | ||
using Robust.Shared.Physics.Systems; | ||
using Robust.Shared.Physics; | ||
using Content.Shared.Physics; | ||
using Content.Shared.Popups; | ||
using Robust.Shared.Physics.Events; | ||
using Robust.Shared.Log; | ||
using Content.Shared.Climbing.Systems; | ||
using Content.Shared.Damage.Systems; | ||
using Content.Shared.Actions; | ||
using Content.Shared.DoAfter; | ||
using Content.Shared.Movement.Events; | ||
using Content.Shared.Popups; | ||
|
||
namespace Content.Shared._CorvaxNext.Resomi.Abilities.Hearing; | ||
|
||
public abstract class SharedListenUpSkillSystem : EntitySystem | ||
{ | ||
[Dependency] protected readonly SharedActionsSystem _actionsSystem = default!; | ||
[Dependency] protected readonly SharedDoAfterSystem _doAfterSystem = default!; | ||
[Dependency] protected readonly SharedPopupSystem _popup = default!; | ||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<ListenUpSkillComponent, ListenUpActionEvent>(OnActivateListenUp); | ||
SubscribeLocalEvent<ListenUpSkillComponent, ListenUpDoAfterEvent>(OnDoAfter); | ||
SubscribeLocalEvent<ListenUpSkillComponent, MoveInputEvent>(OnMoveInput); | ||
} | ||
private void OnActivateListenUp(Entity<ListenUpSkillComponent> ent, ref ListenUpActionEvent args) | ||
{ | ||
|
||
var doAfterArgs = new DoAfterArgs(EntityManager, ent.Owner, ent.Comp.prepareTime, new ListenUpDoAfterEvent(), ent.Owner, null, null) | ||
{ | ||
NeedHand = true, | ||
BreakOnDamage = true, | ||
BreakOnMove = true, | ||
MovementThreshold = 0.01f | ||
}; | ||
_doAfterSystem.TryStartDoAfter(doAfterArgs); | ||
} | ||
private void OnDoAfter(Entity<ListenUpSkillComponent> ent, ref ListenUpDoAfterEvent args) | ||
{ | ||
if (ent.Comp.toggled) | ||
return; | ||
|
||
AddComp<ListenUpComponent>(ent.Owner); | ||
|
||
_actionsSystem.SetToggled(ent.Comp.SwitchListenUpActionEntity, true); | ||
ent.Comp.toggled = !ent.Comp.toggled; | ||
} | ||
|
||
private void OnMoveInput(Entity<ListenUpSkillComponent> ent, ref MoveInputEvent args) | ||
{ | ||
if (!ent.Comp.toggled) | ||
return; | ||
|
||
RemComp<ListenUpComponent>(ent.Owner); | ||
|
||
_actionsSystem.SetToggled(ent.Comp.SwitchListenUpActionEntity, false); | ||
ent.Comp.toggled = !ent.Comp.toggled; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
listen-up-activated-massage = {$name} Замирает, прислушиваясь. | ||
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
File renamed without changes
File renamed without changes
File renamed without changes.
Binary file added
BIN
+755 Bytes
Resources/Textures/_CorvaxNext/Mobs/Species/Resomi/Abilities/ListenUp/EarsDown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+990 Bytes
Resources/Textures/_CorvaxNext/Mobs/Species/Resomi/Abilities/ListenUp/EarsUp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.