2022-02-26 18:24:08 +13:00
|
|
|
using Content.Shared.Actions;
|
|
|
|
|
using Content.Shared.Actions.ActionTypes;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Targeting;
|
2022-07-29 14:13:12 +12:00
|
|
|
using Robust.Shared.Audio;
|
2021-07-12 01:32:10 -07:00
|
|
|
using Robust.Shared.GameStates;
|
2022-04-14 16:17:34 +12:00
|
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
2019-09-26 22:32:32 +02:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Shared.CombatMode
|
2019-09-26 22:32:32 +02:00
|
|
|
{
|
2023-04-08 13:16:48 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Stores whether an entity is in "combat mode"
|
|
|
|
|
/// This is used to differentiate between regular item interactions or
|
|
|
|
|
/// using *everything* as a weapon.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[RegisterComponent, NetworkedComponent]
|
|
|
|
|
[Access(typeof(SharedCombatModeSystem))]
|
|
|
|
|
public sealed class CombatModeComponent : Component
|
2019-09-26 22:32:32 +02:00
|
|
|
{
|
2022-09-29 15:51:59 +10:00
|
|
|
#region Disarm
|
2020-03-25 11:16:57 +01:00
|
|
|
|
2022-09-29 15:51:59 +10:00
|
|
|
/// <summary>
|
|
|
|
|
/// Whether we are able to disarm. This requires our active hand to be free.
|
|
|
|
|
/// False if it's toggled off for whatever reason, null if it's not possible.
|
|
|
|
|
/// </summary>
|
2022-10-16 23:23:44 +11:00
|
|
|
[ViewVariables(VVAccess.ReadWrite), DataField("canDisarm")]
|
2022-09-29 15:51:59 +10:00
|
|
|
public bool? CanDisarm;
|
2022-02-26 18:24:08 +13:00
|
|
|
|
|
|
|
|
[DataField("disarmSuccessSound")]
|
|
|
|
|
public readonly SoundSpecifier DisarmSuccessSound = new SoundPathSpecifier("/Audio/Effects/thudswoosh.ogg");
|
|
|
|
|
|
2022-09-29 15:51:59 +10:00
|
|
|
[DataField("disarmFailChance")]
|
|
|
|
|
public readonly float BaseDisarmFailChance = 0.75f;
|
2022-04-14 16:17:34 +12:00
|
|
|
|
2022-09-29 15:51:59 +10:00
|
|
|
#endregion
|
2022-04-30 18:29:13 -03:00
|
|
|
|
2022-09-29 15:51:59 +10:00
|
|
|
private bool _isInCombatMode;
|
|
|
|
|
private TargetingZone _activeZone;
|
2022-04-14 16:17:34 +12:00
|
|
|
|
|
|
|
|
[DataField("combatToggleActionId", customTypeSerializer: typeof(PrototypeIdSerializer<InstantActionPrototype>))]
|
|
|
|
|
public readonly string CombatToggleActionId = "CombatModeToggle";
|
2022-02-26 18:24:08 +13:00
|
|
|
|
|
|
|
|
[DataField("combatToggleAction")]
|
2022-04-14 16:17:34 +12:00
|
|
|
public InstantAction? CombatToggleAction;
|
2022-02-26 18:24:08 +13:00
|
|
|
|
2020-03-25 11:16:57 +01:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2023-04-08 13:16:48 -07:00
|
|
|
public bool IsInCombatMode
|
2020-03-25 11:16:57 +01:00
|
|
|
{
|
|
|
|
|
get => _isInCombatMode;
|
|
|
|
|
set
|
|
|
|
|
{
|
2021-03-08 04:09:59 +11:00
|
|
|
if (_isInCombatMode == value) return;
|
2020-03-25 11:16:57 +01:00
|
|
|
_isInCombatMode = value;
|
2022-04-14 16:17:34 +12:00
|
|
|
if (CombatToggleAction != null)
|
|
|
|
|
EntitySystem.Get<SharedActionsSystem>().SetToggled(CombatToggleAction, _isInCombatMode);
|
2022-10-04 12:12:13 +11:00
|
|
|
|
2020-03-25 11:16:57 +01:00
|
|
|
Dirty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2023-04-08 13:16:48 -07:00
|
|
|
public TargetingZone ActiveZone
|
2020-03-25 11:16:57 +01:00
|
|
|
{
|
|
|
|
|
get => _activeZone;
|
|
|
|
|
set
|
|
|
|
|
{
|
2021-03-08 04:09:59 +11:00
|
|
|
if (_activeZone == value) return;
|
2020-03-25 11:16:57 +01:00
|
|
|
_activeZone = value;
|
|
|
|
|
Dirty();
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-09-26 22:32:32 +02:00
|
|
|
}
|
|
|
|
|
}
|