Updated fishing process
This commit is contained in:
@@ -16,6 +16,7 @@ public sealed class CP14FishingOverlay : Overlay
|
||||
[Dependency] private readonly IPlayerManager _player = default!;
|
||||
[Dependency] private readonly IResourceCache _resourceCache = default!;
|
||||
|
||||
private readonly SpriteSystem _sprite;
|
||||
private readonly TransformSystem _transform;
|
||||
private readonly CP14FishingProcessSystem _fishingProcess;
|
||||
|
||||
@@ -24,11 +25,15 @@ public sealed class CP14FishingOverlay : Overlay
|
||||
private Texture _handleMiddleTexture = default!;
|
||||
private Texture _handleBottomTexture = default!;
|
||||
|
||||
private Texture _lootTexture = default!;
|
||||
|
||||
private Vector2 _backgroundOffset;
|
||||
private Vector2 _backgroundHandleOffset;
|
||||
|
||||
private float _backgroundHandleHeight;
|
||||
|
||||
private Vector2 _progressOffset;
|
||||
private Vector2 _progressSize;
|
||||
|
||||
private EntityUid _process = EntityUid.Invalid;
|
||||
|
||||
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
||||
@@ -37,6 +42,7 @@ public sealed class CP14FishingOverlay : Overlay
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
_sprite = _entity.System<SpriteSystem>();
|
||||
_transform = _entity.System<TransformSystem>();
|
||||
_fishingProcess = _entity.System<CP14FishingProcessSystem>();
|
||||
}
|
||||
@@ -54,6 +60,8 @@ public sealed class CP14FishingOverlay : Overlay
|
||||
{
|
||||
_process = fishingProcess.Value.Owner;
|
||||
UpdateCachedStyleSheet(fishingProcess.Value.Comp.StyleSheet);
|
||||
|
||||
_lootTexture = _sprite.GetPrototypeIcon(fishingProcess.Value.Comp.LootProtoId).Default;
|
||||
}
|
||||
|
||||
// Getting the position of the player we will be working from
|
||||
@@ -63,8 +71,12 @@ public sealed class CP14FishingOverlay : Overlay
|
||||
var playerOffset = fishingProcess.Value.Comp.PlayerPositionNormalized * _backgroundHandleHeight;
|
||||
var playerHalfSize = fishingProcess.Value.Comp.PlayerHalfSizeNormalized * _backgroundHandleHeight;
|
||||
|
||||
var lootOffset = fishingProcess.Value.Comp.LootPositionNormalized * _backgroundHandleHeight;
|
||||
|
||||
DrawBackground(args.WorldHandle, worldPosition - _backgroundOffset);
|
||||
DrawProgress(args.WorldHandle, worldPosition - _backgroundOffset + _progressOffset, _progressSize, fishingProcess.Value.Comp.Progress);
|
||||
DrawHandle(args.WorldHandle, worldPosition - _backgroundOffset + _backgroundHandleOffset + playerOffset, playerHalfSize);
|
||||
DrawLoot(args.WorldHandle, worldPosition - _backgroundOffset + _backgroundHandleOffset + lootOffset);
|
||||
}
|
||||
|
||||
private void DrawBackground(DrawingHandleWorld handle, Vector2 position)
|
||||
@@ -72,6 +84,15 @@ public sealed class CP14FishingOverlay : Overlay
|
||||
handle.DrawTexture(_backgroundTexture, position);
|
||||
}
|
||||
|
||||
private void DrawProgress(DrawingHandleWorld handle, Vector2 position, Vector2 size, float progress)
|
||||
{
|
||||
var vectorA = position;
|
||||
var vectorB = position + size with { Y = size.Y * progress };
|
||||
var box = new Box2(vectorA, vectorB);
|
||||
|
||||
handle.DrawRect(box, Color.Aqua);
|
||||
}
|
||||
|
||||
private void DrawHandle(DrawingHandleWorld handle, Vector2 position, Vector2 halfSize)
|
||||
{
|
||||
var cursor = position - halfSize;
|
||||
@@ -91,6 +112,11 @@ public sealed class CP14FishingOverlay : Overlay
|
||||
handle.DrawTexture(_handleTopTexture, cursor);
|
||||
}
|
||||
|
||||
private void DrawLoot(DrawingHandleWorld handle, Vector2 position)
|
||||
{
|
||||
handle.DrawTexture(_lootTexture, position + Vector2.UnitX * 0.140625f - _lootTexture.Size / 64f);
|
||||
}
|
||||
|
||||
private void UpdateCachedStyleSheet(CP14FishingProcessStyleSheetPrototype styleSheet)
|
||||
{
|
||||
_backgroundTexture = _resourceCache.GetTexture(styleSheet.Background.Texture);
|
||||
@@ -99,7 +125,11 @@ public sealed class CP14FishingOverlay : Overlay
|
||||
_handleBottomTexture = _resourceCache.GetTexture(styleSheet.Handle.BottomTexture);
|
||||
|
||||
_backgroundOffset = styleSheet.Background.Offset + Vector2.UnitX * _backgroundTexture.Width / 32f;
|
||||
|
||||
_backgroundHandleOffset = styleSheet.Background.HandleOffset;
|
||||
_backgroundHandleHeight = styleSheet.Background.HandleHeight;
|
||||
|
||||
_progressOffset = styleSheet.Background.ProgressOffset;
|
||||
_progressSize = styleSheet.Background.ProgressSize;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user