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

Resomi(Update) #191

Merged
merged 12 commits into from
Jan 3, 2025
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
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 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));
}
}
77 changes: 77 additions & 0 deletions Content.Client/_CorvaxNext/Overlays/ListenUpSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
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)
pofitlo-Git marked this conversation as resolved.
Show resolved Hide resolved
{
_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 sprite)
{
_listenUpOverlay = new(radius, sprite);

return _listenUpOverlay;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Content.Shared._CorvaxNext.Resomi.Abilities.Hearing;

namespace Content.Server._CorvaxNext.Resomi.Abilities;

public sealed class ListenUpSkillSystem : SharedListenUpSkillSystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ListenUpSkillComponent, ComponentInit>(OnComponentInit);
}
private void OnComponentInit(Entity<ListenUpSkillComponent> ent, ref ComponentInit args)
{
_actionsSystem.AddAction(ent.Owner, ref ent.Comp.SwitchListenUpActionEntity, ent.Comp.SwitchListenUpAction, ent.Owner);
}
}
21 changes: 21 additions & 0 deletions Content.Server/_CorvaxNext/Resomi/Abilities/ListenUpSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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()
{
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 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
@@ -0,0 +1,22 @@
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

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

[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
@@ -0,0 +1,52 @@
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 (args.Cancelled || args.Handled || 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;
}
}
6 changes: 6 additions & 0 deletions Content.Shared/_CorvaxNext/Resomi/SharedResomi.cs
Original file line number Diff line number Diff line change
@@ -1,11 +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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- files: ["resomi_2, resomi_2_ask, resomi_2_exclaim"]
license: "CC-BY-NC-SA-3.0"
copyright: "Taken from Steam 'Avali sounds' mod / Starbound. Made by Steam user: https://steamcommunity.com/id/Nefuki with permission."
source: "https://steamcommunity.com/sharedfiles/filedetails/?id=3164757879"
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions Resources/Locale/en-US/_corvaxnext/abilitties/agillity.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
agility-activated-massage = ability On.
agility-deactivated-massage = ability Off.


3 changes: 3 additions & 0 deletions Resources/Locale/en-US/_corvaxnext/abilitties/listen-up.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
listen-up-activated-massage = {$name} freezes, listening.


18 changes: 18 additions & 0 deletions Resources/Locale/en-US/_corvaxnext/accessories/resomi-hair.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
marking-HairResomiBackstrafe = Resomi Backstrafe
marking-HairResomiBurstShort = Resomi Burst Short
marking-HairResomiDefault = Resomi Default
marking-HairResomiDroopy = Resomi Droopy
marking-HairResomiEars = Resomi Ears
marking-HairResomiFluffymohawk = Resomi Fluffymohawk
marking-HairResomiHedge = Resomi Hedge
marking-HairResomiLongway = Resomi Longway
marking-HairResomiMane = Resomi Mane
marking-HairResomiManeBeardless = Resomi Mane Beardless
marking-HairResomiMohawk = Resomi Mohawk
marking-HairResomiMushroom = Resomi Mushroom
marking-HairResomiNotree = Resomi Notree
marking-HairResomiSpiky = Resomi Spiky
marking-HairResomiPointy = Resomi Pointy
marking-HairResomiTwies = Resomi Twies
marking-HairResomiUpright = Resomi Upright
marking-HairResomiLong = Resomi Long
29 changes: 29 additions & 0 deletions Resources/Locale/en-US/_corvaxnext/markings/resomi.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
marking-ResomiTail = Resomi Tail
marking-ResomiTail-tail = Resomi Tail

marking-ResomiTailFeathers = Resomi Tail feathers
marking-ResomiTailFeathers-tail_feathers = Resomi Tail feathers

marking-ResomiLArmFeathers = Resomi Left arm feathers
marking-ResomiLArmFeathers-l_hand_feathers = Resomi Left arm feathers

marking-ResomiLLegFeathers = Resomi Left leg feathers
marking-ResomiLLegFeathers-l_foot_feathers = Resomi Left leg feathers

marking-ResomiRArmFeathers = Resomi Right arm feathers
marking-ResomiRArmFeathers-r_hand_feathers = Resomi Right arm feathers

marking-ResomiRLegFeathers = Resomi Right leg feathers
marking-ResomiRLegFeathers-r_foot_feathers = Resomi Right leg feathers

marking-ResomiFluff = Resomi Fluff
marking-ResomiFluff-fluff = Resomi Fluff

marking-ResomiFluffHead = Resomi Fluff head
marking-ResomiFluffHead-fluff_head = Resomi Fluff head


marking-ResomiFluffHeadUp = Resomi Fluff head (Up)
marking-ResomiFluffHeadUp-fluff_head_up = Resomi Fluff head (Up)


3 changes: 3 additions & 0 deletions Resources/Locale/en-US/_corvaxnext/reagents/biological.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
reagent-name-resomi-blood = Purple Blood.
reagent-desc-resomi-blood = Thick liquid with a pungent ammonia odor.

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} Замирает, прислушиваясь.


2 changes: 1 addition & 1 deletion Resources/Locale/ru-RU/_corvaxnext/reagents/biological.ftl
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
reagent-name-resomi-blood = Фиолетовая кровь
reagent-desc-resomi-blood = Густая жидкость с резким аммиачным запахом
reagent-desc-resomi-blood = Густая жидкость с резким аммиачным запахом
Loading
Loading