-
Notifications
You must be signed in to change notification settings - Fork 203
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
2b79fdc
commit 21e3d85
Showing
11 changed files
with
163 additions
and
83 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
Empty file.
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,57 @@ | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Random; | ||
using Content.Shared.DeltaV.Harpy.Events; | ||
using Content.Shared.DeltaV.Harpy.Components; | ||
|
||
namespace Content.Client.DeltaV.Harpy; | ||
|
||
/// <summary> | ||
/// Handles offsetting an entity while flying | ||
/// </summary> | ||
public abstract class FlyingVisualizerSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IPrototypeManager _protoMan = default!; | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
private ShaderInstance _shader = default!; | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
_shader = _protoMan.Index<ShaderPrototype>("Wave").InstanceUnique(); | ||
|
||
SubscribeLocalEvent<FlyingVisualsComponent, ComponentStartup>(OnStartup); | ||
SubscribeLocalEvent<FlyingVisualsComponent, ComponentShutdown>(OnShutdown); | ||
SubscribeLocalEvent<FlyingVisualsComponent, BeforePostShaderRenderEvent>(OnBeforeShaderPost); | ||
} | ||
|
||
private void OnStartup(EntityUid uid, FlyingVisualsComponent comp, ref ComponentStartup args) | ||
{ | ||
_shader = _protoMan.Index<ShaderPrototype>("Wave").InstanceUnique(); | ||
comp.Offset = _random.NextFloat(0, 1000); | ||
SetShader(uid, _shader); | ||
} | ||
|
||
private void OnShutdown(EntityUid uid, FlyingVisualsComponent comp, ref ComponentShutdown args) | ||
{ | ||
SetShader(uid, null); | ||
} | ||
|
||
private void SetShader(Entity<SpriteComponent?> entity, ShaderInstance? instance) | ||
{ | ||
if (!Resolve(entity, ref entity.Comp, false)) | ||
return; | ||
|
||
entity.Comp.PostShader = instance; | ||
entity.Comp.GetScreenTexture = instance is not null; | ||
entity.Comp.RaiseShaderEvent = instance is not null; | ||
} | ||
|
||
private void OnBeforeShaderPost(EntityUid uid, FlyingVisualsComponent comp, ref BeforePostShaderRenderEvent args) | ||
{ | ||
_shader.SetParameter("Speed", comp.Speed); | ||
_shader.SetParameter("Dis", comp.Dis); | ||
_shader.SetParameter("Offset", comp.Offset); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
Content.Shared/DeltaV/Harpy/Components/FlyingVisualsComponent.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,29 @@ | ||
using System.Numerics; | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.DeltaV.Harpy.Components; | ||
|
||
[RegisterComponent, NetworkedComponent] | ||
public sealed partial class FlyingVisualsComponent : Component | ||
{ | ||
/// <summary> | ||
/// How long does the animation last | ||
/// </summary> | ||
[DataField] | ||
public float AnimationTime = 2f; | ||
|
||
/// <summary> | ||
/// How far it goes in any direction. | ||
/// </summary> | ||
[DataField] | ||
public float Offset = 0.2f; | ||
|
||
/// <summary> | ||
/// How much the limbs (if there are any) rotate. | ||
/// </summary> | ||
[DataField] | ||
public float Rotation = 0.5f; | ||
|
||
[DataField] | ||
public string AnimationKey = default; | ||
} |
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
Empty file.
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
69 changes: 0 additions & 69 deletions
69
Content.Shared/DeltaV/Harpy/SharedFlyingVisualizerSystem.cs
This file was deleted.
Oops, something went wrong.
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