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:
Paul Ritter
2021-03-05 01:08:38 +01:00
committed by GitHub
parent 05d4d9692c
commit 5c50b1f6ed
545 changed files with 4547 additions and 6650 deletions

View File

@@ -18,7 +18,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Timing;
using Robust.Shared.ViewVariables;
@@ -39,17 +39,35 @@ namespace Content.Server.GameObjects.Components.Items.Storage
private TimeSpan _lastInternalOpenAttempt;
[ViewVariables]
private int _storageCapacityMax;
[DataField("Capacity")]
private int _storageCapacityMax = 30;
[ViewVariables]
[DataField("IsCollidableWhenOpen")]
private bool _isCollidableWhenOpen;
[ViewVariables]
protected IEntityQuery? EntityQuery;
[DataField("showContents")]
private bool _showContents;
private bool _occludesLight;
[DataField("occludesLight")]
private bool _occludesLight = true;
[DataField("open")]
private bool _open;
private bool _canWeldShut;
[DataField("CanWeldShut")]
private bool _canWeldShut = true;
[DataField("IsWeldedShut")]
private bool _isWeldedShut;
[DataField("closeSound")]
private string _closeSound = "/Audio/Machines/closetclose.ogg";
[DataField("openSound")]
private string _openSound = "/Audio/Machines/closetopen.ogg";
[ViewVariables]
@@ -136,22 +154,6 @@ namespace Content.Server.GameObjects.Components.Items.Storage
}
}
/// <inheritdoc />
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _storageCapacityMax, "Capacity", 30);
serializer.DataField(ref _isCollidableWhenOpen, "IsCollidableWhenOpen", false);
serializer.DataField(ref _showContents, "showContents", false);
serializer.DataField(ref _occludesLight, "occludesLight", true);
serializer.DataField(ref _open, "open", false);
serializer.DataField(this, a => a.IsWeldedShut, "IsWeldedShut", false);
serializer.DataField(this, a => a.CanWeldShut, "CanWeldShut", true);
serializer.DataField(this, x => x._closeSound, "closeSound", "/Audio/Machines/closetclose.ogg");
serializer.DataField(this, x => x._openSound, "openSound", "/Audio/Machines/closetopen.ogg");
}
public virtual void Activate(ActivateEventArgs eventArgs)
{
ToggleOpen(eventArgs.User);

View File

@@ -14,7 +14,9 @@ using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Players;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.GameObjects.Components.Items.Storage
{
@@ -27,6 +29,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
public override string Name => "Item";
public override uint? NetID => ContentNetIDs.ITEM;
[DataField("HeldPrefix")]
private string _equippedPrefix;
public string EquippedPrefix
@@ -68,13 +71,6 @@ namespace Content.Server.GameObjects.Components.Items.Storage
RemovedFromSlot();
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _equippedPrefix, "HeldPrefix", null);
}
public bool CanPickup(IEntity user)
{
if (!ActionBlockerSystem.CanPickup(user))

View File

@@ -6,7 +6,7 @@ using Content.Shared.Interfaces;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Items.Storage
@@ -19,25 +19,21 @@ namespace Content.Server.GameObjects.Components.Items.Storage
{
public override string Name => "SecretStash";
[ViewVariables] private int _maxItemSize;
[ViewVariables] private string? _secretPartName;
[ViewVariables] [DataField("maxItemSize")]
private int _maxItemSize = (int) ReferenceSizes.Pocket;
[ViewVariables] [DataField("secretPartName")]
private readonly string? _secretPartNameOverride = null;
[ViewVariables] private ContainerSlot _itemContainer = default!;
public string SecretPartName => _secretPartName ?? Loc.GetString("{0:theName}", Owner);
public string SecretPartName => _secretPartNameOverride ?? Loc.GetString("{0:theName}", Owner);
public override void Initialize()
{
base.Initialize();
_itemContainer = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, "stash", out _);
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _maxItemSize, "maxItemSize", (int) ReferenceSizes.Pocket);
serializer.DataField(ref _secretPartName, "secretPartName", null);
}
/// <summary>
/// Tries to hide item inside secret stash from hands of user

View File

@@ -8,7 +8,10 @@ using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Items.Storage
@@ -20,7 +23,8 @@ namespace Content.Server.GameObjects.Components.Items.Storage
public class SecureEntityStorageComponent : EntityStorageComponent
{
public override string Name => "SecureEntityStorage";
private bool _locked;
[DataField("locked")]
private bool _locked = true;
[ViewVariables(VVAccess.ReadWrite)]
public bool Locked
@@ -37,13 +41,6 @@ namespace Content.Server.GameObjects.Components.Items.Storage
}
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _locked, "locked", true);
}
protected override void Startup()
{
base.Startup();

View File

@@ -23,7 +23,9 @@ using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Players;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Items.Storage
@@ -41,14 +43,19 @@ namespace Content.Server.GameObjects.Components.Items.Storage
private Container? _storage;
private readonly Dictionary<IEntity, int> _sizeCache = new();
private bool _occludesLight;
[DataField("occludesLight")]
private bool _occludesLight = true;
[DataField("quickInsert")]
private bool _quickInsert; //Can insert storables by "attacking" them with the storage entity
[DataField("areaInsert")]
private bool _areaInsert; //"Attacking" with the storage entity causes it to insert all nearby storables after a delay
private bool _storageInitialCalculated;
private int _storageUsed;
private int _storageCapacityMax;
[DataField("capacity")]
private int _storageCapacityMax = 10000;
public readonly HashSet<IPlayerSession> SubscribedSessions = new();
[DataField("storageSoundCollection")]
public string? StorageSoundCollection { get; set; }
[ViewVariables]
@@ -355,18 +362,6 @@ namespace Content.Server.GameObjects.Components.Items.Storage
_storage.OccludesLight = _occludesLight;
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _storageCapacityMax, "capacity", 10000);
serializer.DataField(ref _occludesLight, "occludesLight", true);
serializer.DataField(ref _quickInsert, "quickInsert", false);
serializer.DataField(ref _areaInsert, "areaInsert", false);
serializer.DataField(this, x => x.StorageSoundCollection, "storageSoundCollection", string.Empty);
//serializer.DataField(ref StorageUsed, "used", 0);
}
public override void HandleNetworkMessage(ComponentMessage message, INetChannel channel, ICommonSession? session = null)
{
base.HandleNetworkMessage(message, channel, session);

View File

@@ -8,6 +8,7 @@ using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Log;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.GameObjects.Components.Items.Storage
{
@@ -22,9 +23,12 @@ namespace Content.Server.GameObjects.Components.Items.Storage
/// countTag: Cigarette # Note: field doesn't point to entity Id, but its tag
/// </code>
[RegisterComponent]
public class StorageCounterComponent : Component
public class StorageCounterComponent : Component, ISerializationHooks
{
[DataField("countTag")]
private string? _countTag;
[DataField("amount")]
private int? _maxAmount;
/// <summary>
@@ -34,16 +38,12 @@ namespace Content.Server.GameObjects.Components.Items.Storage
public override string Name => "StorageCounter";
public override void ExposeData(ObjectSerializer serializer)
void ISerializationHooks.AfterDeserialization()
{
base.ExposeData(serializer);
serializer.DataField(ref _countTag, "countTag", null);
if (_countTag == null)
{
Logger.Warning("StorageCounterComponent without a `countTag` is useless");
}
serializer.DataField(ref _maxAmount, "amount", null);
}
public override void HandleMessage(ComponentMessage message, IComponent? component)

View File

@@ -1,27 +1,24 @@
#nullable enable
using System;
using System.Collections.Generic;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Logger = Robust.Shared.Log.Logger;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.GameObjects.Components.Items.Storage
{
[RegisterComponent]
internal sealed class StorageFillComponent : Component, IMapInit
public sealed class StorageFillComponent : Component, IMapInit
{
public override string Name => "StorageFill";
private List<PrototypeItemData> _contents;
[DataField("contents")]
private List<StorageFillEntry> _contents = new();
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _contents, "contents", new List<PrototypeItemData>());
}
public IReadOnlyList<StorageFillEntry> Contents => _contents;
void IMapInit.MapInit()
{
@@ -30,11 +27,12 @@ namespace Content.Server.GameObjects.Components.Items.Storage
return;
}
if (!Owner.TryGetComponent(out IStorageComponent storage))
if (!Owner.TryGetComponent(out IStorageComponent? storage))
{
Logger.Error($"StorageFillComponent couldn't find any StorageComponent ({Owner})");
return;
}
var random = IoCManager.Resolve<IRobustRandom>();
var alreadySpawnedGroups = new List<string>();
@@ -58,19 +56,25 @@ namespace Content.Server.GameObjects.Components.Items.Storage
}
[Serializable]
private struct PrototypeItemData : IExposeData
[DataDefinition]
public struct StorageFillEntry : IPopulateDefaultValues
{
public string PrototypeName;
[DataField("name")]
public string? PrototypeName;
[DataField("prob")]
public float SpawnProbability;
[DataField("orGroup")]
public string GroupId;
[DataField("amount")]
public int Amount;
void IExposeData.ExposeData(ObjectSerializer serializer)
public void PopulateDefaultValues()
{
serializer.DataField(ref PrototypeName, "name", null);
serializer.DataField(ref Amount, "amount", 1);
serializer.DataField(ref SpawnProbability, "prob", 1f);
serializer.DataField(ref GroupId, "orGroup", null);
Amount = 1;
SpawnProbability = 1;
}
}
}