фикс системы таскания
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
using System.Linq;
|
||||
using Content.Server._White.Carrying;
|
||||
using Content.Server._White.Cult.GameRule;
|
||||
using Content.Server.Administration.Systems;
|
||||
using Content.Server.Bible.Components;
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Server.Borer;
|
||||
using Content.Server.Carrying;
|
||||
using Content.Server.Cuffs;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Emp;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Server._White.Carrying;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Disposal.Tube;
|
||||
using Content.Server.Carrying;
|
||||
using Content.Server.Disposal.Tube.Components;
|
||||
using Content.Server.Disposal.Unit.Components;
|
||||
using Content.Server.Popups;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Content.Server._White.Carrying;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Server.Carrying;
|
||||
using Content.Shared.Storage;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
@@ -41,7 +41,8 @@ public sealed class EscapeInventorySystem : EntitySystem
|
||||
if (!args.HasDirectionalMovement)
|
||||
return;
|
||||
|
||||
if (!_containerSystem.TryGetContainingContainer(uid, out var container) || !_actionBlockerSystem.CanInteract(uid, container.Owner))
|
||||
if (!_containerSystem.TryGetContainingContainer(uid, out var container) ||
|
||||
!_actionBlockerSystem.CanInteract(uid, container.Owner))
|
||||
return;
|
||||
|
||||
// Make sure there's nothing stopped the removal (like being glued)
|
||||
@@ -59,16 +60,22 @@ public sealed class EscapeInventorySystem : EntitySystem
|
||||
}
|
||||
|
||||
// Uncontested
|
||||
if (HasComp<StorageComponent>(container.Owner) || HasComp<InventoryComponent>(container.Owner) || HasComp<SecretStashComponent>(container.Owner))
|
||||
if (HasComp<StorageComponent>(container.Owner) || HasComp<InventoryComponent>(container.Owner) ||
|
||||
HasComp<SecretStashComponent>(container.Owner))
|
||||
AttemptEscape(uid, container.Owner, component);
|
||||
}
|
||||
|
||||
public void AttemptEscape(EntityUid user, EntityUid container, CanEscapeInventoryComponent component, float multiplier = 1f)
|
||||
public void AttemptEscape(
|
||||
EntityUid user,
|
||||
EntityUid container,
|
||||
CanEscapeInventoryComponent component,
|
||||
float multiplier = 1f)
|
||||
{
|
||||
if (component.IsEscaping)
|
||||
return;
|
||||
|
||||
var doAfterEventArgs = new DoAfterArgs(EntityManager, user, component.BaseResistTime * multiplier, new EscapeInventoryEvent(), user, target: container)
|
||||
var doAfterEventArgs = new DoAfterArgs(EntityManager, user, component.BaseResistTime * multiplier,
|
||||
new EscapeInventoryEvent(), user, target: container)
|
||||
{
|
||||
BreakOnMove = true,
|
||||
BreakOnDamage = true,
|
||||
@@ -79,7 +86,8 @@ public sealed class EscapeInventorySystem : EntitySystem
|
||||
return;
|
||||
|
||||
_popupSystem.PopupEntity(Loc.GetString("escape-inventory-component-start-resisting"), user, user);
|
||||
_popupSystem.PopupEntity(Loc.GetString("escape-inventory-component-start-resisting-target"), container, container);
|
||||
_popupSystem.PopupEntity(Loc.GetString("escape-inventory-component-start-resisting-target"), container,
|
||||
container);
|
||||
}
|
||||
|
||||
private void OnEscape(EntityUid uid, CanEscapeInventoryComponent component, EscapeInventoryEvent args)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
namespace Content.Server.Carrying
|
||||
{
|
||||
namespace Content.Server._White.Carrying;
|
||||
|
||||
/// <summary>
|
||||
/// Stores the carrier of an entity being carried.
|
||||
/// </summary>
|
||||
@@ -8,4 +8,3 @@ namespace Content.Server.Carrying
|
||||
{
|
||||
public EntityUid Carrier = default!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Threading;
|
||||
|
||||
namespace Content.Server.Carrying
|
||||
{
|
||||
namespace Content.Server._White.Carrying;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class CarriableComponent : Component
|
||||
{
|
||||
@@ -9,9 +9,8 @@ namespace Content.Server.Carrying
|
||||
/// Number of free hands required
|
||||
/// to carry the entity
|
||||
/// </summary>
|
||||
[DataField("freeHandsRequired")]
|
||||
[DataField]
|
||||
public int FreeHandsRequired = 2;
|
||||
|
||||
public CancellationTokenSource? CancelToken;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
namespace Content.Server.Carrying
|
||||
{
|
||||
namespace Content.Server._White.Carrying;
|
||||
|
||||
/// <summary>
|
||||
/// Added to an entity when they are carrying somebody.
|
||||
/// </summary>
|
||||
@@ -8,4 +8,3 @@ namespace Content.Server.Carrying
|
||||
{
|
||||
public EntityUid Carried = default!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,34 @@
|
||||
using System.Threading;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Resist;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Inventory;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Resist;
|
||||
using Content.Shared._White.Carrying;
|
||||
using Content.Shared._White.Crossbow;
|
||||
using Content.Shared.Mobs;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Stunnable;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Verbs;
|
||||
using Content.Shared.Carrying;
|
||||
using Content.Shared.Movement.Events;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Content.Shared.Standing;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.Climbing.Events;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Inventory.VirtualItem;
|
||||
using Content.Shared.Throwing;
|
||||
using Content.Shared.Mobs;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Content.Shared.Movement.Events;
|
||||
using Content.Shared.Movement.Pulling.Components;
|
||||
using Content.Shared.Movement.Pulling.Events;
|
||||
using Content.Shared.Movement.Pulling.Systems;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Content.Shared.Standing;
|
||||
using Content.Shared.Stunnable;
|
||||
using Content.Shared.Throwing;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Map.Components;
|
||||
|
||||
namespace Content.Server.Carrying
|
||||
{
|
||||
namespace Content.Server._White.Carrying;
|
||||
|
||||
public sealed class CarryingSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly VirtualItemSystem _virtualItemSystem = default!;
|
||||
@@ -40,6 +42,7 @@ namespace Content.Server.Carrying
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeed = default!;
|
||||
[Dependency] private readonly PenetratedSystem _penetrated = default!;
|
||||
[Dependency] private readonly TransformSystem _transform = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -60,7 +63,6 @@ namespace Content.Server.Carrying
|
||||
SubscribeLocalEvent<CarriableComponent, CarryDoAfterEvent>(OnDoAfter);
|
||||
}
|
||||
|
||||
|
||||
private void AddCarryVerb(EntityUid uid, CarriableComponent component, GetVerbsEvent<AlternativeVerb> args)
|
||||
{
|
||||
if (!args.CanInteract || !args.CanAccess)
|
||||
@@ -90,6 +92,7 @@ namespace Content.Server.Carrying
|
||||
Text = Loc.GetString("carry-verb"),
|
||||
Priority = 2
|
||||
};
|
||||
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
@@ -110,13 +113,11 @@ namespace Content.Server.Carrying
|
||||
/// </summary>
|
||||
private void OnThrow(EntityUid uid, CarryingComponent component, ref BeforeThrowEvent args)
|
||||
{
|
||||
if (!TryComp<VirtualItemComponent>(args.ItemUid, out var virtItem) || !HasComp<CarriableComponent>(virtItem.BlockingEntity))
|
||||
if (!TryComp<VirtualItemComponent>(args.ItemUid, out var virtItem) ||
|
||||
!HasComp<CarriableComponent>(virtItem.BlockingEntity))
|
||||
return;
|
||||
|
||||
args.ItemUid = virtItem.BlockingEntity;
|
||||
|
||||
var multiplier = _contests.MassContest(uid, virtItem.BlockingEntity);
|
||||
args.ThrowStrength = 5f * multiplier;
|
||||
}
|
||||
|
||||
private void OnParentChanged(EntityUid uid, CarryingComponent component, ref EntParentChangedMessage args)
|
||||
@@ -156,7 +157,7 @@ namespace Content.Server.Carrying
|
||||
|
||||
if (_actionBlockerSystem.CanInteract(uid, component.Carrier))
|
||||
{
|
||||
_escapeInventorySystem.AttemptEscape(uid, component.Carrier, escape, _contests.MassContest(uid, component.Carrier));
|
||||
_escapeInventorySystem.AttemptEscape(uid, component.Carrier, escape);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +171,10 @@ namespace Content.Server.Carrying
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private void OnInteractedWith(EntityUid uid, BeingCarriedComponent component, GettingInteractedWithAttemptEvent args)
|
||||
private void OnInteractedWith(
|
||||
EntityUid uid,
|
||||
BeingCarriedComponent component,
|
||||
GettingInteractedWithAttemptEvent args)
|
||||
{
|
||||
if (args.Uid != component.Carrier)
|
||||
args.Cancel();
|
||||
@@ -203,18 +207,15 @@ namespace Content.Server.Carrying
|
||||
Carry(args.Args.User, uid);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void StartCarryDoAfter(EntityUid carrier, EntityUid carried, CarriableComponent component)
|
||||
{
|
||||
TimeSpan length = TimeSpan.FromSeconds(3);
|
||||
|
||||
var mod = _contests.MassContest(carrier, carried);
|
||||
|
||||
if (mod != 0)
|
||||
length /= mod;
|
||||
|
||||
var length = TimeSpan.FromSeconds(6); // т.к. удалили систему разницы масс увеличу время с 3 до 6
|
||||
if (length >= TimeSpan.FromSeconds(9))
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("carry-too-heavy"), carried, carrier, Shared.Popups.PopupType.SmallCaution);
|
||||
_popupSystem.PopupEntity(Loc.GetString("carry-too-heavy"), carried, carrier,
|
||||
Shared.Popups.PopupType.SmallCaution);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -226,8 +227,7 @@ namespace Content.Server.Carrying
|
||||
var ev = new CarryDoAfterEvent();
|
||||
var args = new DoAfterArgs(EntityManager, carrier, length, ev, carried, target: carried)
|
||||
{
|
||||
BreakOnTargetMove = true,
|
||||
BreakOnUserMove = true,
|
||||
BreakOnMove = true,
|
||||
NeedHand = true
|
||||
};
|
||||
|
||||
@@ -236,19 +236,21 @@ namespace Content.Server.Carrying
|
||||
|
||||
private void Carry(EntityUid carrier, EntityUid carried)
|
||||
{
|
||||
if (TryComp<SharedPullableComponent>(carried, out var pullable))
|
||||
_pullingSystem.TryStopPull(pullable);
|
||||
if (TryComp<PullableComponent>(carried, out var pullable))
|
||||
_pullingSystem.TryStopPull(carried, pullable);
|
||||
|
||||
_penetrated.FreePenetrated(carried);
|
||||
|
||||
Transform(carrier).AttachToGridOrMap();
|
||||
Transform(carried).AttachToGridOrMap();
|
||||
Transform(carried).Coordinates = Transform(carrier).Coordinates;
|
||||
Transform(carried).AttachParent(Transform(carrier));
|
||||
_transform.AttachToGridOrMap(carrier);
|
||||
_transform.AttachToGridOrMap(carried);
|
||||
_transform.SetCoordinates(carried, Transform(carrier).Coordinates);
|
||||
_transform.SetParent(carried, carrier);
|
||||
|
||||
_virtualItemSystem.TrySpawnVirtualItemInHand(carried, carrier);
|
||||
_virtualItemSystem.TrySpawnVirtualItemInHand(carried, carrier);
|
||||
|
||||
var carryingComp = EnsureComp<CarryingComponent>(carrier);
|
||||
ApplyCarrySlowdown(carrier, carried);
|
||||
ApplyCarrySlowdown(carrier);
|
||||
var carriedComp = EnsureComp<BeingCarriedComponent>(carried);
|
||||
EnsureComp<KnockedDownComponent>(carried);
|
||||
EnsureComp<CanEscapeInventoryComponent>(carried);
|
||||
@@ -266,25 +268,18 @@ namespace Content.Server.Carrying
|
||||
RemComp<BeingCarriedComponent>(carried);
|
||||
RemComp<KnockedDownComponent>(carried);
|
||||
RemComp<CanEscapeInventoryComponent>(carried);
|
||||
|
||||
_actionBlockerSystem.UpdateCanMove(carried);
|
||||
_virtualItemSystem.DeleteInHandsMatching(carrier, carried);
|
||||
Transform(carried).AttachToGridOrMap();
|
||||
_transform.AttachToGridOrMap(carried);
|
||||
_standingState.Stand(carried);
|
||||
_movementSpeed.RefreshMovementSpeedModifiers(carrier);
|
||||
}
|
||||
|
||||
private void ApplyCarrySlowdown(EntityUid carrier, EntityUid carried)
|
||||
private void ApplyCarrySlowdown(EntityUid carrier)
|
||||
{
|
||||
var massRatio = _contests.MassContest(carrier, carried);
|
||||
|
||||
if (massRatio == 0)
|
||||
massRatio = 1;
|
||||
|
||||
var massRatioSq = Math.Pow(massRatio, 2);
|
||||
var modifier = (1 - (0.15 / massRatioSq));
|
||||
modifier = Math.Max(0.1, modifier);
|
||||
var slowdownComp = EnsureComp<CarryingSlowdownComponent>(carrier);
|
||||
_slowdown.SetModifier(carrier, (float) modifier, (float) modifier, slowdownComp);
|
||||
_slowdown.SetModifier(carrier, slowdownComp);
|
||||
}
|
||||
|
||||
public bool CanCarry(EntityUid carrier, EntityUid carried, CarriableComponent? carriedComp = null)
|
||||
@@ -310,4 +305,3 @@ namespace Content.Server.Carrying
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
using Robust.Shared.Serialization;
|
||||
using Content.Shared.DoAfter;
|
||||
|
||||
namespace Content.Shared.Carrying
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public sealed partial class CarryDoAfterEvent : SimpleDoAfterEvent
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,13 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Carrying
|
||||
{
|
||||
[RegisterComponent, NetworkedComponent, Access(typeof(CarryingSlowdownSystem))]
|
||||
namespace Content.Shared._White.Carrying;
|
||||
|
||||
[RegisterComponent, NetworkedComponent, Access(typeof(CarryingSlowdownSystem)), AutoGenerateComponentState]
|
||||
public sealed partial class CarryingSlowdownComponent : Component
|
||||
{
|
||||
[DataField("walkModifier", required: true)] [ViewVariables(VVAccess.ReadWrite)]
|
||||
public float WalkModifier = 1.0f;
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||
public float WalkModifier = 0.7f;
|
||||
|
||||
[DataField("sprintModifier", required: true)] [ViewVariables(VVAccess.ReadWrite)]
|
||||
public float SprintModifier = 1.0f;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class CarryingSlowdownComponentState : ComponentState
|
||||
{
|
||||
public float WalkModifier;
|
||||
public float SprintModifier;
|
||||
public CarryingSlowdownComponentState(float walkModifier, float sprintModifier)
|
||||
{
|
||||
WalkModifier = walkModifier;
|
||||
SprintModifier = sprintModifier;
|
||||
}
|
||||
}
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||
public float SprintModifier = 0.7f;
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared._White.Carrying;
|
||||
|
||||
namespace Content.Shared.Carrying
|
||||
{
|
||||
public sealed class CarryingSlowdownSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeed = default!;
|
||||
@@ -10,38 +11,25 @@ namespace Content.Shared.Carrying
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<CarryingSlowdownComponent, ComponentGetState>(OnGetState);
|
||||
SubscribeLocalEvent<CarryingSlowdownComponent, ComponentHandleState>(OnHandleState);
|
||||
SubscribeLocalEvent<CarryingSlowdownComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMoveSpeed);
|
||||
}
|
||||
|
||||
public void SetModifier(EntityUid uid, float walkSpeedModifier, float sprintSpeedModifier, CarryingSlowdownComponent? component = null)
|
||||
public void SetModifier(EntityUid uid, CarryingSlowdownComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
|
||||
component.WalkModifier = walkSpeedModifier;
|
||||
component.SprintModifier = sprintSpeedModifier;
|
||||
_movementSpeed.RefreshMovementSpeedModifiers(uid);
|
||||
}
|
||||
private void OnGetState(EntityUid uid, CarryingSlowdownComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new CarryingSlowdownComponentState(component.WalkModifier, component.SprintModifier);
|
||||
}
|
||||
|
||||
private void OnHandleState(EntityUid uid, CarryingSlowdownComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is CarryingSlowdownComponentState state)
|
||||
{
|
||||
component.WalkModifier = state.WalkModifier;
|
||||
component.SprintModifier = state.SprintModifier;
|
||||
|
||||
_movementSpeed.RefreshMovementSpeedModifiers(uid);
|
||||
}
|
||||
}
|
||||
private void OnRefreshMoveSpeed(EntityUid uid, CarryingSlowdownComponent component, RefreshMovementSpeedModifiersEvent args)
|
||||
private void OnRefreshMoveSpeed(
|
||||
EntityUid uid,
|
||||
CarryingSlowdownComponent component,
|
||||
RefreshMovementSpeedModifiersEvent args)
|
||||
{
|
||||
args.ModifySpeed(component.WalkModifier, component.SprintModifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed partial class CarryDoAfterEvent : SimpleDoAfterEvent;
|
||||
Reference in New Issue
Block a user