Serialization v3 content PR (#3491)
* serv3 in shared pt 1 * beginning of deepclone api * progress in implementing ideepclone & serv3 in content * adds target * its cant hurt you it cant hurt you * more changes to content.server * adds dataclasses * almost there * renamed & edited entry * finishes refactoring content to use serv3 * gasmixture runtimes, next: reagentunit * fucin hell that was an annoying one * adds flags * fixes some yaml errors * removes comment * fixes generic components for now * removes todo actually clones values my god paul fixes bug involving resolving custom data classes from other proj renames dataclass fixes spritecomp adds WithFormat.Constants support * adds deepclone to ResistanceSet * adds a bunch of deepclone implementations adds a deepclone analyzer (TODO) adds a deep clone fallback for classes & structs * fixes a bunch of runtimes * adds deepclone to entityuid * adds generator to sln * gets rid of warnings * fixes * argh * componentdata refactors * more deepclone impl * heck me i reworked all of content deepclone * renames custom dataclasstarget * misc * reworks prototypes * deepclone nuke * renamed customdataclass attribute * fixes everything * misc fixed * the killcommit * getting there * changed yamlfieldattribute namespace * adds back iselfserialize * renames everything to data(field/definition) * ouch * Fix most errors on content * Fix more errors in content * Fix some components * work on tests * fixes some customdataclasses * fuggin shit * yes * yeas * Remove data classes * Data field naming fixes * arg * Git resetti RobustToolbox * Merge fixes * General fixes * Fix startup serialization errors * Fix DamageContainerPrototype when supported classes or types are null * Implement construction graph step type serializer * Fix up construction serialization * Fix up construction serialization part 2 * Fix null list in technology database component * Fix body serialization * Fix entity storage serialization * Fix actions serialization * Fix AI serialization * Fix reaction serialization * Fix body serialization * Fix grid atmosphere serialization * Rename IServ3Manager to ISerializationManager * Convert every non generic serializer to the new format, general fixes * Serialization and body system fix * pushinheritance fix * Update all prototypes to have a parent and have consistent id/parent properties * Merge fixes * smh my head * cuddling slaps * Content commit for engine PR * stuff * more fixes * argh * yes even you are fixed * changelog fixes * fixes seeds * argh * Test fixes * Add writing for alert order prototype * Fix alert order writing * FIX * its been alot ok * Fix the rest of the visualizers * Fix server alerts component tests * Fix alert prototype tests not using the read value * Fix alert prototype tests initializing serialization multiple times * THIS IS AN AMERICAN CODEBASE GOD BLESS THE USA * Add ImplicitDataDefinitionForInheritors to IMechanismBehavior Fixes the behaviors not being found * Fix NRE in strap component Good night to the 1 buckle optimization * Fix clothing component slot flags serialization tag * Fix body component in all components test * Merge fixes * ffs * Make construction graph prototype use serialization hooks * human yaml linted * a * Do the thing for construction * stuff * a * monke see yaml linter * LINT HARDER * Remove redundant todo * yes * Add skip hook argument to readers and copiers * we gamin * test/datafield fixes * adds more verbose validation * moves linter to action * Improve construction graph step type serializer error message * Fix ammo box component NRE * gamin * some updates to the linter * yes * removes that test * misc fixes * array fix priority fix misc fixes * adds proper info the validation * adds alwaysrelevant usa * Make yaml linter take half as long to run (~50% less) * Make yaml linter 5 times faster (~80% less execution time) * based vera being based * fixes mapsaving * warning cleanup & moves surpressor * removes old msbuild targets * Revert "Make yaml linter 5 times faster (~80% less execution time)" This reverts commit 3e6091359a26252c3e98828199553de668031c63. * Add -nowarn to yaml linter run configuration * Improve yaml linter message feedback * Make dependencies an argument instead of a property on the serialization manager * yamllinting slaps * Clean up type serializers * Move yaml linter code to its own method * Fix yaml errors * Change yaml linter action name and remove -nowarn * yaml linter please shut * Git resetti robust toolbox Co-authored-by: Paul <ritter.paul1+git@googlemail.com> Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#nullable enable
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Mobs
|
||||
@@ -14,6 +16,7 @@ namespace Content.Shared.GameObjects.Components.Mobs
|
||||
public override string Name => "Examiner";
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("DoRangeCheck")]
|
||||
private bool _doRangeCheck = true;
|
||||
|
||||
/// <summary>
|
||||
@@ -21,12 +24,5 @@ namespace Content.Shared.GameObjects.Components.Mobs
|
||||
/// If false, the user can theoretically examine from infinitely far away.
|
||||
/// </summary>
|
||||
public bool DoRangeCheck => _doRangeCheck;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(ref _doRangeCheck, "DoRangeCheck", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using Content.Shared.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Mobs
|
||||
{
|
||||
@@ -50,23 +51,25 @@ namespace Content.Shared.GameObjects.Components.Mobs
|
||||
public IEntity? Holder { get; private set; }
|
||||
// cached actions component of the holder, since we'll need to access it frequently
|
||||
private SharedActionsComponent? _holderActionsComponent;
|
||||
private List<ItemActionConfig> _actionConfigs = new();
|
||||
// State of all actions provided by this item.
|
||||
private readonly Dictionary<ItemActionType, ActionState> _actions = new();
|
||||
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
[DataField("actions")]
|
||||
private List<ItemActionConfig> _actionConfigs
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(ref _actionConfigs,"actions", new List<ItemActionConfig>());
|
||||
|
||||
foreach (var actionConfig in _actionConfigs)
|
||||
get => internalActionConfigs;
|
||||
set
|
||||
{
|
||||
GrantOrUpdate(actionConfig.ActionType, actionConfig.Enabled, false, null);
|
||||
internalActionConfigs = value;
|
||||
foreach (var actionConfig in value)
|
||||
{
|
||||
GrantOrUpdate(actionConfig.ActionType, actionConfig.Enabled, false, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// State of all actions provided by this item.
|
||||
private readonly Dictionary<ItemActionType, ActionState> _actions = new();
|
||||
private List<ItemActionConfig> internalActionConfigs = new ();
|
||||
|
||||
protected override void Startup()
|
||||
{
|
||||
base.Startup();
|
||||
@@ -226,22 +229,23 @@ namespace Content.Shared.GameObjects.Components.Mobs
|
||||
/// <summary>
|
||||
/// Configuration for an item action provided by an item.
|
||||
/// </summary>
|
||||
public class ItemActionConfig : IExposeData
|
||||
[DataDefinition]
|
||||
public class ItemActionConfig : ISerializationHooks
|
||||
{
|
||||
public ItemActionType ActionType { get; private set; }
|
||||
[DataField("actionType", required: true)]
|
||||
public ItemActionType ActionType { get; private set; } = ItemActionType.Error;
|
||||
|
||||
/// <summary>
|
||||
/// Whether action is initially enabled on this item. Defaults to true.
|
||||
/// </summary>
|
||||
public bool Enabled { get; private set; }
|
||||
public bool Enabled { get; private set; } = true;
|
||||
|
||||
void IExposeData.ExposeData(ObjectSerializer serializer)
|
||||
void ISerializationHooks.AfterDeserialization()
|
||||
{
|
||||
serializer.DataField(this, x => x.ActionType, "actionType", ItemActionType.Error);
|
||||
if (ActionType == ItemActionType.Error)
|
||||
{
|
||||
Logger.ErrorS("action", "invalid or missing actionType");
|
||||
}
|
||||
serializer.DataField(this, x => x.Enabled, "enabled", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Mobs
|
||||
@@ -46,7 +47,8 @@ namespace Content.Shared.GameObjects.Components.Mobs
|
||||
/// of the status of the entity.
|
||||
/// </summary>
|
||||
public IEnumerable<ActionType> InnateActions => _innateActions ?? Enumerable.Empty<ActionType>();
|
||||
private List<ActionType>? _innateActions;
|
||||
[DataField("innateActions")]
|
||||
private List<ActionType>? _innateActions = null;
|
||||
|
||||
|
||||
// entries are removed from this if they are at the initial state (not enabled, no cooldown, toggled off).
|
||||
@@ -63,11 +65,6 @@ namespace Content.Shared.GameObjects.Components.Mobs
|
||||
private Dictionary<EntityUid, Dictionary<ItemActionType, ActionState>> _itemActions =
|
||||
new();
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(ref _innateActions,"innateActions", null);
|
||||
}
|
||||
protected override void Startup()
|
||||
{
|
||||
foreach (var actionType in InnateActions)
|
||||
|
||||
@@ -7,8 +7,10 @@ using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||
using Content.Shared.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Mobs
|
||||
@@ -31,17 +33,26 @@ namespace Content.Shared.GameObjects.Components.Mobs
|
||||
(TimeSpan.FromSeconds(Math.Max(StunnedTimer, Math.Max(KnockdownTimer, SlowdownTimer))));
|
||||
|
||||
private bool _canHelp = true;
|
||||
|
||||
[DataField("stunCap")]
|
||||
protected float _stunCap = 20f;
|
||||
|
||||
[DataField("knockdownCap")]
|
||||
protected float _knockdownCap = 20f;
|
||||
|
||||
[DataField("slowdownCap")]
|
||||
protected float _slowdownCap = 20f;
|
||||
|
||||
private float _helpKnockdownRemove = 1f;
|
||||
|
||||
[DataField("helpInterval")]
|
||||
private float _helpInterval = 1f;
|
||||
|
||||
protected float StunnedTimer;
|
||||
protected float KnockdownTimer;
|
||||
protected float SlowdownTimer;
|
||||
|
||||
private string _stunAlertId = string.Empty;
|
||||
[DataField("stunAlertId")] private string _stunAlertId = "stun";
|
||||
|
||||
protected CancellationTokenSource StatusRemoveCancellation = new();
|
||||
|
||||
@@ -203,19 +214,6 @@ namespace Content.Shared.GameObjects.Components.Mobs
|
||||
StatusRemoveCancellation = new CancellationTokenSource();
|
||||
}
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(ref _stunCap, "stunCap", 20f);
|
||||
serializer.DataField(ref _knockdownCap, "knockdownCap", 20f);
|
||||
serializer.DataField(ref _slowdownCap, "slowdownCap", 20f);
|
||||
serializer.DataField(ref _helpInterval, "helpInterval", 1f);
|
||||
serializer.DataField(ref _helpKnockdownRemove, "helpKnockdownRemove", 1f);
|
||||
serializer.DataField(ref _stunAlertId, "stunAlertId",
|
||||
"stun");
|
||||
}
|
||||
|
||||
protected virtual void OnInteractHand() { }
|
||||
|
||||
bool IInteractHand.InteractHand(InteractHandEventArgs eventArgs)
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#nullable enable
|
||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Mobs.Speech
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class SharedEmotingComponent : Component, IActionBlocker
|
||||
{
|
||||
private bool _enabled = true;
|
||||
[DataField("enabled")] private bool _enabled = true;
|
||||
public override string Name => "Emoting";
|
||||
|
||||
public bool Enabled
|
||||
@@ -23,12 +23,5 @@ namespace Content.Shared.GameObjects.Components.Mobs.Speech
|
||||
}
|
||||
|
||||
bool IActionBlocker.CanEmote() => Enabled;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(this, x => x.Enabled, "enabled", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#nullable enable
|
||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Mobs.Speech
|
||||
{
|
||||
@@ -11,9 +11,11 @@ namespace Content.Shared.GameObjects.Components.Mobs.Speech
|
||||
[RegisterComponent]
|
||||
public class SharedSpeechComponent : Component, IActionBlocker
|
||||
{
|
||||
private bool _enabled = true;
|
||||
public override string Name => "Speech";
|
||||
|
||||
[DataField("enabled")]
|
||||
private bool _enabled = true;
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get => _enabled;
|
||||
@@ -26,12 +28,5 @@ namespace Content.Shared.GameObjects.Components.Mobs.Speech
|
||||
}
|
||||
|
||||
bool IActionBlocker.CanSpeak() => Enabled;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(this, x => x.Enabled, "enabled", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#nullable enable
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Mobs.State
|
||||
{
|
||||
[ImplicitDataDefinitionForInheritors]
|
||||
public abstract class BaseMobState : IMobState
|
||||
{
|
||||
protected abstract DamageState DamageState { get; }
|
||||
@@ -34,8 +35,6 @@ namespace Content.Shared.GameObjects.Components.Mobs.State
|
||||
|
||||
public virtual void UpdateState(IEntity entity, int threshold) { }
|
||||
|
||||
public virtual void ExposeData(ObjectSerializer serializer) { }
|
||||
|
||||
public virtual bool CanInteract()
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#nullable enable
|
||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Mobs.State
|
||||
{
|
||||
@@ -10,7 +9,7 @@ namespace Content.Shared.GameObjects.Components.Mobs.State
|
||||
/// (i.e. Normal, Critical, Dead) and what effects to apply upon entering or
|
||||
/// exiting the state.
|
||||
/// </summary>
|
||||
public interface IMobState : IExposeData, IActionBlocker
|
||||
public interface IMobState : IActionBlocker
|
||||
{
|
||||
bool IsAlive();
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components.Mobs.State
|
||||
@@ -29,12 +30,12 @@ namespace Content.Shared.GameObjects.Components.Mobs.State
|
||||
/// States that this <see cref="SharedMobStateComponent"/> mapped to
|
||||
/// the amount of damage at which they are triggered.
|
||||
/// A threshold is reached when the total damage of an entity is equal
|
||||
/// A threshold is reached when the total damage of an entity is equal
|
||||
/// to or higher than the int key, but lower than the next threshold.
|
||||
/// Ordered from lowest to highest.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
private SortedDictionary<int, IMobState> _lowestToHighestStates = default!;
|
||||
[DataField("thresholds")]
|
||||
private readonly SortedDictionary<int, IMobState> _lowestToHighestStates = default!;
|
||||
|
||||
// TODO Remove Nullability?
|
||||
[ViewVariables]
|
||||
@@ -45,20 +46,6 @@ namespace Content.Shared.GameObjects.Components.Mobs.State
|
||||
|
||||
public IEnumerable<KeyValuePair<int, IMobState>> _highestToLowestStates => _lowestToHighestStates.Reverse();
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataReadWriteFunction(
|
||||
"thresholds",
|
||||
new Dictionary<int, IMobState>(),
|
||||
thresholds =>
|
||||
{
|
||||
_lowestToHighestStates = new SortedDictionary<int, IMobState>(thresholds);
|
||||
},
|
||||
() => new Dictionary<int, IMobState>(_lowestToHighestStates));
|
||||
}
|
||||
|
||||
protected override void Startup()
|
||||
{
|
||||
base.Startup();
|
||||
|
||||
Reference in New Issue
Block a user