-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #416 from Fansana/master
Floof Station Release V9
- Loading branch information
Showing
209 changed files
with
64,086 additions
and
53,626 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 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,89 @@ | ||
using System.Numerics; | ||
using Content.Shared.Floofstation.Leash.Components; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Enums; | ||
|
||
namespace Content.Client.Floofstation.Leash; | ||
|
||
public sealed class LeashVisualsOverlay : Overlay | ||
{ | ||
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV; | ||
|
||
private readonly IEntityManager _entMan; | ||
private readonly SpriteSystem _sprites; | ||
private readonly SharedTransformSystem _xform; | ||
private readonly EntityQuery<TransformComponent> _xformQuery; | ||
private readonly EntityQuery<SpriteComponent> _spriteQuery; | ||
|
||
public LeashVisualsOverlay(IEntityManager entMan) | ||
{ | ||
_entMan = entMan; | ||
_sprites = _entMan.System<SpriteSystem>(); | ||
_xform = _entMan.System<SharedTransformSystem>(); | ||
_xformQuery = _entMan.GetEntityQuery<TransformComponent>(); | ||
_spriteQuery = _entMan.GetEntityQuery<SpriteComponent>(); | ||
} | ||
|
||
protected override void Draw(in OverlayDrawArgs args) | ||
{ | ||
var worldHandle = args.WorldHandle; | ||
worldHandle.SetTransform(Vector2.Zero, Angle.Zero); | ||
|
||
var query = _entMan.EntityQueryEnumerator<LeashedVisualsComponent>(); | ||
while (query.MoveNext(out var visualsComp)) | ||
{ | ||
if (visualsComp.Source is not {Valid: true} source | ||
|| visualsComp.Target is not {Valid: true} target | ||
|| !_xformQuery.TryGetComponent(source, out var xformComp) | ||
|| !_xformQuery.TryGetComponent(target, out var otherXformComp) | ||
|| xformComp.MapID != args.MapId | ||
|| otherXformComp.MapID != xformComp.MapID) | ||
continue; | ||
|
||
var texture = _sprites.Frame0(visualsComp.Sprite); | ||
var width = texture.Width / (float) EyeManager.PixelsPerMeter; | ||
|
||
var coordsA = xformComp.Coordinates; | ||
var coordsB = otherXformComp.Coordinates; | ||
|
||
// If both coordinates are in the same spot (e.g. the leash is being held by the leashed), don't render anything | ||
if (coordsA.TryDistance(_entMan, _xform, coordsB, out var dist) && dist < 0.01f) | ||
continue; | ||
|
||
var rotA = xformComp.LocalRotation; | ||
var rotB = otherXformComp.LocalRotation; | ||
var offsetA = visualsComp.OffsetSource; | ||
var offsetB = visualsComp.OffsetTarget; | ||
|
||
// Sprite rotation is the rotation along the Z axis | ||
// Which is different from transform rotation for all mobs that are seen from the side (instead of top-down) | ||
if (_spriteQuery.TryGetComponent(source, out var spriteA)) | ||
{ | ||
offsetA *= spriteA.Scale; | ||
rotA = spriteA.Rotation; | ||
} | ||
if (_spriteQuery.TryGetComponent(target, out var spriteB)) | ||
{ | ||
offsetB *= spriteB.Scale; | ||
rotB = spriteB.Rotation; | ||
} | ||
|
||
coordsA = coordsA.Offset(rotA.RotateVec(offsetA)); | ||
coordsB = coordsB.Offset(rotB.RotateVec(offsetB)); | ||
|
||
var posA = _xform.ToMapCoordinates(coordsA).Position; | ||
var posB = _xform.ToMapCoordinates(coordsB).Position; | ||
var diff = (posB - posA); | ||
var length = diff.Length(); | ||
|
||
// So basically, we find the midpoint, then create a box that describes the sprite boundaries, then rotate it | ||
var midPoint = diff / 2f + posA; | ||
var angle = (posB - posA).ToWorldAngle(); | ||
var box = new Box2(-width / 2f, -length / 2f, width / 2f, length / 2f); | ||
var rotate = new Box2Rotated(box.Translated(midPoint), angle, midPoint); | ||
|
||
worldHandle.DrawTextureRect(texture, rotate); | ||
} | ||
} | ||
} |
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,21 @@ | ||
using Content.Client.Physics; | ||
using Robust.Client.Graphics; | ||
|
||
namespace Content.Client.Floofstation.Leash; | ||
|
||
public sealed class LeashVisualsSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IOverlayManager _overlay = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
_overlay.AddOverlay(new LeashVisualsOverlay(EntityManager)); | ||
} | ||
|
||
public override void Shutdown() | ||
{ | ||
base.Shutdown(); | ||
_overlay.RemoveOverlay<LeashVisualsOverlay>(); | ||
} | ||
} |
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,65 @@ | ||
using Content.Shared.FootPrint; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Client.FootPrint; | ||
|
||
public sealed class FootPrintsVisualizerSystem : VisualizerSystem<FootPrintComponent> | ||
{ | ||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<FootPrintComponent, ComponentInit>(OnInitialized); | ||
SubscribeLocalEvent<FootPrintComponent, ComponentShutdown>(OnShutdown); | ||
} | ||
|
||
private void OnInitialized(EntityUid uid, FootPrintComponent comp, ComponentInit args) | ||
{ | ||
if (!TryComp<SpriteComponent>(uid, out var sprite)) | ||
return; | ||
|
||
sprite.LayerMapReserveBlank(FootPrintVisualLayers.Print); | ||
UpdateAppearance(uid, comp, sprite); | ||
} | ||
|
||
private void OnShutdown(EntityUid uid, FootPrintComponent comp, ComponentShutdown args) | ||
{ | ||
if (TryComp<SpriteComponent>(uid, out var sprite) | ||
&& sprite.LayerMapTryGet(FootPrintVisualLayers.Print, out var layer)) | ||
sprite.RemoveLayer(layer); | ||
} | ||
|
||
private void UpdateAppearance(EntityUid uid, FootPrintComponent component, SpriteComponent sprite) | ||
{ | ||
if (!sprite.LayerMapTryGet(FootPrintVisualLayers.Print, out var layer) | ||
|| !TryComp<FootPrintsComponent>(component.PrintOwner, out var printsComponent) | ||
|| !TryComp<AppearanceComponent>(uid, out var appearance) | ||
|| !_appearance.TryGetData<FootPrintVisuals>(uid, FootPrintVisualState.State, out var printVisuals, appearance)) | ||
return; | ||
|
||
sprite.LayerSetState(layer, new RSI.StateId(printVisuals switch | ||
{ | ||
FootPrintVisuals.BareFootPrint => printsComponent.RightStep ? printsComponent.RightBarePrint : printsComponent.LeftBarePrint, | ||
FootPrintVisuals.ShoesPrint => printsComponent.ShoesPrint, | ||
FootPrintVisuals.SuitPrint => printsComponent.SuitPrint, | ||
FootPrintVisuals.Dragging => _random.Pick(printsComponent.DraggingPrint), | ||
_ => throw new ArgumentOutOfRangeException($"Unknown {printVisuals} parameter.") | ||
}), printsComponent.RsiPath); | ||
|
||
if (_appearance.TryGetData<Color>(uid, FootPrintVisualState.Color, out var printColor, appearance)) | ||
sprite.LayerSetColor(layer, printColor); | ||
} | ||
|
||
protected override void OnAppearanceChange (EntityUid uid, FootPrintComponent component, ref AppearanceChangeEvent args) | ||
{ | ||
if (args.Sprite is not { } sprite) | ||
return; | ||
|
||
UpdateAppearance(uid, component, 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
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.