2021-02-27 04:12:09 +01:00
|
|
|
#nullable enable
|
2019-09-26 22:32:32 +02:00
|
|
|
using System;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-02-18 09:09:07 +01:00
|
|
|
using Robust.Shared.Players;
|
2019-09-26 22:32:32 +02:00
|
|
|
using Robust.Shared.Serialization;
|
2020-03-25 11:16:57 +01:00
|
|
|
using Robust.Shared.ViewVariables;
|
2019-09-26 22:32:32 +02:00
|
|
|
|
|
|
|
|
namespace Content.Shared.GameObjects.Components.Mobs
|
|
|
|
|
{
|
|
|
|
|
public abstract class SharedCombatModeComponent : Component
|
|
|
|
|
{
|
|
|
|
|
public sealed override uint? NetID => ContentNetIDs.COMBATMODE;
|
|
|
|
|
public override string Name => "CombatMode";
|
|
|
|
|
|
2020-03-25 11:16:57 +01:00
|
|
|
private bool _isInCombatMode;
|
|
|
|
|
private TargetingZone _activeZone;
|
|
|
|
|
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
|
|
|
public virtual bool IsInCombatMode
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
Dirty();
|
2021-03-08 04:09:59 +11:00
|
|
|
|
|
|
|
|
// Regenerate physics contacts -> Can probably just selectively check
|
|
|
|
|
/* Still a bit jank so left disabled for now.
|
|
|
|
|
if (Owner.TryGetComponent(out PhysicsComponent? physicsComponent))
|
|
|
|
|
{
|
|
|
|
|
if (value)
|
|
|
|
|
{
|
|
|
|
|
physicsComponent.WakeBody();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
physicsComponent.RegenerateContacts();
|
|
|
|
|
}
|
|
|
|
|
*/
|
2020-03-25 11:16:57 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
|
|
|
public virtual TargetingZone ActiveZone
|
|
|
|
|
{
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-27 04:12:09 +01:00
|
|
|
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
2020-03-25 11:16:57 +01:00
|
|
|
{
|
|
|
|
|
base.HandleComponentState(curState, nextState);
|
|
|
|
|
|
2020-11-26 14:33:31 +01:00
|
|
|
if (curState is not CombatModeComponentState state)
|
2020-03-25 11:16:57 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
IsInCombatMode = state.IsInCombatMode;
|
|
|
|
|
ActiveZone = state.TargetingZone;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-02-18 09:09:07 +01:00
|
|
|
public override ComponentState GetComponentState(ICommonSession player)
|
2020-03-25 11:16:57 +01:00
|
|
|
{
|
|
|
|
|
return new CombatModeComponentState(IsInCombatMode, ActiveZone);
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-26 22:32:32 +02:00
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
protected sealed class CombatModeComponentState : ComponentState
|
|
|
|
|
{
|
|
|
|
|
public bool IsInCombatMode { get; }
|
|
|
|
|
public TargetingZone TargetingZone { get; }
|
|
|
|
|
|
|
|
|
|
public CombatModeComponentState(bool isInCombatMode, TargetingZone targetingZone)
|
2020-06-08 16:49:05 -04:00
|
|
|
: base(ContentNetIDs.COMBATMODE)
|
2019-09-26 22:32:32 +02:00
|
|
|
{
|
|
|
|
|
IsInCombatMode = isInCombatMode;
|
|
|
|
|
TargetingZone = targetingZone;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|