Gun tweaks (#8320)
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
|
using Content.Client.CombatMode;
|
||||||
using Content.Client.Outline;
|
using Content.Client.Outline;
|
||||||
using Content.Client.Viewport;
|
using Content.Client.Viewport;
|
||||||
using Content.Shared.ActionBlocker;
|
using Content.Shared.ActionBlocker;
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
|
using Content.Shared.CombatMode;
|
||||||
using Content.Shared.DragDrop;
|
using Content.Shared.DragDrop;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Interaction.Events;
|
using Content.Shared.Interaction.Events;
|
||||||
@@ -35,6 +37,7 @@ namespace Content.Client.DragDrop
|
|||||||
[Dependency] private readonly IConfigurationManager _cfgMan = default!;
|
[Dependency] private readonly IConfigurationManager _cfgMan = default!;
|
||||||
[Dependency] private readonly InteractionOutlineSystem _outline = default!;
|
[Dependency] private readonly InteractionOutlineSystem _outline = default!;
|
||||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||||
|
[Dependency] private readonly CombatModeSystem _combatMode = default!;
|
||||||
[Dependency] private readonly InputSystem _inputSystem = default!;
|
[Dependency] private readonly InputSystem _inputSystem = default!;
|
||||||
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
||||||
|
|
||||||
@@ -124,7 +127,8 @@ namespace Content.Client.DragDrop
|
|||||||
|
|
||||||
private bool OnUseMouseDown(in PointerInputCmdHandler.PointerInputCmdArgs args)
|
private bool OnUseMouseDown(in PointerInputCmdHandler.PointerInputCmdArgs args)
|
||||||
{
|
{
|
||||||
if (args.Session?.AttachedEntity is not {Valid: true} dragger)
|
if (args.Session?.AttachedEntity is not {Valid: true} dragger ||
|
||||||
|
_combatMode.IsInCombatMode())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -218,7 +222,8 @@ namespace Content.Client.DragDrop
|
|||||||
|
|
||||||
private bool OnContinueDrag(float frameTime)
|
private bool OnContinueDrag(float frameTime)
|
||||||
{
|
{
|
||||||
if (_dragDropHelper.Dragged == default || Deleted(_dragDropHelper.Dragged))
|
if (_dragDropHelper.Dragged == default || Deleted(_dragDropHelper.Dragged) ||
|
||||||
|
_combatMode.IsInCombatMode())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -231,8 +236,6 @@ namespace Content.Client.DragDrop
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep dragged entity under mouse
|
|
||||||
var mousePos = _eyeManager.ScreenToMap(_dragDropHelper.MouseScreenPosition);
|
|
||||||
// TODO: would use MapPosition instead if it had a setter, but it has no setter.
|
// TODO: would use MapPosition instead if it had a setter, but it has no setter.
|
||||||
// is that intentional, or should we add a setter for Transform.MapPosition?
|
// is that intentional, or should we add a setter for Transform.MapPosition?
|
||||||
if (_dragShadow == default)
|
if (_dragShadow == default)
|
||||||
|
|||||||
@@ -3,14 +3,17 @@ using Content.Server.CombatMode;
|
|||||||
using Content.Server.Hands.Components;
|
using Content.Server.Hands.Components;
|
||||||
using Content.Server.Pulling;
|
using Content.Server.Pulling;
|
||||||
using Content.Server.Storage.Components;
|
using Content.Server.Storage.Components;
|
||||||
|
using Content.Server.Weapon.Ranged.Barrels.Components;
|
||||||
using Content.Shared.ActionBlocker;
|
using Content.Shared.ActionBlocker;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Content.Shared.DragDrop;
|
using Content.Shared.DragDrop;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
|
using Content.Shared.Interaction.Events;
|
||||||
using Content.Shared.Item;
|
using Content.Shared.Item;
|
||||||
using Content.Shared.Pulling.Components;
|
using Content.Shared.Pulling.Components;
|
||||||
using Content.Shared.Weapons.Melee;
|
using Content.Shared.Weapons.Melee;
|
||||||
|
using Content.Shared.Weapons.Ranged.Components;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
@@ -202,8 +205,13 @@ namespace Content.Server.Interaction
|
|||||||
{
|
{
|
||||||
var item = hands.ActiveHandEntity;
|
var item = hands.ActiveHandEntity;
|
||||||
|
|
||||||
if (item != null && !Deleted(item.Value))
|
if (!Deleted(item))
|
||||||
{
|
{
|
||||||
|
var meleeVee = new MeleeAttackAttemptEvent();
|
||||||
|
RaiseLocalEvent(item.Value, ref meleeVee);
|
||||||
|
|
||||||
|
if (meleeVee.Cancelled) return;
|
||||||
|
|
||||||
if (wideAttack)
|
if (wideAttack)
|
||||||
{
|
{
|
||||||
var ev = new WideAttackEvent(item.Value, user, coordinates);
|
var ev = new WideAttackEvent(item.Value, user, coordinates);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using Content.Server.Weapon.Ranged.Ammunition.Components;
|
|||||||
using Content.Server.Weapon.Ranged.Barrels.Components;
|
using Content.Server.Weapon.Ranged.Barrels.Components;
|
||||||
using Content.Shared.Camera;
|
using Content.Shared.Camera;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
|
using Content.Shared.Interaction.Events;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
@@ -18,6 +19,11 @@ namespace Content.Server.Weapon.Ranged;
|
|||||||
|
|
||||||
public sealed partial class GunSystem
|
public sealed partial class GunSystem
|
||||||
{
|
{
|
||||||
|
private void OnMeleeAttempt(EntityUid uid, ServerRangedWeaponComponent component, ref MeleeAttackAttemptEvent args)
|
||||||
|
{
|
||||||
|
args.Cancelled = true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tries to fire a round of ammo out of the weapon.
|
/// Tries to fire a round of ammo out of the weapon.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -138,6 +144,7 @@ public sealed partial class GunSystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region Firing
|
#region Firing
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles firing one or many projectiles
|
/// Handles firing one or many projectiles
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -242,5 +249,6 @@ public sealed partial class GunSystem
|
|||||||
hitscan.FireEffects(shooter, hitscan.MaxLength, angle);
|
hitscan.FireEffects(shooter, hitscan.MaxLength, angle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ public sealed partial class GunSystem : EntitySystem
|
|||||||
|
|
||||||
// SubscribeLocalEvent<ServerRangedWeaponComponent, ExaminedEvent>(OnGunExamine);
|
// SubscribeLocalEvent<ServerRangedWeaponComponent, ExaminedEvent>(OnGunExamine);
|
||||||
SubscribeNetworkEvent<FirePosEvent>(OnFirePos);
|
SubscribeNetworkEvent<FirePosEvent>(OnFirePos);
|
||||||
|
SubscribeLocalEvent<ServerRangedWeaponComponent, MeleeAttackAttemptEvent>(OnMeleeAttempt);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFirePos(FirePosEvent msg, EntitySessionEventArgs args)
|
private void OnFirePos(FirePosEvent msg, EntitySessionEventArgs args)
|
||||||
|
|||||||
@@ -65,10 +65,8 @@ namespace Content.Shared.CombatMode
|
|||||||
{
|
{
|
||||||
var entity = eventArgs.SenderSession.AttachedEntity;
|
var entity = eventArgs.SenderSession.AttachedEntity;
|
||||||
|
|
||||||
if (entity == default || !EntityManager.TryGetComponent(entity, out SharedCombatModeComponent? combatModeComponent))
|
if (entity == null || !EntityManager.TryGetComponent(entity, out SharedCombatModeComponent? combatModeComponent))
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
combatModeComponent.IsInCombatMode = ev.Active;
|
combatModeComponent.IsInCombatMode = ev.Active;
|
||||||
}
|
}
|
||||||
|
|||||||
16
Content.Shared/Interaction/Events/MeleeAttackAttemptEvent.cs
Normal file
16
Content.Shared/Interaction/Events/MeleeAttackAttemptEvent.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
namespace Content.Shared.Interaction.Events;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raised on directed a weapon when being used in a melee attack.
|
||||||
|
/// </summary>
|
||||||
|
[ByRefEvent]
|
||||||
|
public struct MeleeAttackAttemptEvent
|
||||||
|
{
|
||||||
|
public bool Cancelled = false;
|
||||||
|
public readonly EntityUid User;
|
||||||
|
|
||||||
|
public MeleeAttackAttemptEvent(EntityUid user)
|
||||||
|
{
|
||||||
|
User = user;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user