Fix SetMobStateThreshold and MobThresholdsComponent networking (#16840)

This commit is contained in:
Nemanja
2023-05-26 23:50:33 -04:00
committed by GitHub
parent 30a7045a2d
commit 273e101477
2 changed files with 61 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
using Content.Shared.FixedPoint;
using Content.Shared.Mobs.Systems;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.Mobs.Components;
@@ -8,18 +9,38 @@ namespace Content.Shared.Mobs.Components;
[Access(typeof(MobThresholdSystem))]
public sealed class MobThresholdsComponent : Component
{
[DataField("thresholds", required:true), AutoNetworkedField(true)]
[DataField("thresholds", required:true)]
public SortedDictionary<FixedPoint2, MobState> Thresholds = new();
[DataField("triggersAlerts"), AutoNetworkedField]
[DataField("triggersAlerts")]
public bool TriggersAlerts = true;
[DataField("currentThresholdState"), AutoNetworkedField]
[DataField("currentThresholdState")]
public MobState CurrentThresholdState;
/// <summary>
/// Whether or not this entity can be revived out of a dead state.
/// </summary>
[DataField("allowRevives"), AutoNetworkedField]
[DataField("allowRevives")]
public bool AllowRevives;
}
[Serializable, NetSerializable]
public sealed class MobThresholdsComponentState : ComponentState
{
public Dictionary<FixedPoint2, MobState> UnsortedThresholds;
public bool TriggersAlerts;
public MobState CurrentThresholdState;
public bool AllowRevives;
public MobThresholdsComponentState(Dictionary<FixedPoint2, MobState> unsortedThresholds, bool triggersAlerts, MobState currentThresholdState, bool allowRevives)
{
UnsortedThresholds = unsortedThresholds;
TriggersAlerts = triggersAlerts;
CurrentThresholdState = currentThresholdState;
AllowRevives = allowRevives;
}
}