Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Jabak
2024-06-15 19:29:46 +03:00
51 changed files with 640 additions and 77 deletions

View File

@@ -545,7 +545,7 @@ namespace Content.Shared.Cuffs
BreakOnWeightlessMove = false,
BreakOnDamage = true,
NeedHand = true,
DistanceThreshold = 0.3f
DistanceThreshold = 1f // shorter than default but still feels good
};
if (!_doAfter.TryStartDoAfter(doAfterEventArgs))
@@ -650,7 +650,7 @@ namespace Content.Shared.Cuffs
BreakOnDamage = true,
NeedHand = true,
RequireCanInteract = false, // Trust in UncuffAttemptEvent
DistanceThreshold = 0.3f
DistanceThreshold = 1f // shorter than default but still feels good
};
if (!_doAfter.TryStartDoAfter(doAfterEventArgs))

View File

@@ -5,8 +5,8 @@ using Content.Shared.Charges.Systems;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction;
using Content.Shared.Ninja.Components;
using Content.Shared.Physics;
using Content.Shared.Popups;
using Content.Shared.Examine;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Timing;
@@ -21,7 +21,7 @@ public sealed class DashAbilitySystem : EntitySystem
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedChargesSystem _charges = default!;
[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly SharedInteractionSystem _interaction = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
@@ -81,11 +81,10 @@ public sealed class DashAbilitySystem : EntitySystem
_popup.PopupClient(Loc.GetString("dash-ability-no-charges", ("item", uid)), user, user);
return;
}
var origin = Transform(user).MapPosition;
var origin = _transform.GetMapCoordinates(user);
var target = args.Target.ToMap(EntityManager, _transform);
// prevent collision with the user duh
if (!_interaction.InRangeUnobstructed(origin, target, 0f, CollisionGroup.Opaque, uid => uid == user))
if (!_examine.InRangeUnOccluded(origin, target, SharedInteractionSystem.MaxRaycastRange, null))
{
// can only dash if the destination is visible on screen
_popup.PopupClient(Loc.GetString("dash-ability-cant-see", ("item", uid)), user, user);

View File

@@ -59,7 +59,7 @@ public sealed class StepTriggerSystem : EntitySystem
if (component.Blacklist != null && TryComp<MapGridComponent>(transform.GridUid, out var grid))
{
var positon = _map.LocalToTile(uid, grid, transform.Coordinates);
var positon = _map.LocalToTile(transform.GridUid.Value, grid, transform.Coordinates);
var anch = _map.GetAnchoredEntitiesEnumerator(uid, grid, positon);
while (anch.MoveNext(out var ent))

View File

@@ -47,6 +47,16 @@ public sealed partial class MeleeThrowOnHitComponent : Component
[DataField, ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public bool Enabled = true;
// WD START
[DataField, ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public float StunTime;
[DataField, ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public bool ThrowOnThrowHit;
// WD END
}
/// <summary>

View File

@@ -1,5 +1,7 @@
using System.Numerics;
using Content.Shared.Construction.Components;
using Content.Shared.Stunnable;
using Content.Shared.Throwing;
using Content.Shared.Weapons.Melee.Components;
using Content.Shared.Weapons.Melee.Events;
using Robust.Shared.Physics;
@@ -18,22 +20,67 @@ public sealed class MeleeThrowOnHitSystem : EntitySystem
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedStunSystem _stun = default!; // WD
[Dependency] private readonly ThrownItemSystem _thrownItem = default!; // WD
/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<MeleeThrowOnHitComponent, ThrowDoHitEvent>(OnDoHit); // WD
SubscribeLocalEvent<MeleeThrowOnHitComponent, MeleeHitEvent>(OnMeleeHit);
SubscribeLocalEvent<MeleeThrownComponent, ComponentStartup>(OnThrownStartup);
SubscribeLocalEvent<MeleeThrownComponent, ComponentShutdown>(OnThrownShutdown);
SubscribeLocalEvent<MeleeThrownComponent, StartCollideEvent>(OnStartCollide);
}
private void OnDoHit(Entity<MeleeThrowOnHitComponent> ent, ref ThrowDoHitEvent args) // WD
{
if (!ent.Comp.ThrowOnThrowHit)
return;
if (!CanThrowOnHit(ent, args.Target))
return;
if (!TryComp(ent, out PhysicsComponent? physics))
return;
var velocity = physics.LinearVelocity.Normalized() * ent.Comp.Speed;
RemComp<MeleeThrownComponent>(args.Target);
var thrownComp = new MeleeThrownComponent
{
Velocity = velocity,
Lifetime = ent.Comp.Lifetime,
MinLifetime = ent.Comp.MinLifetime
};
AddComp(args.Target, thrownComp);
if (ent.Comp.StunTime != 0f)
_stun.TryParalyze(args.Target, TimeSpan.FromSeconds(ent.Comp.StunTime), true);
_thrownItem.LandComponent(ent, args.Component, physics, false);
_physics.SetLinearVelocity(ent, Vector2.Zero);
}
private void OnMeleeHit(Entity<MeleeThrowOnHitComponent> ent, ref MeleeHitEvent args)
{
var (_, comp) = ent;
if (!args.IsHit)
return;
// WD START
var stunTime = comp.StunTime;
var speed = comp.Speed;
var lifetime = comp.Lifetime;
if (args.Direction != null) // Heavy attack
{
stunTime = 0f;
speed *= 0.5f;
lifetime *= 0.5f;
}
// WD END
var mapPos = _transform.GetMapCoordinates(args.User).Position;
foreach (var hit in args.HitEntities)
{
@@ -55,11 +102,13 @@ public sealed class MeleeThrowOnHitSystem : EntitySystem
RaiseLocalEvent(hit, ref ev);
var thrownComp = new MeleeThrownComponent
{
Velocity = angle.Normalized() * comp.Speed,
Lifetime = comp.Lifetime,
Velocity = angle.Normalized() * speed, // WD EDIT
Lifetime = lifetime, // WD EDIT
MinLifetime = comp.MinLifetime
};
AddComp(hit, thrownComp);
if (stunTime != 0f)
_stun.TryParalyze(hit, TimeSpan.FromSeconds(stunTime), true);
}
}