Skip to content

Commit

Permalink
second
Browse files Browse the repository at this point in the history
  • Loading branch information
pofitlo-Git committed Dec 25, 2024
1 parent 4245a86 commit 772b361
Show file tree
Hide file tree
Showing 19 changed files with 326 additions and 32 deletions.
96 changes: 96 additions & 0 deletions Content.Client/_CorvaxNext/Overlays/ListenUpOverlay.cs
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));
}
}
75 changes: 75 additions & 0 deletions Content.Client/_CorvaxNext/Overlays/ListenUpSystem.cs
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);
}
}
17 changes: 2 additions & 15 deletions Content.Server/_CorvaxNext/Resomi/Abilities/ListenUpSkillSystem.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
using Content.Shared.Actions;
using Content.Shared.Alert;
using Content.Shared.Maps;
using Robust.Shared.Containers;
using Robust.Shared.Map;
using Robust.Shared.Timing;
using Content.Shared._CorvaxNext.Resomi;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Content.Shared._CorvaxNext.Resomi.Abilities;
using Content.Shared.Damage.Components;
using Robust.Shared.Physics;
using Content.Shared._CorvaxNext.Resomi.Abilities.Hearing;

namespace Content.Server._CorvaxNext.Resomi.Abilities;
Expand All @@ -20,11 +8,10 @@ public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ListenUpSkillComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<ListenUpSkillComponent, ListenUpActionEvent>(SwitchAgility);
SubscribeLocalEvent<ListenUpSkillComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);
}
private void OnComponentInit(Entity<ListenUpSkillComponent> ent, ref ComponentInit args)
{
_actionsSystem.AddAction(ent.Owner, ref ent.Comp.SwitchAgilityActionEntity, ent.Comp.SwitchAgilityAction, ent.Owner);
_actionsSystem.AddAction(ent.Owner, ref ent.Comp.SwitchListenUpActionEntity, ent.Comp.SwitchListenUpAction, ent.Owner);

}
}
22 changes: 22 additions & 0 deletions Content.Server/_CorvaxNext/Resomi/Abilities/ListenUpSystem.cs
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);
}
}
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");
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@

namespace Content.Shared._CorvaxNext.Resomi.Abilities.Hearing;

[RegisterComponent, NetworkedComponent]
[AutoGenerateComponentState]
[RegisterComponent]
public sealed partial class ListenUpSkillComponent : Component
{

[DataField("switchListenUpAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string? SwitchListenUpAction = "SwitchListenUpAction";

[DataField]
public EntityUid? SwitchListenUpActionEntity;

[DataField]
public bool toggled = false;

[DataField]
public float prepareTime = 3f;
}
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;
}
}
4 changes: 4 additions & 0 deletions Content.Shared/_CorvaxNext/Resomi/SharedResomi.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
using Content.Shared.Actions;
using Content.Shared.DoAfter;
using Robust.Shared.Serialization;
using Content.Shared._CorvaxNext.Resomi.Abilities.Hearing;

namespace Content.Shared._CorvaxNext.Resomi;

public sealed partial class SwitchAgillityActionEvent : InstantActionEvent;

public sealed partial class ListenUpActionEvent : InstantActionEvent;

[Serializable, NetSerializable]
public sealed partial class ListenUpDoAfterEvent : SimpleDoAfterEvent;

/// <summary>
/// Rises when the action state changes
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions Resources/Locale/ru-RU/_corvaxNext/abilitties/listen-up.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
listen-up-activated-massage = {$name} Замирает, прислушиваясь.
9 changes: 5 additions & 4 deletions Resources/Prototypes/_CorvaxNext/Actions/resomi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
description: Switching agility
components:
- type: InstantAction
icon: _CorvaxNext/Mobs/Species/Resomi/Abilities/AgilityOff.png
iconOn: _CorvaxNext/Mobs/Species/Resomi/Abilities/AgilityOn.png
icon: _CorvaxNext/Mobs/Species/Resomi/Abilities/Agility/AgilityOff.png
iconOn: _CorvaxNext/Mobs/Species/Resomi/Abilities/Agility/AgilityOn.png
event: !type:SwitchAgillityActionEvent

- type: entity
id: ListenUpAction
id: SwitchListenUpAction
name: Listen up
description: Listen up
components:
- type: InstantAction
icon: _CorvaxNext/Mobs/Species/Resomi/Abilities/AgilityOff.png
icon: _CorvaxNext/Mobs/Species/Resomi/Abilities/ListenUp/EarsDown.png
iconOn: _CorvaxNext/Mobs/Species/Resomi/Abilities/ListenUp/EarsUp.png
event: !type:ListenUpActionEvent
14 changes: 12 additions & 2 deletions Resources/Prototypes/_CorvaxNext/Entities/Species/resomi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
components:
- type: WeaponsUseInability
- type: AgillitySkill
- type: ListenUpSkill
- type: ChatModifier
whisperListeningRange: 4
- type: FlashModifier
modifier: 2
- type: ResomiAccent
- type: FootprintVisualizer
leftBarePrint: "footprint-left-bare-lizard"
rightBarePrint: "footprint-right-bare-lizard"
- type: DamageVisuals
thresholds: [ 10, 30, 50, 70]
targetLayers:
Expand Down Expand Up @@ -91,8 +96,13 @@
Male: MaleResomi
Female: FemaleResomi
Unsexed: MaleResomi
- type: FlashModifier
modifier: 2
#- type: Respirator
# damage:
# types:
# Asphyxiation: 1.0
damageRecovery:
types:
Asphyxiation: -1.0
- type: Hands
handDisplacement:
sizeMaps:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 772b361

Please sign in to comment.