-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into Longarms-Require-Wielding
- Loading branch information
Showing
292 changed files
with
6,487 additions
and
2,498 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
Content.Client/Flight/Components/FlightVisualsComponent.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,40 @@ | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Client.Flight.Components; | ||
|
||
[RegisterComponent] | ||
public sealed partial class FlightVisualsComponent : Component | ||
{ | ||
/// <summary> | ||
/// How long does the animation last | ||
/// </summary> | ||
[DataField] | ||
public float Speed; | ||
|
||
/// <summary> | ||
/// How far it goes in any direction. | ||
/// </summary> | ||
[DataField] | ||
public float Multiplier; | ||
|
||
/// <summary> | ||
/// How much the limbs (if there are any) rotate. | ||
/// </summary> | ||
[DataField] | ||
public float Offset; | ||
|
||
/// <summary> | ||
/// Are we animating layers or the entire sprite? | ||
/// </summary> | ||
public bool AnimateLayer = false; | ||
public int? TargetLayer; | ||
|
||
[DataField] | ||
public string AnimationKey = "default"; | ||
|
||
[ViewVariables(VVAccess.ReadWrite)] | ||
public ShaderInstance Shader = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using Robust.Client.GameObjects; | ||
using Content.Shared.Flight; | ||
using Content.Shared.Flight.Events; | ||
using Content.Client.Flight.Components; | ||
|
||
namespace Content.Client.Flight; | ||
public sealed class FlightSystem : SharedFlightSystem | ||
{ | ||
[Dependency] private readonly IEntityManager _entityManager = default!; | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeNetworkEvent<FlightEvent>(OnFlight); | ||
|
||
} | ||
|
||
private void OnFlight(FlightEvent args) | ||
{ | ||
var uid = GetEntity(args.Uid); | ||
if (!_entityManager.TryGetComponent(uid, out SpriteComponent? sprite) | ||
|| !args.IsAnimated | ||
|| !_entityManager.TryGetComponent(uid, out FlightComponent? flight)) | ||
return; | ||
|
||
|
||
int? targetLayer = null; | ||
if (flight.IsLayerAnimated && flight.Layer is not null) | ||
{ | ||
targetLayer = GetAnimatedLayer(uid, flight.Layer, sprite); | ||
if (targetLayer == null) | ||
return; | ||
} | ||
|
||
if (args.IsFlying && args.IsAnimated && flight.AnimationKey != "default") | ||
{ | ||
var comp = new FlightVisualsComponent | ||
{ | ||
AnimateLayer = flight.IsLayerAnimated, | ||
AnimationKey = flight.AnimationKey, | ||
Multiplier = flight.ShaderMultiplier, | ||
Offset = flight.ShaderOffset, | ||
Speed = flight.ShaderSpeed, | ||
TargetLayer = targetLayer, | ||
}; | ||
AddComp(uid, comp); | ||
} | ||
if (!args.IsFlying) | ||
RemComp<FlightVisualsComponent>(uid); | ||
} | ||
|
||
public int? GetAnimatedLayer(EntityUid uid, string targetLayer, SpriteComponent? sprite = null) | ||
{ | ||
if (!Resolve(uid, ref sprite)) | ||
return null; | ||
|
||
int index = 0; | ||
foreach (var layer in sprite.AllLayers) | ||
{ | ||
// This feels like absolute shitcode, isn't there a better way to check for it? | ||
if (layer.Rsi?.Path.ToString() == targetLayer) | ||
return index; | ||
index++; | ||
} | ||
return null; | ||
} | ||
} |
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,64 @@ | ||
using Content.Client.Flight.Components; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client.Flight; | ||
|
||
/// <summary> | ||
/// Handles offsetting an entity while flying | ||
/// </summary> | ||
public sealed class FlyingVisualizerSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IPrototypeManager _protoMan = default!; | ||
[Dependency] private readonly SpriteSystem _spriteSystem = default!; | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<FlightVisualsComponent, ComponentStartup>(OnStartup); | ||
SubscribeLocalEvent<FlightVisualsComponent, ComponentShutdown>(OnShutdown); | ||
SubscribeLocalEvent<FlightVisualsComponent, BeforePostShaderRenderEvent>(OnBeforeShaderPost); | ||
} | ||
|
||
private void OnStartup(EntityUid uid, FlightVisualsComponent comp, ComponentStartup args) | ||
{ | ||
comp.Shader = _protoMan.Index<ShaderPrototype>(comp.AnimationKey).InstanceUnique(); | ||
AddShader(uid, comp.Shader, comp.AnimateLayer, comp.TargetLayer); | ||
SetValues(comp, comp.Speed, comp.Offset, comp.Multiplier); | ||
} | ||
|
||
private void OnShutdown(EntityUid uid, FlightVisualsComponent comp, ComponentShutdown args) | ||
{ | ||
AddShader(uid, null, comp.AnimateLayer, comp.TargetLayer); | ||
} | ||
|
||
private void AddShader(Entity<SpriteComponent?> entity, ShaderInstance? shader, bool animateLayer, int? layer) | ||
{ | ||
if (!Resolve(entity, ref entity.Comp, false)) | ||
return; | ||
|
||
if (!animateLayer) | ||
entity.Comp.PostShader = shader; | ||
|
||
if (animateLayer && layer is not null) | ||
entity.Comp.LayerSetShader(layer.Value, shader); | ||
|
||
entity.Comp.GetScreenTexture = shader is not null; | ||
entity.Comp.RaiseShaderEvent = shader is not null; | ||
} | ||
|
||
/// <summary> | ||
/// This function can be used to modify the shader's values while its running. | ||
/// </summary> | ||
private void OnBeforeShaderPost(EntityUid uid, FlightVisualsComponent comp, ref BeforePostShaderRenderEvent args) | ||
{ | ||
SetValues(comp, comp.Speed, comp.Offset, comp.Multiplier); | ||
} | ||
|
||
private void SetValues(FlightVisualsComponent comp, float speed, float offset, float multiplier) | ||
{ | ||
comp.Shader.SetParameter("Speed", speed); | ||
comp.Shader.SetParameter("Offset", offset); | ||
comp.Shader.SetParameter("Multiplier", multiplier); | ||
} | ||
} |
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
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
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
Oops, something went wrong.