я усталь

This commit is contained in:
Deserty0
2025-09-12 13:44:21 +10:00
parent 59d776ca72
commit 0c7dd03f79
4 changed files with 41 additions and 3 deletions

View File

@@ -1,20 +1,19 @@
using System.Numerics;
using Content.Client._CP14.Input;
using Content.Client.Hands.Systems;
using Content.Client.Interactable;
using Content.Client.Resources;
using Content.Client.UserInterface.Screens;
using Content.Shared._CP14.Fishing;
using Content.Shared._CP14.Fishing.Components;
using Content.Shared._CP14.Input;
using Content.Shared.Interaction;
using Robust.Client;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Input;
using Robust.Shared.Input.Binding;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
@@ -28,6 +27,7 @@ public sealed class CP14FishingSystem : CP14SharedFishingSystem
[Dependency] private readonly InputSystem _input = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly HandsSystem _handsSystem = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
private Popup? _fishingPopup;
@@ -46,7 +46,11 @@ public sealed class CP14FishingSystem : CP14SharedFishingSystem
if (!fishingRodComponent.FishCaught)
return;
if (_playerManager.LocalSession?.AttachedEntity is not { } player)
return;
var reeling = _input.CmdStates.GetState(CP14ContentKeyFunctions.CP14FishingAction) == BoundKeyState.Down;
RaiseNetworkEvent(new FishingReelKeyMessage(player, reeling));
}
private void OpenFishingPopup(EntityUid uid, CP14FishingRodComponent component, AfterInteractEvent args)

View File

@@ -1,3 +1,4 @@
using Content.Server.Hands.Systems;
using Content.Shared._CP14.Fishing;
using Content.Shared._CP14.Fishing.Components;
using Content.Shared.Interaction;
@@ -10,12 +11,14 @@ public sealed class CP14FishingSystem : CP14SharedFishingSystem
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly ThrowingSystem _throwingSystem = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly HandsSystem _handsSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CP14FishingRodComponent, AfterInteractEvent>(OnInteract);
SubscribeNetworkEvent<FishingReelKeyMessage>(OnReelingMessage);
}
public override void Update(float delta)
@@ -37,8 +40,21 @@ public sealed class CP14FishingSystem : CP14SharedFishingSystem
}
}
private void OnReelingMessage(FishingReelKeyMessage msg)
{
var held = _handsSystem.GetActiveItem(msg.User);
if (!TryComp<CP14FishingRodComponent>(held, out var rodComponent))
return;
rodComponent.Reeling = msg.Reeling;
}
private void OnInteract(EntityUid uid, CP14FishingRodComponent component, AfterInteractEvent args)
{
if (args.Handled)
return;
if (args.Target is not { Valid: true })
return;
@@ -51,6 +67,7 @@ public sealed class CP14FishingSystem : CP14SharedFishingSystem
if (!_interactionSystem.InRangeUnobstructed(uid, args.Target.Value, component.MaxFishingDistance))
return;
args.Handled = true;
CastFloat(uid, component, args.Target.Value);
}

View File

@@ -1,5 +1,6 @@
using Content.Shared._CP14.Fishing.Components;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
namespace Content.Shared._CP14.Fishing;
@@ -33,4 +34,17 @@ public abstract class CP14SharedFishingSystem : EntitySystem
_random.SetSeed((int)_gameTiming.CurTick.Value);
component.FishingTime += TimeSpan.FromSeconds(_random.NextDouble(component.MinAwaitTime, component.MaxAwaitTime));
}
[Serializable, NetSerializable]
public sealed class FishingReelKeyMessage : EntityEventArgs
{
public EntityUid User { get; }
public bool Reeling { get; }
public FishingReelKeyMessage(EntityUid user, bool reeling)
{
User = user;
Reeling = reeling;
}
}
}

View File

@@ -21,6 +21,9 @@ public sealed partial class CP14FishingRodComponent : Component
[AutoNetworkedField]
public bool FishCaught;
[AutoNetworkedField]
public bool Reeling;
[DataField]
public EntProtoId FloatPrototype = "CP14DefaultFishingFloat";