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

@@ -15,13 +15,14 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.AI.Utility.AiLogic
{
// TODO: Need to split out the IMover stuff for NPC to a generic one that can be used for hoomans as well.
[RegisterComponent]
[ComponentReference(typeof(AiControllerComponent)), ComponentReference(typeof(IMoverComponent))]
internal sealed class UtilityAi : AiControllerComponent
public sealed class UtilityAi : AiControllerComponent, ISerializationHooks
{
public override string Name => "UtilityAI";
@@ -34,6 +35,7 @@ namespace Content.Server.AI.Utility.AiLogic
/// <summary>
/// The sum of all BehaviorSets gives us what actions the AI can take
/// </summary>
[field: DataField("behaviorSets")]
public HashSet<string> BehaviorSets { get; } = new();
public List<IAiUtility> AvailableActions { get; set; } = new();
@@ -62,26 +64,35 @@ namespace Content.Server.AI.Utility.AiLogic
/// </summary>
private bool _isDead;
public override void ExposeData(ObjectSerializer serializer)
/*public void AfterDeserialization()
{
base.ExposeData(serializer);
var bSets = serializer.ReadDataField("behaviorSets", new List<string>());
if (bSets.Count > 0)
if (BehaviorSets.Count > 0)
{
var behaviorManager = IoCManager.Resolve<INpcBehaviorManager>();
foreach (var bSet in bSets)
foreach (var bSet in BehaviorSets)
{
behaviorManager.AddBehaviorSet(this, bSet, false);
}
behaviorManager.RebuildActions(this);
}
}
}*/
public override void Initialize()
{
if (BehaviorSets.Count > 0)
{
var behaviorManager = IoCManager.Resolve<INpcBehaviorManager>();
foreach (var bSet in BehaviorSets)
{
behaviorManager.AddBehaviorSet(this, bSet, false);
}
behaviorManager.RebuildActions(this);
}
base.Initialize();
_planCooldownRemaining = PlanCooldown;
_blackboard = new Blackboard(Owner);

View File

@@ -1,8 +1,8 @@
#nullable enable
using System.Collections.Generic;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using YamlDotNet.RepresentationModel;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.AI.Utility
{
@@ -12,19 +12,18 @@ namespace Content.Server.AI.Utility
/// <summary>
/// Name of the BehaviorSet.
/// </summary>
public string ID { get; private set; } = default!;
[ViewVariables]
[field: DataField("id", required: true)]
public string ID { get; } = default!;
[ViewVariables]
[field: DataField("parent")]
public string? Parent { get; }
/// <summary>
/// Actions that this BehaviorSet grants to the entity.
/// </summary>
public IReadOnlyList<string> Actions { get; private set; } = default!;
public void LoadFrom(YamlMappingNode mapping)
{
var serializer = YamlObjectSerializer.NewReader(mapping);
serializer.DataField(this, x => x.ID, "id", string.Empty);
serializer.DataField(this, x => x.Actions, "actions", new List<string>());
}
[DataField("actions")]
public IReadOnlyList<string> Actions { get; private set; } = new List<string>();
}
}

View File

@@ -2,7 +2,7 @@
using Content.Shared.Actions;
using Content.Shared.Utility;
using JetBrains.Annotations;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Actions
{
@@ -10,16 +10,11 @@ namespace Content.Server.Actions
/// Just shows a popup message.asd
/// </summary>
[UsedImplicitly]
[DataDefinition]
public class DebugInstant : IInstantAction, IInstantItemAction
{
public string Message { get; private set; }
public float Cooldown { get; private set; }
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.Message, "message", "Instant action used.");
serializer.DataField(this, x => x.Cooldown, "cooldown", 0);
}
[DataField("message")] public string Message { get; [UsedImplicitly] private set; } = "Instant action used.";
[DataField("cooldown")] public float Cooldown { get; [UsedImplicitly] private set; }
public void DoInstantAction(InstantItemActionEventArgs args)
{

View File

@@ -1,17 +1,14 @@
using Content.Server.Utility;
using Content.Shared.Actions;
using JetBrains.Annotations;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Actions
{
[UsedImplicitly]
[DataDefinition]
public class DebugTargetEntity : ITargetEntityAction, ITargetEntityItemAction
{
void IExposeData.ExposeData(ObjectSerializer serializer)
{
}
public void DoTargetEntityAction(TargetEntityItemActionEventArgs args)
{
args.Performer.PopupMessageEveryone(args.Item.Name + ": Clicked " +

View File

@@ -1,17 +1,14 @@
using Content.Server.Utility;
using Content.Shared.Actions;
using JetBrains.Annotations;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Actions
{
[UsedImplicitly]
[DataDefinition]
public class DebugTargetPoint : ITargetPointAction, ITargetPointItemAction
{
void IExposeData.ExposeData(ObjectSerializer serializer)
{
}
public void DoTargetPointAction(TargetPointItemActionEventArgs args)
{
args.Performer.PopupMessageEveryone(args.Item.Name + ": Clicked local position " +

View File

@@ -1,21 +1,16 @@
using Content.Server.Utility;
using Content.Shared.Actions;
using JetBrains.Annotations;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Actions
{
[UsedImplicitly]
[DataDefinition]
public class DebugToggle : IToggleAction, IToggleItemAction
{
public string MessageOn { get; private set; }
public string MessageOff { get; private set; }
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.MessageOn, "messageOn", "on!");
serializer.DataField(this, x => x.MessageOff, "messageOff", "off!");
}
[DataField("messageOn")] public string MessageOn { get; private set; } = "on!";
[DataField("messageOff")] public string MessageOff { get; private set; } = "off!";
public bool DoToggleAction(ToggleItemActionEventArgs args)
{

View File

@@ -18,23 +18,17 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Actions
{
[UsedImplicitly]
[DataDefinition]
public class DisarmAction : ITargetEntityAction
{
private float _failProb;
private float _pushProb;
private float _cooldown;
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(ref _failProb, "failProb", 0.4f);
serializer.DataField(ref _pushProb, "pushProb", 0.4f);
serializer.DataField(ref _cooldown, "cooldown", 1.5f);
}
[DataField("failProb")] private float _failProb = 0.4f;
[DataField("pushProb")] private float _pushProb = 0.4f;
[DataField("cooldown")] private float _cooldown = 1.5f;
public void DoTargetEntityAction(TargetEntityActionEventArgs args)
{

View File

@@ -6,6 +6,7 @@ using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.Utility;
using JetBrains.Annotations;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Actions
{
@@ -13,18 +14,12 @@ namespace Content.Server.Actions
/// Blink lights and scare livings
/// </summary>
[UsedImplicitly]
[DataDefinition]
public class GhostBoo : IInstantAction
{
private float _radius;
private float _cooldown;
private int _maxTargets;
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(ref _radius, "radius", 3);
serializer.DataField(ref _cooldown, "cooldown", 120);
serializer.DataField(ref _maxTargets, "maxTargets", 3);
}
[DataField("radius")] private float _radius = 3;
[DataField("cooldown")] private float _cooldown = 120;
[DataField("maxTargets")] private int _maxTargets = 3;
public void DoInstantAction(InstantActionEventArgs args)
{

View File

@@ -1,4 +1,5 @@
using System;
#nullable enable
using System;
using System.Collections.Generic;
using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.Actions;
@@ -13,35 +14,29 @@ using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Actions
{
[UsedImplicitly]
[DataDefinition]
public class ScreamAction : IInstantAction
{
private const float Variation = 0.125f;
private const float Volume = 4f;
private List<string> _male;
private List<string> _female;
private string _wilhelm;
/// seconds
private float _cooldown;
[Dependency] private readonly IRobustRandom _random = default!;
private IRobustRandom _random;
[DataField("male")] private List<string>? _male;
[DataField("female")] private List<string>? _female;
[DataField("wilhelm")] private string? _wilhelm;
/// seconds
[DataField("cooldown")] private float _cooldown = 10;
public ScreamAction()
{
_random = IoCManager.Resolve<IRobustRandom>();
}
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(ref _male, "male", null);
serializer.DataField(ref _female, "female", null);
serializer.DataField(ref _wilhelm, "wilhelm", null);
serializer.DataField(ref _cooldown, "cooldown", 10);
IoCManager.InjectDependencies(this);
}
public void DoInstantAction(InstantActionEventArgs args)

View File

@@ -2,7 +2,7 @@
using Content.Server.GameObjects.Components.ActionBlocking;
using Content.Shared.Alert;
using JetBrains.Annotations;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Alert.Click
{
@@ -10,10 +10,9 @@ namespace Content.Server.Alert.Click
/// Try to remove handcuffs from yourself
/// </summary>
[UsedImplicitly]
[DataDefinition]
public class RemoveCuffs : IAlertClick
{
void IExposeData.ExposeData(ObjectSerializer serializer) {}
public void AlertClicked(ClickAlertEventArgs args)
{
if (args.Player.TryGetComponent(out CuffableComponent? cuffableComponent))

View File

@@ -1,7 +1,7 @@
using Content.Server.GameObjects.Components.Atmos;
using Content.Shared.Alert;
using JetBrains.Annotations;
using Robust.Shared.Serialization;
using Content.Server.GameObjects.Components.Atmos;
using Content.Shared.Alert;
using JetBrains.Annotations;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Alert.Click
{
@@ -9,10 +9,9 @@ namespace Content.Server.Alert.Click
/// Resist fire
/// </summary>
[UsedImplicitly]
[DataDefinition]
public class ResistFire : IAlertClick
{
void IExposeData.ExposeData(ObjectSerializer serializer) { }
public void AlertClicked(ClickAlertEventArgs args)
{
if (args.Player.TryGetComponent(out FlammableComponent flammable))

View File

@@ -1,7 +1,7 @@
using Content.Server.GameObjects.Components.Movement;
using Content.Shared.Alert;
using JetBrains.Annotations;
using Robust.Shared.Serialization;
using Content.Shared.Alert;
using JetBrains.Annotations;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Alert.Click
{
@@ -9,10 +9,9 @@ namespace Content.Server.Alert.Click
/// Stop piloting shuttle
/// </summary>
[UsedImplicitly]
[DataDefinition]
public class StopPiloting : IAlertClick
{
void IExposeData.ExposeData(ObjectSerializer serializer) { }
public void AlertClicked(ClickAlertEventArgs args)
{
if (args.Player.TryGetComponent(out ShuttleControllerComponent controller))

View File

@@ -1,9 +1,9 @@
using Content.Shared.Alert;
using Content.Shared.GameObjects.Components.Pulling;
using Content.Shared.GameObjects.EntitySystems;
using JetBrains.Annotations;
using Content.Shared.GameObjects.Components.Pulling;
using Content.Shared.GameObjects.EntitySystems;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Alert.Click
{
@@ -11,10 +11,9 @@ namespace Content.Server.Alert.Click
/// Stop pulling something
/// </summary>
[UsedImplicitly]
[DataDefinition]
public class StopPulling : IAlertClick
{
void IExposeData.ExposeData(ObjectSerializer serializer) { }
public void AlertClicked(ClickAlertEventArgs args)
{
EntitySystem

View File

@@ -1,7 +1,7 @@
using Content.Server.GameObjects.Components.Buckle;
using Content.Shared.Alert;
using Robust.Shared.Serialization;
using JetBrains.Annotations;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Alert.Click
{
@@ -9,10 +9,9 @@ namespace Content.Server.Alert.Click
/// Unbuckles if player is currently buckled.
/// </summary>
[UsedImplicitly]
[DataDefinition]
public class Unbuckle : IAlertClick
{
void IExposeData.ExposeData(ObjectSerializer serializer) { }
public void AlertClicked(ClickAlertEventArgs args)
{
if (args.Player.TryGetComponent(out BuckleComponent buckle))

View File

@@ -10,6 +10,7 @@ using Content.Shared.Atmos;
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.Atmos
@@ -18,28 +19,28 @@ namespace Content.Server.Atmos
/// A general-purpose, variable volume gas mixture.
/// </summary>
[Serializable]
public class GasMixture : IExposeData, IEquatable<GasMixture>, ICloneable
[DataDefinition]
public class GasMixture : IEquatable<GasMixture>, ICloneable, ISerializationHooks
{
private readonly AtmosphereSystem _atmosphereSystem;
private AtmosphereSystem? _atmosphereSystem;
public static GasMixture SpaceGas => new() {Volume = 2500f, Immutable = true, Temperature = Atmospherics.TCMB};
// This must always have a length that is a multiple of 4 for SIMD acceleration.
[ViewVariables]
private float[] _moles;
[DataField("moles")] [ViewVariables] private float[] _moles = new float[Atmospherics.AdjustedNumberOfGases];
[ViewVariables]
private float[] _molesArchived;
[DataField("molesArchived")] [ViewVariables]
private float[] _molesArchived = new float[Atmospherics.AdjustedNumberOfGases];
[ViewVariables]
[DataField("temperature")] [ViewVariables]
private float _temperature = Atmospherics.TCMB;
public IReadOnlyList<float> Gases => _moles;
[ViewVariables]
[DataField("immutable")] [ViewVariables]
public bool Immutable { get; private set; }
[ViewVariables]
[DataField("lastShare")] [ViewVariables]
public float LastShare { get; private set; }
[ViewVariables]
@@ -55,6 +56,7 @@ namespace Content.Server.Atmos
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
_atmosphereSystem ??= EntitySystem.Get<AtmosphereSystem>();
Span<float> tmp = stackalloc float[_moles.Length];
NumericsHelpers.Multiply(_moles, _atmosphereSystem.GasSpecificHeats, tmp);
@@ -68,6 +70,7 @@ namespace Content.Server.Atmos
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
_atmosphereSystem ??= EntitySystem.Get<AtmosphereSystem>();
Span<float> tmp = stackalloc float[_moles.Length];
NumericsHelpers.Multiply(_molesArchived, _atmosphereSystem.GasSpecificHeats, tmp);
@@ -106,10 +109,10 @@ namespace Content.Server.Atmos
[ViewVariables]
public float ThermalEnergy => Temperature * HeatCapacity;
[ViewVariables]
[DataField("temperatureArchived")] [ViewVariables]
public float TemperatureArchived { get; private set; }
[ViewVariables]
[DataField("volume")] [ViewVariables]
public float Volume { get; set; }
public GasMixture() : this(null)
@@ -118,9 +121,7 @@ namespace Content.Server.Atmos
public GasMixture(AtmosphereSystem? atmosphereSystem)
{
_atmosphereSystem = atmosphereSystem ?? EntitySystem.Get<AtmosphereSystem>();
_moles = new float[Atmospherics.AdjustedNumberOfGases];
_molesArchived = new float[Atmospherics.AdjustedNumberOfGases];
_atmosphereSystem = atmosphereSystem;
}
public GasMixture(float volume, AtmosphereSystem? atmosphereSystem = null): this(atmosphereSystem)
@@ -262,6 +263,7 @@ namespace Content.Server.Atmos
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public float Share(GasMixture sharer, int atmosAdjacentTurfs)
{
_atmosphereSystem ??= EntitySystem.Get<AtmosphereSystem>();
var temperatureDelta = TemperatureArchived - sharer.TemperatureArchived;
var absTemperatureDelta = Math.Abs(temperatureDelta);
var oldHeatCapacity = 0f;
@@ -485,6 +487,7 @@ namespace Content.Server.Atmos
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ReactionResult React(IGasMixtureHolder holder)
{
_atmosphereSystem ??= EntitySystem.Get<AtmosphereSystem>();
var reaction = ReactionResult.NoReaction;
var temperature = Temperature;
var energy = ThermalEnergy;
@@ -533,16 +536,8 @@ namespace Content.Server.Atmos
NumericsHelpers.Multiply(_moles, multiplier);
}
void IExposeData.ExposeData(ObjectSerializer serializer)
void ISerializationHooks.AfterDeserialization()
{
serializer.DataField(this, x => x.Immutable, "immutable", false);
serializer.DataField(this, x => x.Volume, "volume", 0f);
serializer.DataField(this, x => x.LastShare, "lastShare", 0f);
serializer.DataField(this, x => x.TemperatureArchived, "temperatureArchived", 0f);
serializer.DataField(ref _moles, "moles", new float[Atmospherics.AdjustedNumberOfGases]);
serializer.DataField(ref _molesArchived, "molesArchived", new float[Atmospherics.AdjustedNumberOfGases]);
serializer.DataField(ref _temperature, "temperature", Atmospherics.TCMB);
// The arrays MUST have a specific length.
Array.Resize(ref _moles, Atmospherics.AdjustedNumberOfGases);
Array.Resize(ref _molesArchived, Atmospherics.AdjustedNumberOfGases);

View File

@@ -1,11 +1,12 @@
#nullable enable
using System;
using System.Collections.Generic;
using Content.Server.Interfaces;
using Content.Shared.Atmos;
using Robust.Server.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using YamlDotNet.RepresentationModel;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.Atmos.Reactions
{
@@ -25,45 +26,43 @@ namespace Content.Server.Atmos.Reactions
[Prototype("gasReaction")]
public class GasReactionPrototype : IPrototype
{
public string ID { get; private set; }
[ViewVariables]
[field: DataField("id", required: true)]
public string ID { get; } = default!;
[ViewVariables]
[field: DataField("parent")]
public string? Parent { get; }
/// <summary>
/// Minimum gas amount requirements.
/// </summary>
public float[] MinimumRequirements { get; private set; }
[DataField("minimumRequirements")]
public float[] MinimumRequirements { get; private set; } = new float[Atmospherics.TotalNumberOfGases];
/// <summary>
/// Minimum temperature requirement.
/// </summary>
public float MinimumTemperatureRequirement { get; private set; }
[DataField("minimumTemperature")]
public float MinimumTemperatureRequirement { get; private set; } = Atmospherics.TCMB;
/// <summary>
/// Minimum energy requirement.
/// </summary>
[DataField("minimumEnergy")]
public float MinimumEnergyRequirement { get; private set; }
/// <summary>
/// Lower numbers are checked/react later than higher numbers.
/// If two reactions have the same priority, they may happen in either order.
/// </summary>
[DataField("priority")]
public int Priority { get; private set; }
/// <summary>
/// A list of effects this will produce.
/// </summary>
private List<IGasReactionEffect> _effects;
public void LoadFrom(YamlMappingNode mapping)
{
var serializer = YamlObjectSerializer.NewReader(mapping);
serializer.DataField(this, x => x.ID, "id", string.Empty);
serializer.DataField(this, x => x.Priority, "priority", 100);
serializer.DataField(this, x => x.MinimumRequirements, "minimumRequirements", new float[Atmospherics.TotalNumberOfGases]);
serializer.DataField(this, x => x.MinimumTemperatureRequirement, "minimumTemperature", Atmospherics.TCMB);
serializer.DataField(this, x => x.MinimumEnergyRequirement, "minimumEnergy", 0f);
serializer.DataField(ref _effects, "effects", new List<IGasReactionEffect>());
}
[DataField("effects")] private List<IGasReactionEffect> _effects = new();
public ReactionResult React(GasMixture mixture, IGasMixtureHolder holder, GridTileLookupSystem gridLookup)
{

View File

@@ -5,11 +5,12 @@ using Content.Server.Utility;
using Content.Shared.Atmos;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Atmos.Reactions
{
[UsedImplicitly]
[DataDefinition]
public class PlasmaFireReaction : IGasReactionEffect
{
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, GridTileLookupSystem gridTileLookup)
@@ -87,9 +88,5 @@ namespace Content.Server.Atmos.Reactions
return mixture.ReactionResults[GasReaction.Fire] != 0 ? ReactionResult.Reacting : ReactionResult.NoReaction;
}
void IExposeData.ExposeData(ObjectSerializer serializer)
{
}
}
}

View File

@@ -4,17 +4,14 @@ using Content.Server.Utility;
using Content.Shared.Atmos;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Atmos.Reactions
{
[UsedImplicitly]
[DataDefinition]
public class TritiumFireReaction : IGasReactionEffect
{
void IExposeData.ExposeData(ObjectSerializer serializer)
{
}
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, GridTileLookupSystem gridTileLookup)
{
var energyReleased = 0f;

View File

@@ -1,3 +1,4 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
@@ -15,10 +16,9 @@ using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
using YamlDotNet.RepresentationModel;
namespace Content.Server.Botany
{
@@ -59,19 +59,29 @@ namespace Content.Server.Botany
}
*/
[DataDefinition]
public struct SeedChemQuantity
{
[DataField("Min")]
public int Min;
[DataField("Max")]
public int Max;
[DataField("PotencyDivisor")]
public int PotencyDivisor;
}
[Prototype("seed")]
public class Seed : IPrototype, IExposeData
public class Seed : IPrototype
{
private const string SeedPrototype = "SeedBase";
public string ID { get; private set; }
[ViewVariables]
[field: DataField("id", required: true)]
public string ID { get; private init; } = default!;
[ViewVariables]
[field: DataField("parent")]
public string? Parent { get; }
/// <summary>
/// Unique identifier of this seed. Do NOT set this.
@@ -79,45 +89,84 @@ namespace Content.Server.Botany
public int Uid { get; internal set; } = -1;
#region Tracking
[ViewVariables] public string Name { get; set; }
[ViewVariables] public string SeedName { get; set; }
[ViewVariables] public string SeedNoun { get; set; }
[ViewVariables] public string DisplayName { get; set; }
[ViewVariables] public bool RoundStart { get; private set; }
[ViewVariables] public bool Mysterious { get; set; }
[ViewVariables] public bool Immutable { get; set; }
[ViewVariables] [DataField("name")] public string Name { get; set; } = string.Empty;
[ViewVariables] [DataField("seedName")] public string SeedName { get; set; } = string.Empty;
[ViewVariables]
[DataField("seedNoun")]
public string SeedNoun { get; set; } = "seeds";
[ViewVariables] [DataField("displayName")] public string DisplayName { get; set; } = string.Empty;
[ViewVariables]
[DataField("roundStart")]
public bool RoundStart { get; private set; } = true;
[ViewVariables] [DataField("mysterious")] public bool Mysterious { get; set; }
[ViewVariables] [DataField("immutable")] public bool Immutable { get; set; }
#endregion
#region Output
[ViewVariables] public List<string> ProductPrototypes { get; set; }
[ViewVariables] public Dictionary<string, SeedChemQuantity> Chemicals { get; set; }
[ViewVariables] public Dictionary<Gas, float> ConsumeGasses { get; set; }
[ViewVariables]public Dictionary<Gas, float> ExudeGasses { get; set; }
[ViewVariables]
[DataField("productPrototypes")]
public List<string> ProductPrototypes { get; set; } = new();
[ViewVariables]
[DataField("chemicals")]
public Dictionary<string, SeedChemQuantity> Chemicals { get; set; } = new();
[ViewVariables]
[DataField("consumeGasses")]
public Dictionary<Gas, float> ConsumeGasses { get; set; } = new();
[ViewVariables]
[DataField("exudeGasses")]
public Dictionary<Gas, float> ExudeGasses { get; set; } = new();
#endregion
#region Tolerances
[ViewVariables] public float NutrientConsumption { get; set; }
[ViewVariables] public float WaterConsumption { get; set; }
[ViewVariables] public float IdealHeat { get; set; }
[ViewVariables] public float HeatTolerance { get; set; }
[ViewVariables] public float IdealLight { get; set; }
[ViewVariables] public float LightTolerance { get; set; }
[ViewVariables] public float ToxinsTolerance { get; set; }
[ViewVariables] public float LowPressureTolerance { get; set; }
[ViewVariables] public float HighPressureTolerance { get; set; }
[ViewVariables] public float PestTolerance { get; set; }
[ViewVariables] public float WeedTolerance { get; set; }
[ViewVariables]
[DataField("nutrientConsumption")]
public float NutrientConsumption { get; set; } = 0.25f;
[ViewVariables] [DataField("waterConsumption")] public float WaterConsumption { get; set; } = 3f;
[ViewVariables] [DataField("idealHeat")] public float IdealHeat { get; set; } = 293f;
[ViewVariables] [DataField("heatTolerance")] public float HeatTolerance { get; set; } = 20f;
[ViewVariables] [DataField("idealLight")] public float IdealLight { get; set; } = 7f;
[ViewVariables] [DataField("lightTolerance")] public float LightTolerance { get; set; } = 5f;
[ViewVariables] [DataField("toxinsTolerance")] public float ToxinsTolerance { get; set; } = 4f;
[ViewVariables]
[DataField("lowPressureTolerance")]
public float LowPressureTolerance { get; set; } = 25f;
[ViewVariables]
[DataField("highPressureTolerance")]
public float HighPressureTolerance { get; set; } = 200f;
[ViewVariables]
[DataField("pestTolerance")]
public float PestTolerance { get; set; } = 5f;
[ViewVariables]
[DataField("weedTolerance")]
public float WeedTolerance { get; set; } = 5f;
#endregion
#region General traits
[ViewVariables] public float Endurance { get; set; }
[ViewVariables] public int Yield { get; set; }
[ViewVariables] public float Lifespan { get; set; }
[ViewVariables] public float Maturation { get; set; }
[ViewVariables] public float Production { get; set; }
[ViewVariables] public int GrowthStages { get; set; }
[ViewVariables] public HarvestType HarvestRepeat { get; set; }
[ViewVariables] public float Potency { get; set; }
[ViewVariables]
[DataField("endurance")]
public float Endurance { get; set; } = 100f;
[ViewVariables] [DataField("yield")] public int Yield { get; set; }
[ViewVariables] [DataField("lifespan")] public float Lifespan { get; set; }
[ViewVariables] [DataField("maturation")] public float Maturation { get; set; }
[ViewVariables] [DataField("production")] public float Production { get; set; }
[ViewVariables] [DataField("growthStages")] public int GrowthStages { get; set; } = 6;
[ViewVariables] [DataField("harvestRepeat")] public HarvestType HarvestRepeat { get; set; } = HarvestType.NoRepeat;
[ViewVariables] [DataField("potency")] public float Potency { get; set; } = 1f;
// No, I'm not removing these.
//public PlantSpread Spread { get; set; }
//public PlantMutation Mutation { get; set; }
@@ -127,72 +176,36 @@ namespace Content.Server.Botany
//public bool Hematophage { get; set; }
//public bool Thorny { get; set; }
//public bool Stinging { get; set; }
[DataField("ligneous")]
public bool Ligneous { get; set; }
// public bool Teleporting { get; set; }
// public PlantJuicy Juicy { get; set; }
#endregion
#region Cosmetics
[ViewVariables]public ResourcePath PlantRsi { get; set; }
[ViewVariables] public string PlantIconState { get; set; }
[ViewVariables] public bool Bioluminescent { get; set; }
[ViewVariables] public Color BioluminescentColor { get; set; }
[ViewVariables] public string SplatPrototype { get; set; }
[ViewVariables]
[DataField("plantRsi", required: true)]
public ResourcePath PlantRsi { get; set; } = default!;
[ViewVariables]
[DataField("plantIconState")]
public string PlantIconState { get; set; } = "produce";
[ViewVariables]
[DataField("bioluminescent")]
public bool Bioluminescent { get; set; }
[ViewVariables]
[DataField("bioluminescentColor")]
public Color BioluminescentColor { get; set; } = Color.White;
[ViewVariables]
[DataField("splatPrototype")]
public string? SplatPrototype { get; set; }
#endregion
void IExposeData.ExposeData(ObjectSerializer serializer)
{
InternalExposeData(serializer);
}
public void InternalExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.ID, "id", string.Empty);
serializer.DataField(this, x => x.Name, "name", string.Empty);
serializer.DataField(this, x => x.SeedName, "seedName", string.Empty);
serializer.DataField(this, x => x.SeedNoun, "seedNoun", "seeds");
serializer.DataField(this, x => x.DisplayName, "displayName", string.Empty);
serializer.DataField(this, x => x.RoundStart, "roundStart", true);
serializer.DataField(this, x => x.Mysterious, "mysterious", false);
serializer.DataField(this, x => x.Immutable, "immutable", false);
serializer.DataField(this, x => x.ProductPrototypes, "productPrototypes", new List<string>());
serializer.DataField(this, x => x.Chemicals, "chemicals", new Dictionary<string, SeedChemQuantity>());
serializer.DataField(this, x => x.ConsumeGasses, "consumeGasses", new Dictionary<Gas, float>());
serializer.DataField(this, x => x.ExudeGasses, "exudeGasses", new Dictionary<Gas, float>());
serializer.DataField(this, x => x.NutrientConsumption, "nutrientConsumption", 0.25f);
serializer.DataField(this, x => x.WaterConsumption, "waterConsumption", 3f);
serializer.DataField(this, x => x.IdealHeat, "idealHeat", 293f);
serializer.DataField(this, x => x.HeatTolerance, "heatTolerance", 20f);
serializer.DataField(this, x => x.IdealLight, "idealLight", 7f);
serializer.DataField(this, x => x.LightTolerance, "lightTolerance", 5f);
serializer.DataField(this, x => x.ToxinsTolerance, "toxinsTolerance", 4f);
serializer.DataField(this, x => x.LowPressureTolerance, "lowPressureTolerance", 25f);
serializer.DataField(this, x => x.HighPressureTolerance, "highPressureTolerance", 200f);
serializer.DataField(this, x => x.PestTolerance, "pestTolerance", 5f);
serializer.DataField(this, x => x.WeedTolerance, "weedTolerance", 5f);
serializer.DataField(this, x => x.Endurance, "endurance", 100f);
serializer.DataField(this, x => x.Yield, "yield", 0);
serializer.DataField(this, x => x.Lifespan, "lifespan", 0f);
serializer.DataField(this, x => x.Maturation, "maturation", 0f);
serializer.DataField(this, x => x.Production, "production", 0f);
serializer.DataField(this, x => x.GrowthStages, "growthStages", 6);
serializer.DataField(this, x => x.HarvestRepeat, "harvestRepeat", HarvestType.NoRepeat);
serializer.DataField(this, x => x.Potency, "potency", 1f);
serializer.DataField(this, x => x.Ligneous, "ligneous", false);
serializer.DataField(this, x => x.PlantRsi, "plantRsi", null);
serializer.DataField(this, x => x.PlantIconState, "plantIconState", "produce");
serializer.DataField(this, x => x.Bioluminescent, "bioluminescent", false);
serializer.DataField(this, x => x.BioluminescentColor, "bioluminescentColor", Color.White);
serializer.DataField(this, x => x.SplatPrototype, "splatPrototype", string.Empty);
}
public void LoadFrom(YamlMappingNode mapping)
{
var serializer = YamlObjectSerializer.NewReader(mapping);
InternalExposeData(serializer);
}
public Seed Clone()
{
var newSeed = new Seed()
@@ -240,7 +253,7 @@ namespace Content.Server.Botany
return newSeed;
}
public IEntity SpawnSeedPacket(EntityCoordinates transformCoordinates, IEntityManager entityManager = null)
public IEntity SpawnSeedPacket(EntityCoordinates transformCoordinates, IEntityManager? entityManager = null)
{
entityManager ??= IoCManager.Resolve<IEntityManager>();
@@ -249,7 +262,7 @@ namespace Content.Server.Botany
var seedComp = seed.EnsureComponent<SeedComponent>();
seedComp.Seed = this;
if (seed.TryGetComponent(out SpriteComponent sprite))
if (seed.TryGetComponent(out SpriteComponent? sprite))
{
// Seed state will always be seed. Blame the spriter if that's not the case!
sprite.LayerSetSprite(0, new SpriteSpecifier.Rsi(PlantRsi, "seed"));
@@ -346,7 +359,7 @@ namespace Content.Server.Botany
return Clone();
}
public bool CheckHarvest(IEntity user, IEntity held = null)
public bool CheckHarvest(IEntity user, IEntity? held = null)
{
return (!Ligneous || (Ligneous && held != null && held.HasTag("BotanySharp")));
}

View File

@@ -2,7 +2,7 @@
using Content.Shared.Chemistry;
using Content.Shared.Interfaces.Chemistry;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Chemistry.Metabolism
{
@@ -10,21 +10,16 @@ namespace Content.Server.Chemistry.Metabolism
/// Default metabolism for drink reagents. Attempts to find a ThirstComponent on the target,
/// and to update it's thirst values.
/// </summary>
[DataDefinition]
public class DefaultDrink : IMetabolizable
{
//Rate of metabolism in units / second
private ReagentUnit _metabolismRate;
public ReagentUnit MetabolismRate => _metabolismRate;
[DataField("rate")]
public ReagentUnit MetabolismRate { get; set; } = ReagentUnit.New(1);
//How much thirst is satiated when 1u of the reagent is metabolized
private float _hydrationFactor;
public float HydrationFactor => _hydrationFactor;
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(ref _metabolismRate, "rate", ReagentUnit.New(1));
serializer.DataField(ref _hydrationFactor, "nutrimentFactor", 30.0f);
}
[DataField("hydrationFactor")]
public float HydrationFactor { get; set; } = 30.0f;
//Remove reagent at set rate, satiate thirst if a ThirstComponent can be found
ReagentUnit IMetabolizable.Metabolize(IEntity solutionEntity, string reagentId, float tickTime)

View File

@@ -2,7 +2,7 @@
using Content.Shared.Chemistry;
using Content.Shared.Interfaces.Chemistry;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Chemistry.Metabolism
{
@@ -10,21 +10,18 @@ namespace Content.Server.Chemistry.Metabolism
/// Default metabolism for food reagents. Attempts to find a HungerComponent on the target,
/// and to update it's hunger values.
/// </summary>
[DataDefinition]
public class DefaultFood : IMetabolizable
{
//Rate of metabolism in units / second
private ReagentUnit _metabolismRate;
public ReagentUnit MetabolismRate => _metabolismRate;
/// <summary>
/// Rate of metabolism in units / second
/// </summary>
[DataField("rate")] public ReagentUnit MetabolismRate { get; private set; } = ReagentUnit.New(1.0);
//How much hunger is satiated when 1u of the reagent is metabolized
private float _nutritionFactor;
public float NutritionFactor => _nutritionFactor;
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(ref _metabolismRate, "rate", ReagentUnit.New(1.0));
serializer.DataField(ref _nutritionFactor, "nutrimentFactor", 30.0f);
}
/// <summary>
/// How much hunger is satiated when 1u of the reagent is metabolized
/// </summary>
[DataField("nutritionFactor")] public float NutritionFactor { get; set; } = 30.0f;
//Remove reagent at set rate, satiate hunger if a HungerComponent can be found
ReagentUnit IMetabolizable.Metabolize(IEntity solutionEntity, string reagentId, float tickTime)

View File

@@ -5,22 +5,17 @@ using Content.Shared.Interfaces.Chemistry;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Chemistry.PlantMetabolism
{
[ImplicitDataDefinitionForInheritors]
public abstract class AdjustAttribute : IPlantMetabolizable
{
[Dependency] private readonly IRobustRandom _robustRandom = default!;
public float Amount { get; private set; }
public float Prob { get; private set; }
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.Amount, "amount", 1f);
serializer.DataField(this, x => x.Prob, "prob", 1f);
}
[DataField("amount")] public float Amount { get; protected set; } = 1;
[DataField("prob")] public float Prob { get; protected set; } = 1; // = (80);
/// <summary>
/// Checks if the plant holder can metabolize the reagent or not. Checks if it has an alive plant by default.

View File

@@ -6,17 +6,14 @@ using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Chemistry.PlantMetabolism
{
[UsedImplicitly]
[DataDefinition]
public class Clonexadone : IPlantMetabolizable
{
void IExposeData.ExposeData(ObjectSerializer serializer)
{
}
public void Metabolize(IEntity plantHolder, float customPlantMetabolism = 1)
{
if (plantHolder.Deleted || !plantHolder.TryGetComponent(out PlantHolderComponent? plantHolderComp)

View File

@@ -6,17 +6,14 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Chemistry.PlantMetabolism
{
[UsedImplicitly]
[DataDefinition]
public class Diethylamine : IPlantMetabolizable
{
void IExposeData.ExposeData(ObjectSerializer serializer)
{
}
public void Metabolize(IEntity plantHolder, float customPlantMetabolism = 1)
{
if (plantHolder.Deleted || !plantHolder.TryGetComponent(out PlantHolderComponent? plantHolderComp)

View File

@@ -6,17 +6,14 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Chemistry.PlantMetabolism
{
[UsedImplicitly]
[DataDefinition]
public class RobustHarvest : IPlantMetabolizable
{
void IExposeData.ExposeData(ObjectSerializer serializer)
{
}
public void Metabolize(IEntity plantHolder, float customPlantMetabolism = 1f)
{
if (plantHolder.Deleted || !plantHolder.TryGetComponent(out PlantHolderComponent? plantHolderComp)

View File

@@ -1,16 +1,16 @@
#nullable enable
using System;
using Content.Server.GameObjects.Components.Chemistry;
using Content.Server.Interfaces.Chemistry;
using Content.Server.Utility;
using Content.Shared.Audio;
using Content.Shared.Interfaces.Chemistry;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Chemistry.ReactionEffects
{
@@ -18,6 +18,7 @@ namespace Content.Server.Chemistry.ReactionEffects
/// Basically smoke and foam reactions.
/// </summary>
[UsedImplicitly]
[ImplicitDataDefinitionForInheritors]
public abstract class AreaReactionEffect : IReactionEffect
{
[Dependency] private readonly IMapManager _mapManager = default!;
@@ -25,82 +26,65 @@ namespace Content.Server.Chemistry.ReactionEffects
/// <summary>
/// Used for calculating the spread range of the effect based on the intensity of the reaction.
/// </summary>
private float _rangeConstant;
private float _rangeMultiplier;
private int _maxRange;
[DataField("rangeConstant")] private float _rangeConstant;
[DataField("rangeMultiplier")] private float _rangeMultiplier = 1.1f;
[DataField("maxRange")] private int _maxRange = 10;
/// <summary>
/// If true the reagents get diluted or concentrated depending on the range of the effect
/// </summary>
private bool _diluteReagents;
[DataField("diluteReagents")] private bool _diluteReagents;
/// <summary>
/// At what range should the reagents volume stay the same. If the effect range is higher than this then the reagents
/// will get diluted. If the effect range is lower than this then the reagents will get concentrated.
/// </summary>
private int _reagentDilutionStart;
[DataField("reagentDilutionStart")] private int _reagentDilutionStart = 4;
/// <summary>
/// Used to calculate dilution. Increasing this makes the reagents get more diluted. This means that a lower range
/// will be needed to make the reagents volume get closer to zero.
/// </summary>
private float _reagentDilutionFactor;
[DataField("reagentDilutionFactor")] private float _reagentDilutionFactor = 1;
/// <summary>
/// Used to calculate concentration. Reagents get linearly more concentrated as the range goes from
/// _reagentDilutionStart to zero. When the range is zero the reagents volume gets multiplied by this.
/// </summary>
private float _reagentMaxConcentrationFactor;
[DataField("reagentMaxConcentrationFactor")]
private float _reagentMaxConcentrationFactor = 2;
/// <summary>
/// How many seconds will the effect stay, counting after fully spreading.
/// </summary>
private float _duration;
[DataField("duration")] private float _duration = 10;
/// <summary>
/// How many seconds between each spread step.
/// </summary>
private float _spreadDelay;
[DataField("spreadDelay")] private float _spreadDelay = 0.5f;
/// <summary>
/// How many seconds between each remove step.
/// </summary>
private float _removeDelay;
[DataField("removeDelay")] private float _removeDelay = 0.5f;
/// <summary>
/// The entity prototype that will be spawned as the effect. It needs a component derived from SolutionAreaEffectComponent.
/// </summary>
private string? _prototypeId;
[DataField("prototypeId", required: true)]
private string _prototypeId = default!;
/// <summary>
/// Sound that will get played when this reaction effect occurs.
/// </summary>
private string? _sound;
[DataField("sound")] private string? _sound;
protected AreaReactionEffect()
{
IoCManager.InjectDependencies(this);
}
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(ref _rangeConstant, "rangeConstant",0f);
serializer.DataField(ref _rangeMultiplier, "rangeMultiplier",1.1f);
serializer.DataField(ref _maxRange, "maxRange", 10);
serializer.DataField(ref _diluteReagents, "diluteReagents", false);
serializer.DataField(ref _reagentDilutionStart, "reagentDilutionStart", 4);
serializer.DataField(ref _reagentDilutionFactor, "reagentDilutionFactor", 1f);
serializer.DataField(ref _reagentMaxConcentrationFactor, "reagentMaxConcentrationFactor",2f);
serializer.DataField(ref _duration, "duration", 10f);
serializer.DataField(ref _spreadDelay, "spreadDelay", 0.5f);
serializer.DataField(ref _removeDelay, "removeDelay", 0.5f);
serializer.DataField(ref _sound, "sound", null);
serializer.DataField(ref _prototypeId, "prototypeId", null);
if (_prototypeId == null)
Logger.Error("prototypeId wasn't provided to AreaReactionEffect, check yaml");
}
public void React(IEntity solutionEntity, double intensity)
{
if (!solutionEntity.TryGetComponent(out SolutionContainerComponent? contents))

View File

@@ -1,43 +1,34 @@
using System;
using Content.Server.Explosions;
using Content.Server.GameObjects.Components.Chemistry;
using Content.Server.Interfaces.Chemistry;
using Content.Shared.Interfaces.Chemistry;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Chemistry.ReactionEffects
{
[DataDefinition]
public class ExplosionReactionEffect : IReactionEffect
{
private float _devastationRange;
private float _heavyImpactRange;
private float _lightImpactRange;
private float _flashRange;
[DataField("devastationRange")] private float _devastationRange = 1;
[DataField("heavyImpactRange")] private float _heavyImpactRange = 2;
[DataField("lightImpactRange")] private float _lightImpactRange = 3;
[DataField("flashRange")] private float _flashRange;
/// <summary>
/// If true, then scale ranges by intensity. If not, the ranges are the same regardless of reactant amount.
/// </summary>
private bool _scaled;
[DataField("scaled")] private bool _scaled;
/// <summary>
/// Maximum scaling on ranges. For example, if it equals 5, then it won't scaled anywhere past
/// 5 times the minimum reactant amount.
/// </summary>
private float _maxScale;
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(ref _devastationRange, "devastationRange", 1);
serializer.DataField(ref _heavyImpactRange, "heavyImpactRange", 2);
serializer.DataField(ref _lightImpactRange, "lightImpactRange", 3);
serializer.DataField(ref _flashRange, "flashRange", 0);
serializer.DataField(ref _scaled, "scaled", false);
serializer.DataField(ref _maxScale, "maxScale", 1);
}
[DataField("maxScale")] private float _maxScale = 1;
public void React(IEntity solutionEntity, double intensity)
{
float floatIntensity = (float)intensity;
var floatIntensity = (float)intensity;
if (solutionEntity == null)
return;
if(!solutionEntity.TryGetComponent(out SolutionContainerComponent solution))
@@ -54,10 +45,10 @@ namespace Content.Server.Chemistry.ReactionEffects
}
//Calculate intensities
int finalDevastationRange = (int)MathF.Round(_devastationRange * floatIntensity);
int finalHeavyImpactRange = (int)MathF.Round(_heavyImpactRange * floatIntensity);
int finalLightImpactRange = (int)MathF.Round(_lightImpactRange * floatIntensity);
int finalFlashRange = (int)MathF.Round(_flashRange * floatIntensity);
var finalDevastationRange = (int)MathF.Round(_devastationRange * floatIntensity);
var finalHeavyImpactRange = (int)MathF.Round(_heavyImpactRange * floatIntensity);
var finalLightImpactRange = (int)MathF.Round(_lightImpactRange * floatIntensity);
var finalFlashRange = (int)MathF.Round(_flashRange * floatIntensity);
solutionEntity.SpawnExplosion(finalDevastationRange,
finalHeavyImpactRange, finalLightImpactRange, finalFlashRange);
}

View File

@@ -2,10 +2,12 @@
using Content.Server.GameObjects.Components.Chemistry;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Chemistry.ReactionEffects
{
[UsedImplicitly]
[DataDefinition]
public class FoamAreaReactionEffect : AreaReactionEffect
{
protected override SolutionAreaEffectComponent? GetAreaEffectComponent(IEntity entity)

View File

@@ -2,10 +2,12 @@
using Content.Server.GameObjects.Components.Chemistry;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Chemistry.ReactionEffects
{
[UsedImplicitly]
[DataDefinition]
public class SmokeAreaReactionEffect : AreaReactionEffect
{
protected override SolutionAreaEffectComponent? GetAreaEffectComponent(IEntity entity)

View File

@@ -1,19 +1,16 @@
using Content.Server.GameObjects.Components;
using System.Linq;
using Content.Server.GameObjects.Components;
using Content.Server.Utility;
using Content.Shared.Chemistry;
using Content.Shared.Interfaces.Chemistry;
using Robust.Shared.Map;
using Robust.Shared.Serialization;
using System.Linq;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Chemistry.TileReactions
{
[DataDefinition]
public class CleanTileReaction : ITileReaction
{
void IExposeData.ExposeData(ObjectSerializer serializer)
{
}
ReagentUnit ITileReaction.TileReact(TileRef tile, ReagentPrototype reagent, ReagentUnit reactVolume)
{
var entities = tile.GetEntitiesInTileFast().ToArray();

View File

@@ -5,19 +5,15 @@ using Content.Shared.Chemistry;
using Content.Shared.Interfaces.Chemistry;
using JetBrains.Annotations;
using Robust.Shared.Map;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Chemistry.TileReactions
{
[UsedImplicitly]
[DataDefinition]
public class ExtinguishTileReaction : ITileReaction
{
private float _coolingTemperature = 2f;
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(ref _coolingTemperature, "coolingTemperature", 2f);
}
[DataField("coolingTemperature")] private float _coolingTemperature = 2f;
public ReagentUnit TileReact(TileRef tile, ReagentPrototype reagent, ReagentUnit reactVolume)
{

View File

@@ -4,19 +4,15 @@ using Content.Shared.Chemistry;
using Content.Shared.Interfaces.Chemistry;
using JetBrains.Annotations;
using Robust.Shared.Map;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Chemistry.TileReactions
{
[UsedImplicitly]
[DataDefinition]
public class FlammableTileReaction : ITileReaction
{
private float _temperatureMultiplier = 1.25f;
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(ref _temperatureMultiplier, "temperatureMultiplier", 1.15f);
}
[DataField("temperatureMultiplier")] private float _temperatureMultiplier = 1.15f;
public ReagentUnit TileReact(TileRef tile, ReagentPrototype reagent, ReagentUnit reactVolume)
{

View File

@@ -3,17 +3,14 @@ using Content.Shared.Chemistry;
using Content.Shared.Interfaces.Chemistry;
using JetBrains.Annotations;
using Robust.Shared.Map;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Chemistry.TileReactions
{
[UsedImplicitly]
[DataDefinition]
public class SpillIfPuddlePresentTileReaction : ITileReaction
{
void IExposeData.ExposeData(ObjectSerializer serializer)
{
}
public ReagentUnit TileReact(TileRef tile, ReagentPrototype reagent, ReagentUnit reactVolume)
{
if (reactVolume < 5 || !tile.TryGetPuddle(null, out _)) return ReagentUnit.Zero;

View File

@@ -4,26 +4,18 @@ using Content.Shared.Chemistry;
using Content.Shared.Interfaces.Chemistry;
using JetBrains.Annotations;
using Robust.Shared.Map;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Chemistry.TileReactions
{
[UsedImplicitly]
[DataDefinition]
public class SpillTileReaction : ITileReaction
{
private float _launchForwardsMultiplier = 1f;
private float _requiredSlipSpeed = 6f;
private float _paralyzeTime = 1f;
private bool _overflow;
void IExposeData.ExposeData(ObjectSerializer serializer)
{
// If you want to modify more puddle/slippery values, add them here.
serializer.DataField(ref _paralyzeTime, "paralyzeTime", 1f);
serializer.DataField(ref _launchForwardsMultiplier, "launchForwardsMultiplier", 1f);
serializer.DataField(ref _requiredSlipSpeed, "requiredSlipSpeed", 6f);
serializer.DataField(ref _overflow, "overflow", false);
}
[DataField("launchForwardsMultiplier")] private float _launchForwardsMultiplier = 1;
[DataField("requiredSlipSpeed")] private float _requiredSlipSpeed = 6;
[DataField("paralyzeTime")] private float _paralyzeTime = 1;
[DataField("overflow")] private bool _overflow;
public ReagentUnit TileReact(TileRef tile, ReagentPrototype reagent, ReagentUnit reactVolume)
{

View File

@@ -6,6 +6,7 @@ using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
namespace Content.Server.Commands.GameTicking
{
@@ -62,6 +63,7 @@ namespace Content.Server.Commands.GameTicking
}
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
var underplating = tileDefinitionManager["underplating"];
var underplatingTile = new Tile(underplating.TileId);
var changed = 0;
@@ -80,7 +82,7 @@ namespace Content.Server.Commands.GameTicking
break;
}
prototype = prototype.Parent;
prototype = prototypeManager.Index<EntityPrototype>(prototype.Parent);
}
if (prototype?.ID != "base_wall")

View File

@@ -4,19 +4,15 @@ using Content.Server.GameObjects.Components.Construction;
using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Construction.Completions
{
[UsedImplicitly]
[DataDefinition]
public class AddContainer : IGraphAction
{
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.Container, "container", null);
}
public string? Container { get; private set; } = null;
[DataField("container")] public string? Container { get; private set; } = null;
public async Task PerformAction(IEntity entity, IEntity? user)
{

View File

@@ -7,19 +7,15 @@ using JetBrains.Annotations;
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.Construction.Completions
{
[UsedImplicitly]
[DataDefinition]
public class BuildComputer : IGraphAction
{
public string Container { get; private set; } = string.Empty;
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.Container, "container", string.Empty);
}
[DataField("container")] public string Container { get; private set; } = string.Empty;
public async Task PerformAction(IEntity entity, IEntity? user)
{

View File

@@ -7,11 +7,12 @@ using JetBrains.Annotations;
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.Construction.Completions
{
[UsedImplicitly]
[DataDefinition]
public class BuildMachine : IGraphAction
{
public async Task PerformAction(IEntity entity, IEntity? user)
@@ -104,9 +105,5 @@ namespace Content.Server.Construction.Completions
entity.Delete();
}
void IExposeData.ExposeData(ObjectSerializer serializer)
{
}
}
}

View File

@@ -3,17 +3,14 @@ using System.Threading.Tasks;
using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Construction.Completions
{
[UsedImplicitly]
[DataDefinition]
public class DeleteEntity : IGraphAction
{
void IExposeData.ExposeData(ObjectSerializer serializer)
{
}
public async Task PerformAction(IEntity entity, IEntity? user)
{
if (entity.Deleted) return;

View File

@@ -4,17 +4,14 @@ using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Construction.Completions
{
[UsedImplicitly]
[DataDefinition]
public class EmptyAllContainers : IGraphAction
{
void IExposeData.ExposeData(ObjectSerializer serializer)
{
}
public async Task PerformAction(IEntity entity, IEntity? user)
{
if (entity.Deleted || !entity.TryGetComponent<ContainerManagerComponent>(out var containerManager))

View File

@@ -5,19 +5,15 @@ using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Construction.Completions
{
[UsedImplicitly]
[DataDefinition]
public class EmptyContainer : IGraphAction
{
public string Container { get; private set; } = string.Empty;
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.Container, "container", string.Empty);
}
[DataField("container")] public string Container { get; private set; } = string.Empty;
public async Task PerformAction(IEntity entity, IEntity? user)
{

View File

@@ -4,16 +4,14 @@ using Content.Server.GameObjects.Components.Construction;
using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Construction.Completions
{
[UsedImplicitly]
[DataDefinition]
public class MachineFrameRegenerateProgress : IGraphAction
{
void IExposeData.ExposeData(ObjectSerializer serializer)
{ }
public async Task PerformAction(IEntity entity, IEntity? user)
{
if (entity.Deleted)

View File

@@ -5,21 +5,16 @@ using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Construction.Completions
{
[UsedImplicitly]
[DataDefinition]
public class PlaySound : IGraphAction
{
public string SoundCollection { get; private set; } = string.Empty;
public string Sound { get; private set; } = string.Empty;
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.Sound, "sound", string.Empty);
serializer.DataField(this, x => x.SoundCollection, "soundCollection", string.Empty);
}
[DataField("soundCollection")] public string SoundCollection { get; private set; } = string.Empty;
[DataField("sound")] public string Sound { get; private set; } = string.Empty;
public async Task PerformAction(IEntity entity, IEntity? user)
{

View File

@@ -4,21 +4,16 @@ using Content.Shared.Construction;
using Content.Shared.Interfaces;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Construction.Completions
{
[UsedImplicitly]
[DataDefinition]
public class PopupUser : IGraphAction
{
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.Text, "text", string.Empty);
serializer.DataField(this, x => x.Cursor, "cursor", false);
}
public bool Cursor { get; private set; } = false;
public string Text { get; private set; } = string.Empty;
[DataField("cursor")] public bool Cursor { get; private set; } = false;
[DataField("text")] public string Text { get; private set; } = string.Empty;
public async Task PerformAction(IEntity entity, IEntity? user)
{

View File

@@ -3,19 +3,15 @@ using System.Threading.Tasks;
using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Construction.Completions
{
[UsedImplicitly]
[DataDefinition]
public class SetAnchor : IGraphAction
{
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.Value, "value", true);
}
public bool Value { get; private set; } = true;
[DataField("value")] public bool Value { get; private set; } = true;
public async Task PerformAction(IEntity entity, IEntity? user)
{

View File

@@ -1,24 +1,20 @@
#nullable enable
using System;
using System.Threading.Tasks;
using Content.Server.GameObjects.Components.Stack;
using Content.Shared.Construction;
using JetBrains.Annotations;
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.Log;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Construction.Completions
{
[UsedImplicitly]
[DataDefinition]
public class SetStackCount : IGraphAction
{
public int Amount { get; private set; }
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.Amount, "amount", 1);
}
[DataField("amount")] public int Amount { get; private set; } = 1;
public async Task PerformAction(IEntity entity, IEntity? user)
{

View File

@@ -6,20 +6,17 @@ using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Maths;
using Robust.Shared.Serialization.Manager.Attributes;
using YamlDotNet.Serialization;
namespace Content.Server.Construction.Completions
{
[UsedImplicitly]
[DataDefinition]
public class SnapToGrid : IGraphAction
{
public SnapGridOffset Offset { get; private set; } = SnapGridOffset.Center;
public bool SouthRotation { get; private set; } = false;
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.Offset, "offset", SnapGridOffset.Center);
serializer.DataField(this, x => x.SouthRotation, "southRotation", false);
}
[DataField("offset")] public SnapGridOffset Offset { get; private set; } = SnapGridOffset.Center;
[DataField("southRotation")] public bool SouthRotation { get; private set; } = false;
public async Task PerformAction(IEntity entity, IEntity? user)
{

View File

@@ -7,22 +7,16 @@ using Content.Shared.Utility;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Construction.Completions
{
[UsedImplicitly]
[DataDefinition]
public class SpawnPrototype : IGraphAction
{
public string Prototype { get; private set; } = string.Empty;
public int Amount { get; private set; } = 1;
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.Prototype, "prototype", string.Empty);
serializer.DataField(this, x => x.Amount, "amount", 1);
}
[DataField("prototype")] public string Prototype { get; private set; } = string.Empty;
[DataField("amount")] public int Amount { get; private set; } = 1;
public async Task PerformAction(IEntity entity, IEntity? user)
{

View File

@@ -4,22 +4,17 @@ using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
namespace Content.Server.Construction.Completions
{
[UsedImplicitly]
[DataDefinition]
public class SpriteChange : IGraphAction
{
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.SpriteSpecifier, "specifier", SpriteSpecifier.Invalid);
serializer.DataField(this, x => x.Layer, "layer", 0);
}
public int Layer { get; private set; } = 0;
public SpriteSpecifier? SpriteSpecifier { get; private set; } = SpriteSpecifier.Invalid;
[DataField("layer")] public int Layer { get; private set; } = 0;
[DataField("specifier")] public SpriteSpecifier? SpriteSpecifier { get; private set; } = SpriteSpecifier.Invalid;
public async Task PerformAction(IEntity entity, IEntity? user)
{

View File

@@ -4,21 +4,16 @@ using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Construction.Completions
{
[UsedImplicitly]
[DataDefinition]
public class SpriteStateChange : IGraphAction
{
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.State, "state", string.Empty);
serializer.DataField(this, x => x.Layer, "layer", 0);
}
public int Layer { get; private set; } = 0;
public string? State { get; private set; } = string.Empty;
[DataField("layer")] public int Layer { get; private set; } = 0;
[DataField("state")] public string? State { get; private set; } = string.Empty;
public async Task PerformAction(IEntity entity, IEntity? user)
{

View File

@@ -6,11 +6,12 @@ using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Reflection;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Construction.Completions
{
[UsedImplicitly]
[DataDefinition]
public class VisualizerDataInt : IGraphAction
{
[Dependency] private readonly IReflectionManager _reflectionManager = default!;
@@ -20,14 +21,8 @@ namespace Content.Server.Construction.Completions
IoCManager.InjectDependencies(this);
}
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.Key, "key", string.Empty);
serializer.DataField(this, x => x.Data, "data", 0);
}
public string? Key { get; private set; } = string.Empty;
public int Data { get; private set; } = 0;
[DataField("key")] public string Key { get; private set; } = string.Empty;
[DataField("data")] public int Data { get; private set; } = 0;
public async Task PerformAction(IEntity entity, IEntity? user)
{

View File

@@ -3,7 +3,7 @@ using Content.Server.GameObjects.Components;
using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Construction.Conditions
{
@@ -12,14 +12,10 @@ namespace Content.Server.Construction.Conditions
/// Returns true if the entity doesn't have a wires component.
/// </summary>
[UsedImplicitly]
[DataDefinition]
public class AllWiresCut : IEdgeCondition
{
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.Value, "value", true);
}
public bool Value { get; private set; } = true;
[DataField("value")] public bool Value { get; private set; } = true;
public async Task<bool> Condition(IEntity entity)
{

View File

@@ -5,7 +5,7 @@ using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Construction.Conditions
{
@@ -13,6 +13,7 @@ namespace Content.Server.Construction.Conditions
/// Makes the condition fail if any entities on a tile have (or not) a component.
/// </summary>
[UsedImplicitly]
[DataDefinition]
public class ComponentInTile : IEdgeCondition
{
[Dependency] private readonly IComponentFactory _componentFactory = default!;
@@ -23,22 +24,18 @@ namespace Content.Server.Construction.Conditions
IoCManager.InjectDependencies(this);
}
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.Component, "component", string.Empty);
serializer.DataField(this, x => x.HasEntity, "hasEntity", true);
}
/// <summary>
/// If true, any entity on the tile must have the component.
/// If false, no entity on the tile must have the component.
/// </summary>
[DataField("hasEntity")]
public bool HasEntity { get; private set; }
/// <summary>
/// The component name in question.
/// </summary>
public string Component { get; private set; }
[DataField("component")]
public string Component { get; private set; } = string.Empty;
public async Task<bool> Condition(IEntity entity)
{

View File

@@ -4,22 +4,17 @@ using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
namespace Content.Server.Construction.Conditions
{
[UsedImplicitly]
[DataDefinition]
public class ContainerEmpty : IEdgeCondition
{
public string Container { get; private set; } = string.Empty;
public string Text { get; private set; } = string.Empty;
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.Container, "container", string.Empty);
serializer.DataField(this, x => x.Text, "text", string.Empty);
}
[DataField("container")] public string Container { get; private set; } = string.Empty;
[DataField("text")] public string Text { get; private set; } = string.Empty;
public async Task<bool> Condition(IEntity entity)
{

View File

@@ -4,20 +4,16 @@ using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
namespace Content.Server.Construction.Conditions
{
[UsedImplicitly]
[DataDefinition]
public class DoorWelded : IEdgeCondition
{
public bool Welded { get; private set; }
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.Welded, "welded", true);
}
[DataField("welded")] public bool Welded { get; private set; } = true;
public async Task<bool> Condition(IEntity entity)
{

View File

@@ -2,20 +2,16 @@
using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
namespace Content.Server.Construction.Conditions
{
[UsedImplicitly]
[DataDefinition]
public class EntityAnchored : IEdgeCondition
{
public bool Anchored { get; private set; }
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.Anchored, "anchored", true);
}
[DataField("anchored")] public bool Anchored { get; private set; } = true;
public async Task<bool> Condition(IEntity entity)
{

View File

@@ -4,7 +4,7 @@ using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
namespace Content.Server.Construction.Conditions
@@ -13,10 +13,9 @@ namespace Content.Server.Construction.Conditions
/// Checks that the entity has all parts needed in the machine frame component.
/// </summary>
[UsedImplicitly]
[DataDefinition]
public class MachineFrameComplete : IEdgeCondition
{
void IExposeData.ExposeData(ObjectSerializer serializer) { }
public async Task<bool> Condition(IEntity entity)
{
if (entity.Deleted || !entity.TryGetComponent<MachineFrameComponent>(out var machineFrame))

View File

@@ -5,12 +5,13 @@ using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
namespace Content.Server.Construction.Conditions
{
[UsedImplicitly]
[DataDefinition]
public class ToiletLidClosed : IEdgeCondition
{
public async Task<bool> Condition(IEntity entity)
@@ -27,9 +28,5 @@ namespace Content.Server.Construction.Conditions
message.AddMarkup(Loc.GetString("Use a [color=yellow]crowbar[/color] to close the lid.\n"));
return true;
}
void IExposeData.ExposeData(ObjectSerializer serializer)
{
}
}
}

View File

@@ -4,20 +4,16 @@ using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
namespace Content.Server.Construction.Conditions
{
[UsedImplicitly]
[DataDefinition]
public class WirePanel : IEdgeCondition
{
public bool Open { get; private set; }
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.Open, "open", true);
}
[DataField("open")] public bool Open { get; private set; } = true;
public async Task<bool> Condition(IEntity entity)
{

View File

@@ -25,4 +25,5 @@
<ProjectReference Include="..\Content.Shared\Content.Shared.csproj" />
</ItemGroup>
<Import Project="..\RobustToolbox\MSBuild\Robust.Analyzers.targets" />
</Project>

View File

@@ -1,8 +1,8 @@
#nullable enable
using System.Collections.Generic;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using YamlDotNet.RepresentationModel;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.AI
{
@@ -11,17 +11,15 @@ namespace Content.Server.GameObjects.Components.AI
{
// These are immutable so any dynamic changes aren't saved back over.
// AiFactionSystem will just read these and then store them.
[ViewVariables]
[field: DataField("id", required: true)]
public string ID { get; } = default!;
public string ID { get; private set; } = default!;
[ViewVariables]
[field: DataField("parent")]
public string? Parent { get; }
public IReadOnlyList<string> Hostile { get; private set; } = default!;
public void LoadFrom(YamlMappingNode mapping)
{
var serializer = YamlObjectSerializer.NewReader(mapping);
serializer.DataField(this, x => x.ID, "id", string.Empty);
serializer.DataField(this, x => x.Hostile, "hostile", new List<string>());
}
[DataField("hostile")]
public IReadOnlyList<string> Hostile { get; private set; } = new List<string>();
}
}

View File

@@ -1,9 +1,7 @@
#nullable enable
using System;
using System.Collections.Generic;
using Content.Server.GameObjects.EntitySystems.AI;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.GameObjects.Components.AI
{
@@ -12,29 +10,7 @@ namespace Content.Server.GameObjects.Components.AI
{
public override string Name => "AiFactionTag";
[DataField("factions")]
public Faction Factions { get; private set; } = Faction.None;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataReadWriteFunction(
"factions",
new List<Faction>(),
factions => factions.ForEach(faction => Factions |= faction),
() =>
{
var writeFactions = new List<Faction>();
foreach (Faction fac in Enum.GetValues(typeof(Faction)))
{
if ((Factions & fac) != 0)
{
writeFactions.Add(fac);
}
}
return writeFactions;
});
}
}
}

View File

@@ -2,7 +2,7 @@
using System.Collections.Generic;
using Content.Server.Interfaces;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Access
@@ -16,25 +16,13 @@ namespace Content.Server.GameObjects.Components.Access
{
public override string Name => "Access";
[DataField("tags")]
[ViewVariables]
private readonly HashSet<string> _tags = new();
public ISet<string> Tags => _tags;
public bool IsReadOnly => false;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataReadWriteFunction("tags", new List<string>(),
value =>
{
_tags.Clear();
_tags.UnionWith(value);
},
() => new List<string>(_tags));
}
public void SetTags(IEnumerable<string> newTags)
{
_tags.Clear();

View File

@@ -13,7 +13,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
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.Access
@@ -28,14 +28,15 @@ namespace Content.Server.GameObjects.Components.Access
{
public override string Name => "AccessReader";
private readonly List<ISet<string>> _accessLists = new();
private readonly HashSet<string> _denyTags = new();
/// <summary>
/// List of access lists to check allowed against. For an access check to pass
/// there has to be an access list that is a subset of the access in the checking list.
/// </summary>
[ViewVariables] public IList<ISet<string>> AccessLists => _accessLists;
[field: DataField("access")]
[ViewVariables]
public List<HashSet<string>> AccessLists { get; } = new();
/// <summary>
/// The set of tags that will automatically deny an allowed check, if any of them are present.
@@ -69,7 +70,7 @@ namespace Content.Server.GameObjects.Components.Access
return false;
}
return _accessLists.Count == 0 || _accessLists.Any(a => a.IsSubsetOf(accessTags));
return AccessLists.Count == 0 || AccessLists.Any(a => a.IsSubsetOf(accessTags));
}
public static ICollection<string> FindAccessTags(IEntity entity)
@@ -120,21 +121,5 @@ namespace Content.Server.GameObjects.Components.Access
}
}
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataReadWriteFunction("access", new List<List<string>>(),
v =>
{
if (v.Count != 0)
{
_accessLists.Clear();
_accessLists.AddRange(v.Select(a => new HashSet<string>(a)));
}
},
() => _accessLists.Select(p => new List<string>(p)).ToList());
}
}
}

View File

@@ -1,6 +1,8 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Access
@@ -11,8 +13,10 @@ namespace Content.Server.GameObjects.Components.Access
public override string Name => "IdCard";
/// See <see cref="UpdateEntityName"/>.
[DataField("originalOwnerName")]
private string _ownerOriginalName;
[DataField("fullName")]
private string _fullName;
[ViewVariables(VVAccess.ReadWrite)]
public string FullName
@@ -25,6 +29,7 @@ namespace Content.Server.GameObjects.Components.Access
}
}
[DataField("jobTitle")]
private string _jobTitle;
[ViewVariables(VVAccess.ReadWrite)]
public string JobTitle
@@ -70,14 +75,5 @@ namespace Content.Server.GameObjects.Components.Access
_ownerOriginalName ??= Owner.Name;
UpdateEntityName();
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _fullName, "fullName", string.Empty);
serializer.DataField(ref _jobTitle, "jobTitle", string.Empty);
serializer.DataField(ref _ownerOriginalName, "originalOwnerName", null);
}
}
}

View File

@@ -5,6 +5,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.GameObjects.Components.Access
{
@@ -13,15 +14,9 @@ namespace Content.Server.GameObjects.Components.Access
{
public override string Name => "PresetIdCard";
[DataField("job")]
private string? _jobName;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _jobName, "job", null);
}
void IMapInit.MapInit()
{
if (_jobName == null)

View File

@@ -14,7 +14,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.ActionBlocking
@@ -27,60 +27,70 @@ namespace Content.Server.GameObjects.Components.ActionBlocking
/// The time it takes to apply a <see cref="CuffedComponent"/> to an entity.
/// </summary>
[ViewVariables]
public float CuffTime { get; set; }
[DataField("cuffTime")]
public float CuffTime { get; set; } = 5f;
/// <summary>
/// The time it takes to remove a <see cref="CuffedComponent"/> from an entity.
/// </summary>
[ViewVariables]
public float UncuffTime { get; set; }
[DataField("uncuffTime")]
public float UncuffTime { get; set; } = 5f;
/// <summary>
/// The time it takes for a cuffed entity to remove <see cref="CuffedComponent"/> from itself.
/// </summary>
[ViewVariables]
public float BreakoutTime { get; set; }
[DataField("breakoutTime")]
public float BreakoutTime { get; set; } = 30f;
/// <summary>
/// If an entity being cuffed is stunned, this amount of time is subtracted from the time it takes to add/remove their cuffs.
/// </summary>
[ViewVariables]
public float StunBonus { get; set; }
[DataField("stunBonus")]
public float StunBonus { get; set; } = 2f;
/// <summary>
/// Will the cuffs break when removed?
/// </summary>
[ViewVariables]
[DataField("breakOnRemove")]
public bool BreakOnRemove { get; set; }
/// <summary>
/// The path of the RSI file used for the player cuffed overlay.
/// </summary>
[ViewVariables]
public string? CuffedRSI { get; set; }
[DataField("cuffedRSI")]
public string? CuffedRSI { get; set; } = "Objects/Misc/handcuffs.rsi";
/// <summary>
/// The iconstate used with the RSI file for the player cuffed overlay.
/// </summary>
[ViewVariables]
public string? OverlayIconState { get; set; }
[DataField("bodyIconState")]
public string? OverlayIconState { get; set; } = "body-overlay";
/// <summary>
/// The iconstate used for broken handcuffs
/// </summary>
[ViewVariables]
[DataField("brokenIconState")]
public string? BrokenState { get; set; }
/// <summary>
/// The iconstate used for broken handcuffs
/// </summary>
[ViewVariables]
[DataField("brokenName")]
public string BrokenName { get; set; } = default!;
/// <summary>
/// The iconstate used for broken handcuffs
/// </summary>
[ViewVariables]
[DataField("brokenDesc")]
public string BrokenDesc { get; set; } = default!;
[ViewVariables]
@@ -101,12 +111,21 @@ namespace Content.Server.GameObjects.Components.ActionBlocking
}
}
public string? StartCuffSound { get; set; }
public string? EndCuffSound { get; set; }
public string? StartBreakoutSound { get; set; }
public string? StartUncuffSound { get; set; }
public string? EndUncuffSound { get; set; }
public Color Color { get; set; }
[DataField("startCuffSound")]
public string StartCuffSound { get; set; } = "/Audio/Items/Handcuffs/cuff_start.ogg";
[DataField("endCuffSound")] public string EndCuffSound { get; set; } = "/Audio/Items/Handcuffs/cuff_end.ogg";
[DataField("startBreakoutSound")]
public string StartBreakoutSound { get; set; } = "/Audio/Items/Handcuffs/cuff_breakout_start.ogg";
[DataField("startUncuffSound")]
public string StartUncuffSound { get; set; } = "/Audio/Items/Handcuffs/cuff_takeoff_start.ogg";
[DataField("endUncuffSound")]
public string EndUncuffSound { get; set; } = "/Audio/Items/Handcuffs/cuff_takeoff_end.ogg";
[DataField("color")]
public Color Color { get; set; } = Color.White;
// Non-exposed data fields
private bool _isBroken = false;
@@ -116,27 +135,6 @@ namespace Content.Server.GameObjects.Components.ActionBlocking
/// </summary>
private bool _cuffing;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(this, x => x.CuffTime, "cuffTime", 5.0f);
serializer.DataField(this, x => x.BreakoutTime, "breakoutTime", 30.0f);
serializer.DataField(this, x => x.UncuffTime, "uncuffTime", 5.0f);
serializer.DataField(this, x => x.StunBonus, "stunBonus", 2.0f);
serializer.DataField(this, x => x.StartCuffSound, "startCuffSound", "/Audio/Items/Handcuffs/cuff_start.ogg");
serializer.DataField(this, x => x.EndCuffSound, "endCuffSound", "/Audio/Items/Handcuffs/cuff_end.ogg");
serializer.DataField(this, x => x.StartUncuffSound, "startUncuffSound", "/Audio/Items/Handcuffs/cuff_takeoff_start.ogg");
serializer.DataField(this, x => x.EndUncuffSound, "endUncuffSound", "/Audio/Items/Handcuffs/cuff_takeoff_end.ogg");
serializer.DataField(this, x => x.StartBreakoutSound, "startBreakoutSound", "/Audio/Items/Handcuffs/cuff_breakout_start.ogg");
serializer.DataField(this, x => x.CuffedRSI, "cuffedRSI", "Objects/Misc/handcuffs.rsi");
serializer.DataField(this, x => x.OverlayIconState, "bodyIconState", "body-overlay");
serializer.DataField(this, x => x.Color, "color", Color.White);
serializer.DataField(this, x => x.BreakOnRemove, "breakOnRemove", false);
serializer.DataField(this, x => x.BrokenState, "brokenIconState", string.Empty);
serializer.DataField(this, x => x.BrokenName, "brokenName", string.Empty);
serializer.DataField(this, x => x.BrokenDesc, "brokenDesc", string.Empty);
}
public override ComponentState GetComponentState(ICommonSession player)
{
return new HandcuffedComponentState(Broken ? BrokenState : string.Empty);

View File

@@ -7,7 +7,7 @@ using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Interactable;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components
@@ -18,21 +18,16 @@ namespace Content.Server.GameObjects.Components
public override string Name => "Anchorable";
[ViewVariables]
[DataField("tool")]
public ToolQuality Tool { get; private set; } = ToolQuality.Anchoring;
[ViewVariables]
int IInteractUsing.Priority => 1;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("snap")]
public bool Snap { get; private set; }
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(this, x => x.Tool, "tool", ToolQuality.Anchoring);
serializer.DataField(this, x => x.Snap, "snap", false);
}
/// <summary>
/// Checks if a tool can change the anchored status.
/// </summary>

View File

@@ -13,8 +13,10 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Arcade
@@ -36,33 +38,23 @@ namespace Content.Server.GameObjects.Components.Arcade
[ViewVariables] private bool _enemyInvincibilityFlag;
[ViewVariables] private SpaceVillainGame _game = null!;
[ViewVariables(VVAccess.ReadWrite)] private List<string> _possibleFightVerbs = null!;
[ViewVariables(VVAccess.ReadWrite)] private List<string> _possibleFirstEnemyNames = null!;
[ViewVariables(VVAccess.ReadWrite)] private List<string> _possibleLastEnemyNames = null!;
[ViewVariables(VVAccess.ReadWrite)] private List<string> _possibleRewards = null!;
public override void ExposeData(ObjectSerializer serializer)
[ViewVariables(VVAccess.ReadWrite)] [DataField("possibleFightVerbs")] private List<string> _possibleFightVerbs = new List<string>()
{"Defeat", "Annihilate", "Save", "Strike", "Stop", "Destroy", "Robust", "Romance", "Pwn", "Own"};
[ViewVariables(VVAccess.ReadWrite)] [DataField("possibleFirstEnemyNames")] private List<string> _possibleFirstEnemyNames = new List<string>(){
"the Automatic", "Farmer", "Lord", "Professor", "the Cuban", "the Evil", "the Dread King",
"the Space", "Lord", "the Great", "Duke", "General"
};
[ViewVariables(VVAccess.ReadWrite)] [DataField("possibleLastEnemyNames")] private List<string> _possibleLastEnemyNames = new List<string>()
{
serializer.DataField(ref _possibleFightVerbs, "possibleFightVerbs", new List<string>()
{"Defeat", "Annihilate", "Save", "Strike", "Stop", "Destroy", "Robust", "Romance", "Pwn", "Own"});
serializer.DataField(ref _possibleFirstEnemyNames, "possibleFirstEnemyNames", new List<string>(){
"the Automatic", "Farmer", "Lord", "Professor", "the Cuban", "the Evil", "the Dread King",
"the Space", "Lord", "the Great", "Duke", "General"
});
serializer.DataField(ref _possibleLastEnemyNames, "possibleLastEnemyNames", new List<string>()
{
"Melonoid", "Murdertron", "Sorcerer", "Ruin", "Jeff", "Ectoplasm", "Crushulon", "Uhangoid",
"Vhakoid", "Peteoid", "slime", "Griefer", "ERPer", "Lizard Man", "Unicorn"
});
serializer.DataField(ref _possibleRewards, "possibleRewards", new List<string>()
{
"ToyMouse", "ToyAi", "ToyNuke", "ToyAssistant", "ToyGriffin", "ToyHonk", "ToyIan",
"ToyMarauder", "ToyMauler", "ToyGygax", "ToyOdysseus", "ToyOwlman", "ToyDeathRipley",
"ToyPhazon", "ToyFireRipley", "ToyReticence", "ToyRipley", "ToySeraph", "ToyDurand", "ToySkeleton"
});
_game = new SpaceVillainGame(this);
}
"Melonoid", "Murdertron", "Sorcerer", "Ruin", "Jeff", "Ectoplasm", "Crushulon", "Uhangoid",
"Vhakoid", "Peteoid", "slime", "Griefer", "ERPer", "Lizard Man", "Unicorn"
};
[ViewVariables(VVAccess.ReadWrite)] [DataField("possibleRewards")] private List<string> _possibleRewards = new List<string>()
{
"ToyMouse", "ToyAi", "ToyNuke", "ToyAssistant", "ToyGriffin", "ToyHonk", "ToyIan",
"ToyMarauder", "ToyMauler", "ToyGygax", "ToyOdysseus", "ToyOwlman", "ToyDeathRipley",
"ToyPhazon", "ToyFireRipley", "ToyReticence", "ToyRipley", "ToySeraph", "ToyDurand", "ToySkeleton"
};
void IActivate.Activate(ActivateEventArgs eventArgs)
{
@@ -76,6 +68,8 @@ namespace Content.Server.GameObjects.Components.Arcade
}
if(!ActionBlockerSystem.CanInteract(actor.playerSession.AttachedEntity)) return;
_game ??= new SpaceVillainGame(this);
if (_wiresComponent?.IsPanelOpen == true)
{
_wiresComponent.OpenInterface(actor.playerSession);

View File

@@ -5,7 +5,7 @@ using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Atmos
@@ -18,17 +18,25 @@ namespace Content.Server.GameObjects.Components.Atmos
public override string Name => "Airtight";
[DataFieldWithFlag("airBlockedDirection", typeof(AtmosDirectionFlags))]
[ViewVariables]
private int _initialAirBlockedDirection;
[ViewVariables]
private int _currentAirBlockedDirection;
private bool _airBlocked = true;
private bool _fixVacuum;
private int _initialAirBlockedDirection = (int) AtmosDirection.All;
[ViewVariables]
private int _currentAirBlockedDirection;
[DataField("airBlocked")]
private bool _airBlocked = true;
[DataField("fixVacuum")]
private bool _fixVacuum = true;
[ViewVariables]
[DataField("rotateAirBlocked")]
private bool _rotateAirBlocked = true;
[ViewVariables]
[DataField("fixAirBlockedDirectionInitialize")]
private bool _fixAirBlockedDirectionInitialize = true;
[ViewVariables(VVAccess.ReadWrite)]
@@ -58,17 +66,6 @@ namespace Content.Server.GameObjects.Components.Atmos
[ViewVariables]
public bool FixVacuum => _fixVacuum;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _airBlocked, "airBlocked", true);
serializer.DataField(ref _fixVacuum, "fixVacuum", true);
serializer.DataField(ref _initialAirBlockedDirection, "airBlockedDirection", (int)AtmosDirection.All, WithFormat.Flags<AtmosDirectionFlags>());
serializer.DataField(ref _rotateAirBlocked, "rotateAirBlocked", true);
serializer.DataField(ref _fixAirBlockedDirectionInitialize, "fixAirBlockedDirectionInitialize", true);
}
public override void Initialize()
{
base.Initialize();

View File

@@ -3,7 +3,7 @@ using Content.Server.GameObjects.Components.Body.Respiratory;
using Content.Shared.GameObjects.Components.Inventory;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.GameObjects.Components.Atmos
{
@@ -16,18 +16,13 @@ namespace Content.Server.GameObjects.Components.Atmos
/// <summary>
/// Tool is functional only in allowed slots
/// </summary>
private EquipmentSlotDefines.SlotFlags _allowedSlots;
[DataField("allowedSlots")]
private EquipmentSlotDefines.SlotFlags _allowedSlots = EquipmentSlotDefines.SlotFlags.MASK;
public override string Name => "BreathMask";
public bool IsFunctional { get; private set; }
public IEntity? ConnectedInternalsEntity { get; private set; }
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _allowedSlots, "allowedSlots", EquipmentSlotDefines.SlotFlags.MASK);
}
protected override void Shutdown()
{
base.Shutdown();

View File

@@ -15,7 +15,7 @@ using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Server.GameObjects;
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.Atmos
@@ -33,18 +33,13 @@ namespace Content.Server.GameObjects.Components.Atmos
public float FireStacks { get; private set; }
[ViewVariables(VVAccess.ReadWrite)]
[DataField("fireSpread")]
public bool FireSpread { get; private set; } = false;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("canResistFire")]
public bool CanResistFire { get; private set; } = false;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(this, x => x.FireSpread, "fireSpread", false);
serializer.DataField(this, x => x.CanResistFire, "canResistFire", false);
}
public void Ignite()
{
if (FireStacks > 0 && !OnFire)

View File

@@ -1,18 +1,18 @@
#nullable enable
using System;
using System.Linq;
using Content.Server.Atmos;
using Content.Server.GameObjects.Components.Atmos.Piping;
using Content.Server.Interfaces;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using System.Linq;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Atmos;
using Content.Shared.Interfaces.GameObjects.Components;
using Content.Shared.Atmos;
using Content.Shared.GameObjects.Components.Atmos;
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Atmos
{
@@ -37,7 +37,8 @@ namespace Content.Server.GameObjects.Components.Atmos
/// What <see cref="GasMixture"/> the canister contains.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public GasMixture Air { get; set; } = default!;
[DataField("gasMixture")]
public GasMixture Air { get; set; } = new (DefaultVolume);
[ViewVariables]
public bool Anchored => !Owner.TryGetComponent<IPhysicsComponent>(out var physics) || physics.Anchored;
@@ -51,7 +52,7 @@ namespace Content.Server.GameObjects.Components.Atmos
[ViewVariables]
public bool ConnectedToPort => ConnectedPort != null;
private const float DefaultVolume = 10;
public const float DefaultVolume = 10;
[ViewVariables(VVAccess.ReadWrite)] public float ReleasePressure { get; set; }
@@ -67,13 +68,6 @@ namespace Content.Server.GameObjects.Components.Atmos
private AppearanceComponent? _appearance;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(this, x => Air, "gasMixture", new GasMixture(DefaultVolume));
}
public override void Initialize()
{
base.Initialize();

View File

@@ -1,7 +1,9 @@
using Content.Server.Atmos;
using Content.Server.Interfaces;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Atmos
@@ -11,15 +13,6 @@ namespace Content.Server.GameObjects.Components.Atmos
{
public override string Name => "GasMixtureHolder";
[ViewVariables] public GasMixture Air { get; set; }
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
Air = new GasMixture();
serializer.DataField(this, x => x.Air, "air", new GasMixture());
}
[ViewVariables] [DataField("air")] public GasMixture Air { get; set; } = new GasMixture();
}
}

View File

@@ -20,7 +20,7 @@ using Robust.Server.Player;
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.Utility;
using Robust.Shared.ViewVariables;
@@ -33,7 +33,8 @@ namespace Content.Server.GameObjects.Components.Atmos
private const float MaxExplosionRange = 14f;
private const float DefaultOutputPressure = Atmospherics.OneAtmosphere;
private float _pressureResistance;
[DataField("pressureResistance")]
private float _pressureResistance = Atmospherics.OneAtmosphere * 5f;
private int _integrity = 3;
@@ -41,12 +42,14 @@ namespace Content.Server.GameObjects.Components.Atmos
[ViewVariables] private BoundUserInterface? _userInterface;
[ViewVariables] public GasMixture? Air { get; set; }
[DataField("air")] [ViewVariables] public GasMixture? Air { get; set; } = new();
/// <summary>
/// Distributed pressure.
/// </summary>
[ViewVariables] public float OutputPressure { get; private set; }
[DataField("outputPressure")]
[ViewVariables]
public float OutputPressure { get; private set; } = DefaultOutputPressure;
/// <summary>
/// Tank is connected to internals.
@@ -61,21 +64,25 @@ namespace Content.Server.GameObjects.Components.Atmos
/// <summary>
/// Pressure at which tanks start leaking.
/// </summary>
[DataField("tankLeakPressure")]
public float TankLeakPressure { get; set; } = 30 * Atmospherics.OneAtmosphere;
/// <summary>
/// Pressure at which tank spills all contents into atmosphere.
/// </summary>
[DataField("tankRupturePressure")]
public float TankRupturePressure { get; set; } = 40 * Atmospherics.OneAtmosphere;
/// <summary>
/// Base 3x3 explosion.
/// </summary>
[DataField("tankFragmentPressure")]
public float TankFragmentPressure { get; set; } = 50 * Atmospherics.OneAtmosphere;
/// <summary>
/// Increases explosion for each scale kPa above threshold.
/// </summary>
[DataField("tankFragmentScale")]
public float TankFragmentScale { get; set; } = 10 * Atmospherics.OneAtmosphere;
public override void Initialize()
@@ -94,19 +101,6 @@ namespace Content.Server.GameObjects.Components.Atmos
UpdateUserInterface(true);
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(this, x => x.Air, "air", new GasMixture());
serializer.DataField(this, x => x.OutputPressure, "outputPressure", DefaultOutputPressure);
serializer.DataField(this, x => x.TankLeakPressure, "tankLeakPressure", 30 * Atmospherics.OneAtmosphere);
serializer.DataField(this, x => x.TankRupturePressure, "tankRupturePressure", 40 * Atmospherics.OneAtmosphere);
serializer.DataField(this, x => x.TankFragmentPressure, "tankFragmentPressure", 50 * Atmospherics.OneAtmosphere);
serializer.DataField(this, x => x.TankFragmentScale, "tankFragmentScale", 10 * Atmospherics.OneAtmosphere);
serializer.DataField(ref _pressureResistance, "pressureResistance", Atmospherics.OneAtmosphere * 5f);
}
public void Examine(FormattedMessage message, bool inDetailsRange)
{
message.AddMarkup(Loc.GetString("gas-tank-examine", ("pressure", Math.Round(Air?.Pressure ?? 0))));
@@ -355,10 +349,9 @@ namespace Content.Server.GameObjects.Components.Atmos
}
[UsedImplicitly]
[DataDefinition]
public class ToggleInternalsAction : IToggleItemAction
{
void IExposeData.ExposeData(ObjectSerializer serializer) {}
public bool DoToggleAction(ToggleItemActionEventArgs args)
{
if (!args.Item.TryGetComponent<GasTankComponent>(out var gasTankComponent)) return false;

View File

@@ -1,4 +1,5 @@
#nullable enable
// ReSharper disable once RedundantUsingDirective
using System;
using System.Collections;
using System.Collections.Generic;
@@ -13,12 +14,15 @@ using Content.Shared.Atmos;
using Content.Shared.Maps;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Timing;
using Robust.Shared.ViewVariables;
using Dependency = Robust.Shared.IoC.DependencyAttribute;
namespace Content.Server.GameObjects.Components.Atmos
{
@@ -27,11 +31,11 @@ namespace Content.Server.GameObjects.Components.Atmos
/// </summary>
[ComponentReference(typeof(IGridAtmosphereComponent))]
[RegisterComponent, Serializable]
public class GridAtmosphereComponent : Component, IGridAtmosphereComponent
public class GridAtmosphereComponent : Component, IGridAtmosphereComponent, ISerializationHooks
{
[Robust.Shared.IoC.Dependency] private IMapManager _mapManager = default!;
[Robust.Shared.IoC.Dependency] private ITileDefinitionManager _tileDefinitionManager = default!;
[Robust.Shared.IoC.Dependency] private IServerEntityManager _serverEntityManager = default!;
[Dependency] private IMapManager _mapManager = default!;
[Dependency] private ITileDefinitionManager _tileDefinitionManager = default!;
[Dependency] private IServerEntityManager _serverEntityManager = default!;
public GridTileLookupSystem GridTileLookupSystem { get; private set; } = default!;
internal GasTileOverlaySystem GasTileOverlaySystem { get; private set; } = default!;
@@ -44,12 +48,12 @@ namespace Content.Server.GameObjects.Components.Atmos
public override string Name => "GridAtmosphere";
private bool _paused = false;
private float _timer = 0f;
private bool _paused;
private float _timer;
private Stopwatch _stopwatch = new();
private GridId _gridId;
[ComponentDependency] private IMapGridComponent? _mapGridComponent = default!;
[ComponentDependency] private IMapGridComponent? _mapGridComponent;
[ViewVariables]
public int UpdateCounter { get; private set; } = 0;
@@ -66,6 +70,12 @@ namespace Content.Server.GameObjects.Components.Atmos
[ViewVariables]
private double _excitedGroupLastProcess;
[DataField("uniqueMixes")]
private List<GasMixture>? _uniqueMixes;
[DataField("tiles")]
private Dictionary<Vector2i, int>? _tiles;
[ViewVariables]
protected readonly Dictionary<Vector2i, TileAtmosphere> Tiles = new(1000);
@@ -138,6 +148,11 @@ namespace Content.Server.GameObjects.Components.Atmos
[ViewVariables]
private ProcessState _state = ProcessState.TileEqualize;
public GridAtmosphereComponent()
{
_paused = false;
}
private enum ProcessState
{
TileEqualize,
@@ -158,9 +173,59 @@ namespace Content.Server.GameObjects.Components.Atmos
indices.PryTile(_gridId, _mapManager, _tileDefinitionManager, _serverEntityManager);
}
void ISerializationHooks.BeforeSerialization()
{
var uniqueMixes = new List<GasMixture>();
var uniqueMixHash = new Dictionary<GasMixture, int>();
var tiles = new Dictionary<Vector2i, int>();
foreach (var (indices, tile) in Tiles)
{
if (tile.Air == null) continue;
if (uniqueMixHash.TryGetValue(tile.Air, out var index))
{
tiles[indices] = index;
continue;
}
uniqueMixes.Add(tile.Air);
var newIndex = uniqueMixes.Count - 1;
uniqueMixHash[tile.Air] = newIndex;
tiles[indices] = newIndex;
}
if (uniqueMixes.Count == 0) uniqueMixes = null;
if (tiles.Count == 0) tiles = null;
_uniqueMixes = uniqueMixes;
_tiles = tiles;
}
public override void Initialize()
{
base.Initialize();
Tiles.Clear();
if (_tiles != null && Owner.TryGetComponent(out IMapGridComponent? mapGrid))
{
foreach (var (indices, mix) in _tiles)
{
try
{
Tiles.Add(indices, new TileAtmosphere(this, mapGrid.GridIndex, indices, (GasMixture) _uniqueMixes![mix].Clone()));
}
catch (ArgumentOutOfRangeException)
{
Logger.Error($"Error during atmos serialization! Tile at {indices} points to an unique mix ({mix}) out of range!");
throw;
}
Invalidate(indices);
}
}
GridTileLookupSystem = EntitySystem.Get<GridTileLookupSystem>();
GasTileOverlaySystem = EntitySystem.Get<GasTileOverlaySystem>();
AtmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
@@ -840,60 +905,6 @@ namespace Content.Server.GameObjects.Components.Atmos
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
if (serializer.Reading && Owner.TryGetComponent(out IMapGridComponent? mapGrid))
{
var gridId = mapGrid.Grid.Index;
if (!serializer.TryReadDataField("uniqueMixes", out List<GasMixture>? uniqueMixes) ||
!serializer.TryReadDataField("tiles", out Dictionary<Vector2i, int>? tiles))
return;
Tiles.Clear();
foreach (var (indices, mix) in tiles!)
{
try
{
Tiles.Add(indices, new TileAtmosphere(this, gridId, indices, (GasMixture)uniqueMixes![mix].Clone()));
}
catch (ArgumentOutOfRangeException)
{
Logger.Error($"Error during atmos serialization! Tile at {indices} points to an unique mix ({mix}) out of range!");
throw;
}
Invalidate(indices);
}
}
else if (serializer.Writing)
{
var uniqueMixes = new List<GasMixture>();
var uniqueMixHash = new Dictionary<GasMixture, int>();
var tiles = new Dictionary<Vector2i, int>();
foreach (var (indices, tile) in Tiles)
{
if (tile.Air == null) continue;
if (uniqueMixHash.TryGetValue(tile.Air, out var index))
{
tiles[indices] = index;
continue;
}
uniqueMixes.Add(tile.Air);
var newIndex = uniqueMixes.Count - 1;
uniqueMixHash[tile.Air] = newIndex;
tiles[indices] = newIndex;
}
serializer.DataField(ref uniqueMixes, "uniqueMixes", new List<GasMixture>());
serializer.DataField(ref tiles, "tiles", new Dictionary<Vector2i, int>());
}
}
public IEnumerator<TileAtmosphere> GetEnumerator()
{
return Tiles.Values.GetEnumerator();
@@ -910,4 +921,16 @@ namespace Content.Server.GameObjects.Components.Atmos
// TODO ATMOS
}
}
public struct IntermediateTileAtmosphere
{
public readonly Vector2i Indices;
public readonly GasMixture GasMixture;
public IntermediateTileAtmosphere(Vector2i indices, GasMixture gasMixture)
{
Indices = indices;
GasMixture = gasMixture;
}
}
}

View File

@@ -1,7 +1,7 @@
#nullable enable
using System.Diagnostics.CodeAnalysis;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Atmos
@@ -12,21 +12,16 @@ namespace Content.Server.GameObjects.Components.Atmos
public override string Name => "MovedByPressure";
[ViewVariables(VVAccess.ReadWrite)]
[DataField("enabled")]
public bool Enabled { get; set; } = true;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("pressureResistance")]
public float PressureResistance { get; set; } = 1f;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("moveResist")]
public float MoveResist { get; set; } = 100f;
[ViewVariables(VVAccess.ReadWrite)]
public int LastHighPressureMovementAirCycle { get; set; } = 0;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(this, x => x.Enabled, "enabled", true);
serializer.DataField(this, x => PressureResistance, "pressureResistance", 1f);
serializer.DataField(this, x => MoveResist, "moveResist", 100f);
}
}
public static class MovedByPressureExtensions

View File

@@ -1,4 +1,6 @@
#nullable enable
using System;
using System.Linq;
using Content.Server.Atmos;
using Content.Server.GameObjects.Components.NodeContainer;
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
@@ -7,12 +9,10 @@ using Content.Shared.GameObjects.Components.Atmos;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Log;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
using System;
using System.Linq;
namespace Content.Server.GameObjects.Components.Atmos.Piping.Filters
namespace Content.Server.GameObjects.Components.Atmos.Piping
{
[RegisterComponent]
public class GasFilterComponent : Component
@@ -44,7 +44,8 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Filters
UpdateAppearance();
}
}
private Gas _gasToFilter;
[DataField("gasToFilter")] private Gas _gasToFilter = Gas.Plasma;
[ViewVariables(VVAccess.ReadWrite)]
public int VolumeFilterRate
@@ -52,6 +53,8 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Filters
get => _volumeFilterRate;
set => _volumeFilterRate = Math.Clamp(value, 0, MaxVolumeFilterRate);
}
[DataField("startingVolumePumpRate")]
private int _volumeFilterRate;
[ViewVariables(VVAccess.ReadWrite)]
@@ -60,22 +63,23 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Filters
get => _maxVolumeFilterRate;
set => Math.Max(value, 0);
}
private int _maxVolumeFilterRate;
[ViewVariables]
private PipeDirection _initialInletDirection;
[DataField("maxVolumePumpRate")] private int _maxVolumeFilterRate = 100;
[DataField("inletDirection")] [ViewVariables]
private PipeDirection _initialInletDirection = PipeDirection.None;
/// <summary>
/// The direction the filtered-out gas goes.
/// </summary>
[ViewVariables]
private PipeDirection _initialFilterOutletDirection;
[DataField("filterOutletDirection")] [ViewVariables]
private PipeDirection _initialFilterOutletDirection = PipeDirection.None;
/// <summary>
/// The direction the rest of the gas goes.
/// </summary>
[ViewVariables]
private PipeDirection _initialOutletDirection;
[DataField("outletDirection")] [ViewVariables]
private PipeDirection _initialOutletDirection = PipeDirection.None;
[ViewVariables]
private PipeNode? _inletPipe;
@@ -89,17 +93,6 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Filters
[ComponentDependency]
private readonly AppearanceComponent? _appearance = default;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _volumeFilterRate, "startingVolumePumpRate", 0);
serializer.DataField(ref _maxVolumeFilterRate, "maxVolumePumpRate", 100);
serializer.DataField(ref _gasToFilter, "gasToFilter", Gas.Plasma);
serializer.DataField(ref _initialInletDirection, "inletDirection", PipeDirection.None);
serializer.DataField(ref _initialFilterOutletDirection, "filterOutletDirection", PipeDirection.None);
serializer.DataField(ref _initialOutletDirection, "outletDirection", PipeDirection.None);
}
public override void Initialize()
{
base.Initialize();

View File

@@ -1,12 +1,12 @@
#nullable enable
using System.Linq;
using Content.Server.GameObjects.Components.NodeContainer;
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
using Content.Shared.Atmos;
using Robust.Shared.GameObjects;
using Robust.Shared.Log;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
using System.Linq;
namespace Content.Server.GameObjects.Components.Atmos.Piping
{
@@ -21,26 +21,30 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
/// <summary>
/// If the generator is producing gas.
/// </summary>
[DataField("generatorEnabled")]
[ViewVariables(VVAccess.ReadWrite)]
public bool GeneratorEnabled { get; set; }
public bool GeneratorEnabled { get; set; } = true;
/// <summary>
/// What gas is being generated.
/// </summary>
[DataField("generatedGas")]
[ViewVariables(VVAccess.ReadWrite)]
public Gas GeneratedGas { get; set; }
public Gas GeneratedGas { get; set; } = Gas.Oxygen;
/// <summary>
/// Molar rate of gas generation.
/// </summary>
[DataField("gasGenerationRate")]
[ViewVariables(VVAccess.ReadWrite)]
public float GasGenerationRate { get; set; }
public float GasGenerationRate { get; set; } = 10;
/// <summary>
/// The pipe pressure above which the generator stops producing gas.
/// </summary>
[DataField("generatorPressureCap")]
[ViewVariables(VVAccess.ReadWrite)]
public float GeneratorPressureCap { get; set; }
public float GeneratorPressureCap { get; set; } = 10;
/// <summary>
/// The pipe to which generated gas is added.
@@ -48,15 +52,6 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
[ViewVariables]
private PipeNode? Pipe { get; set; }
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(this, x => x.GeneratorEnabled, "generatorEnabled", true);
serializer.DataField(this, x => x.GeneratedGas, "generatedGas", Gas.Oxygen);
serializer.DataField(this, x => x.GasGenerationRate, "gasGenerationRate", 10);
serializer.DataField(this, x => x.GeneratorPressureCap, "generatorPressureCap", 10);
}
public override void Initialize()
{
base.Initialize();

View File

@@ -8,7 +8,9 @@ using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
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.Atmos.Piping.Pumps
@@ -31,19 +33,23 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Pumps
UpdateAppearance();
}
}
[DataField("pumpEnabled")]
private bool _pumpEnabled;
/// <summary>
/// Needs to be same <see cref="PipeDirection"/> as that of a <see cref="PipeNode"/> on this entity.
/// </summary>
[ViewVariables]
private PipeDirection _initialInletDirection;
[DataField("initialInletDirection")]
private PipeDirection _initialInletDirection = PipeDirection.None;
/// <summary>
/// Needs to be same <see cref="PipeDirection"/> as that of a <see cref="PipeNode"/> on this entity.
/// </summary>
[ViewVariables]
private PipeDirection _initialOutletDirection;
[DataField("initialOutletDirection")]
private PipeDirection _initialOutletDirection = PipeDirection.None;
[ViewVariables]
private PipeNode? _inletPipe;
@@ -53,14 +59,6 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Pumps
private AppearanceComponent? _appearance;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _initialInletDirection, "inletDirection", PipeDirection.None);
serializer.DataField(ref _initialOutletDirection, "outletDirection", PipeDirection.None);
serializer.DataField(ref _pumpEnabled, "pumpEnabled", false);
}
public override void Initialize()
{
base.Initialize();

View File

@@ -3,7 +3,9 @@ using System;
using Content.Server.Atmos;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Atmos.Piping.Pumps
@@ -24,6 +26,8 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Pumps
get => _pressurePumpTarget;
set => _pressurePumpTarget = Math.Clamp(value, 0, MaxPressurePumpTarget);
}
[DataField("startingPressurePumpTarget")]
private int _pressurePumpTarget;
/// <summary>
@@ -35,7 +39,8 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Pumps
get => _maxPressurePumpTarget;
set => Math.Max(value, 0);
}
private int _maxPressurePumpTarget;
[DataField("maxPressurePumpTarget")]
private int _maxPressurePumpTarget = 100;
/// <summary>
/// Every update, this pump will only increase the outlet pressure by this fraction of the amount needed to reach the <see cref="PressurePumpTarget"/>.
@@ -46,15 +51,8 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Pumps
get => _transferRatio;
set => _transferRatio = Math.Clamp(value, 0, 1);
}
private float _transferRatio;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _pressurePumpTarget, "startingPressurePumpTarget", 0);
serializer.DataField(ref _maxPressurePumpTarget, "maxPressurePumpTarget", 100);
serializer.DataField(ref _transferRatio, "transferRatio", 0.5f);
}
[DataField("transferRatio")]
private float _transferRatio = 0.5f;
protected override void PumpGas(GasMixture inletGas, GasMixture outletGas)
{

View File

@@ -3,7 +3,9 @@ using System;
using Content.Server.Atmos;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Atmos.Piping.Pumps
@@ -19,6 +21,7 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Pumps
get => _volumePumpRate;
set => _volumePumpRate = Math.Clamp(value, 0, MaxVolumePumpRate);
}
[DataField("startingVolumePumpRate")]
private int _volumePumpRate;
[ViewVariables(VVAccess.ReadWrite)]
@@ -27,17 +30,11 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Pumps
get => _maxVolumePumpRate;
set => Math.Max(value, 0);
}
private int _maxVolumePumpRate;
[DataField("maxVolumePumpRate")]
private int _maxVolumePumpRate = 100;
public override string Name => "VolumePump";
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _volumePumpRate, "startingVolumePumpRate", 0);
serializer.DataField(ref _maxVolumePumpRate, "maxVolumePumpRate", 100);
}
protected override void PumpGas(GasMixture inletGas, GasMixture outletGas)
{
var volumeRatio = Math.Clamp(VolumePumpRate / inletGas.Volume, 0, 1);

View File

@@ -3,7 +3,9 @@ using System;
using Content.Server.Atmos;
using Content.Shared.Atmos;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Atmos.Piping.Scrubbers
@@ -23,7 +25,8 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Scrubbers
get => _siphonPressureTarget;
set => _siphonPressureTarget = Math.Max(value, 0);
}
private float _siphonPressureTarget;
[DataField("startingSiphonPressureTarget")]
private float _siphonPressureTarget = Atmospherics.OneAtmosphere * 2;
/// <summary>
/// Every update, this siphon will only decrease the inlet pressure by this fraction of the amount needed to reach the <see cref="SiphonPressureTarget"/>.
@@ -34,14 +37,8 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Scrubbers
get => _transferRatio;
set => _transferRatio = Math.Clamp(value, 0, 1);
}
private float _transferRatio;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _siphonPressureTarget, "startingSiphonPressureTarget", Atmospherics.OneAtmosphere * 2);
serializer.DataField(ref _transferRatio, "transferRatio", 0.5f);
}
[DataField("transferRatio")]
private float _transferRatio = 0.5f;
protected override void ScrubGas(GasMixture inletGas, GasMixture outletGas)
{

View File

@@ -5,6 +5,8 @@ using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using System;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.GameObjects.Components.Atmos.Piping.Vents
{
@@ -23,7 +25,8 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Vents
get => _ventPressureTarget;
set => _ventPressureTarget = Math.Clamp(value, 0, MaxVentPressureTarget);
}
private float _ventPressureTarget;
[DataField("startingVentPressureTarget")]
private float _ventPressureTarget = Atmospherics.OneAtmosphere;
/// <summary>
/// Max value <see cref="VentPressureTarget"/> can be set to.
@@ -34,7 +37,8 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Vents
get => _maxVentPressureTarget;
set => Math.Max(value, 0);
}
private float _maxVentPressureTarget;
[DataField("maxVentPressureTarget")]
private float _maxVentPressureTarget = Atmospherics.OneAtmosphere * 2;
/// <summary>
/// Every update, this vent will only increase the outlet pressure by this fraction of the amount needed to reach the <see cref="VentPressureTarget"/>.
@@ -45,15 +49,8 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Vents
get => _transferRatio;
set => _transferRatio = Math.Clamp(value, 0, 1);
}
private float _transferRatio;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _ventPressureTarget, "startingVentPressureTarget", Atmospherics.OneAtmosphere);
serializer.DataField(ref _maxVentPressureTarget, "maxVentPressureTarget", Atmospherics.OneAtmosphere * 2);
serializer.DataField(ref _transferRatio, "transferRatio", 0.5f);
}
[DataField("transferRatio")]
private float _transferRatio = 0.5f;
protected override void VentGas(GasMixture inletGas, GasMixture outletGas)
{

View File

@@ -1,6 +1,8 @@
using Content.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Atmos
@@ -11,17 +13,11 @@ namespace Content.Server.GameObjects.Components.Atmos
public override string Name => "PressureProtection";
[ViewVariables]
public float HighPressureMultiplier { get; private set; }
[DataField("highPressureMultiplier")]
public float HighPressureMultiplier { get; private set; } = 1f;
[ViewVariables]
public float LowPressureMultiplier { get; private set; }
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(this, x => x.HighPressureMultiplier, "highPressureMultiplier", 1f);
serializer.DataField(this, x => x.LowPressureMultiplier, "lowPressureMultiplier", 1f);
}
[DataField("lowPressureMultiplier")]
public float LowPressureMultiplier { get; private set; } = 1f;
}
}

View File

@@ -2,7 +2,9 @@ using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Random;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components
@@ -10,7 +12,8 @@ namespace Content.Server.GameObjects.Components
[RegisterComponent]
public sealed class AtmosPlaqueComponent : Component, IMapInit
{
private PlaqueType _type;
[DataField("plaqueType")]
private PlaqueType _type = PlaqueType.Unset;
public override string Name => "AtmosPlaque";
[ViewVariables(VVAccess.ReadWrite)]
@@ -89,13 +92,6 @@ namespace Content.Server.GameObjects.Components
}
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _type, "plaqueType", PlaqueType.Unset);
}
public enum PlaqueType
{
Unset = 0,

View File

@@ -9,6 +9,7 @@ using Robust.Shared.Log;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.BarSign
@@ -21,6 +22,7 @@ namespace Content.Server.GameObjects.Components.BarSign
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[DataField("current")]
private string? _currentSign;
[ViewVariables(VVAccess.ReadWrite)]
@@ -98,13 +100,6 @@ namespace Content.Server.GameObjects.Components.BarSign
UpdateSignInfo();
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _currentSign, "current", null);
}
public void MapInit()
{
if (_currentSign != null)

View File

@@ -1,40 +1,44 @@
#nullable enable
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.BarSign
{
[Prototype("barSign")]
public class BarSignPrototype : IPrototype
{
public string ID { get; private set; }
public string Icon { get; private set; }
public string Name { get; private set; }
public string Description { get; private set; }
public bool RenameArea { get; private set; } = true;
public bool Hidden { get; private set; }
private string _description = "";
private string _name = "";
public void LoadFrom(YamlMappingNode mapping)
[ViewVariables]
[field: DataField("id", required: true)]
public string ID { get; } = default!;
[ViewVariables]
[field: DataField("parent")]
public string? Parent { get; }
[DataField("icon")] public string Icon { get; private set; } = "";
[DataField("name")]
public string Name
{
ID = mapping.GetNode("id").AsString();
Name = Loc.GetString(mapping.GetNode("name").AsString());
Icon = mapping.GetNode("icon").AsString();
if (mapping.TryGetNode("hidden", out var node))
{
Hidden = node.AsBool();
}
if (mapping.TryGetNode("renameArea", out node))
{
RenameArea = node.AsBool();
}
if (mapping.TryGetNode("description", out node))
{
Description = Loc.GetString(node.AsString());
}
get => _name;
private set => _name = Loc.GetString(value);
}
[DataField("description")]
public string Description
{
get => _description;
private set => _description = Loc.GetString(value);
}
[DataField("renameArea")]
public bool RenameArea { get; private set; } = true;
[DataField("hidden")]
public bool Hidden { get; private set; }
}
}

View File

@@ -3,9 +3,10 @@ using System.Linq;
using Content.Server.GameObjects.Components.Body.Circulatory;
using Content.Shared.Chemistry;
using Content.Shared.GameObjects.Components.Body.Networks;
using Content.Shared.Interfaces.Chemistry;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Body.Behavior
@@ -27,21 +28,25 @@ namespace Content.Server.GameObjects.Components.Body.Behavior
/// <summary>
/// Modifier for alcohol damage.
/// </summary>
[DataField("alcoholLethality")]
[ViewVariables] private float _alcoholLethality = 0.005f;
/// <summary>
/// Modifier for alcohol damage.
/// </summary>
[DataField("alcoholExponent")]
[ViewVariables] private float _alcoholExponent = 1.6f;
/// <summary>
/// Toxin volume that can be purged without damage.
/// </summary>
[DataField("toxinTolerance")]
[ViewVariables] private float _toxinTolerance = 3f;
/// <summary>
/// Toxin damage modifier.
/// </summary>
[DataField("toxinLethality")]
[ViewVariables] private float _toxinLethality = 0.01f;
/// <summary>
@@ -102,15 +107,5 @@ namespace Content.Server.GameObjects.Components.Body.Behavior
}
}
}
public override void ExposeData(ObjectSerializer serializer)
{
//Uses typical human values for defaults.
base.ExposeData(serializer);
serializer.DataField(ref _alcoholLethality, "alcoholLethality", 0.005f);
serializer.DataField(ref _alcoholExponent, "alcoholExponent", 1.6f);
serializer.DataField(ref _toxinTolerance, "toxinTolerance", 3f);
serializer.DataField(ref _toxinLethality, "toxinLethality", 0.01f);
}
}
}

View File

@@ -10,12 +10,13 @@ using Content.Shared.GameObjects.Components.Body;
using Content.Shared.GameObjects.Components.Mobs.State;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Timing;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Body.Behavior
{
[DataDefinition]
public class LungBehavior : MechanismBehavior
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
@@ -24,43 +25,27 @@ namespace Content.Server.GameObjects.Components.Body.Behavior
[ViewVariables] private TimeSpan _lastGaspPopupTime;
[ViewVariables] public GasMixture Air { get; set; } = default!;
[DataField("air")]
[ViewVariables]
public GasMixture Air { get; set; } = new()
{
Volume = 6,
Temperature = Atmospherics.NormalBodyTemperature
};
[ViewVariables] public float Temperature => Air.Temperature;
[ViewVariables] public float Volume => Air.Volume;
[ViewVariables] public TimeSpan GaspPopupCooldown { get; private set; }
[DataField("gaspPopupCooldown")]
[ViewVariables]
public TimeSpan GaspPopupCooldown { get; private set; } = TimeSpan.FromSeconds(8);
[ViewVariables] public LungStatus Status { get; set; }
[ViewVariables] public float CycleDelay { get; set; }
[DataField("cycleDelay")]
[ViewVariables]
public float CycleDelay { get; set; } = 2;
public override void ExposeData(ObjectSerializer serializer)
public LungBehavior()
{
base.ExposeData(serializer);
Air = new GasMixture {Temperature = Atmospherics.NormalBodyTemperature};
serializer.DataField(this, l => l.CycleDelay, "cycleDelay", 2);
serializer.DataReadWriteFunction(
"volume",
6,
vol => Air.Volume = vol,
() => Air.Volume);
serializer.DataReadWriteFunction(
"temperature",
Atmospherics.NormalBodyTemperature,
temp => Air.Temperature = temp,
() => Air.Temperature);
serializer.DataReadWriteFunction(
"gaspPopupCooldown",
8f,
delay => GaspPopupCooldown = TimeSpan.FromSeconds(delay),
() => GaspPopupCooldown.TotalSeconds);
IoCManager.InjectDependencies(this);
}
protected override void OnAddedToBody(IBody body)

View File

@@ -4,7 +4,6 @@ using Content.Shared.GameObjects.Components.Body.Behavior;
using Content.Shared.GameObjects.Components.Body.Mechanism;
using Content.Shared.GameObjects.Components.Body.Part;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.Components.Body.Behavior
@@ -19,8 +18,6 @@ namespace Content.Server.GameObjects.Components.Body.Behavior
public IEntity Owner => Parent.Owner;
public virtual void ExposeData(ObjectSerializer serializer) { }
public virtual void Initialize(IMechanism parent)
{
Parent = parent;

View File

@@ -7,7 +7,7 @@ using Content.Shared.Chemistry;
using Content.Shared.GameObjects.Components.Body.Networks;
using Content.Shared.GameObjects.Components.Chemistry;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Body.Behavior
@@ -89,15 +89,16 @@ namespace Content.Server.GameObjects.Components.Body.Behavior
/// <summary>
/// Initial internal solution storage volume
/// </summary>
[DataField("maxVolume")]
[ViewVariables]
protected ReagentUnit InitialMaxVolume { get; private set; }
protected ReagentUnit InitialMaxVolume { get; private set; } = ReagentUnit.New(100);
/// <summary>
/// Time in seconds between reagents being ingested and them being
/// transferred to <see cref="SharedBloodstreamComponent"/>
/// </summary>
[ViewVariables]
private float _digestionDelay;
[DataField("digestionDelay")] [ViewVariables]
private float _digestionDelay = 20;
/// <summary>
/// Used to track how long each reagent has been in the stomach
@@ -105,13 +106,6 @@ namespace Content.Server.GameObjects.Components.Body.Behavior
[ViewVariables]
private readonly List<ReagentDelta> _reagentDeltas = new();
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(this, s => s.InitialMaxVolume, "maxVolume", ReagentUnit.New(100));
serializer.DataField(ref _digestionDelay, "digestionDelay", 20);
}
public override void Startup()
{
base.Startup();

View File

@@ -7,7 +7,9 @@ using Content.Shared.Atmos;
using Content.Shared.Chemistry;
using Content.Shared.GameObjects.Components.Body.Networks;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Body.Circulatory
@@ -21,7 +23,8 @@ namespace Content.Server.GameObjects.Components.Body.Circulatory
/// <summary>
/// Max volume of internal solution storage
/// </summary>
[ViewVariables] private ReagentUnit _initialMaxVolume;
[DataField("maxVolume")]
[ViewVariables] private ReagentUnit _initialMaxVolume = ReagentUnit.New(250);
/// <summary>
/// Internal solution for reagent storage
@@ -33,7 +36,9 @@ namespace Content.Server.GameObjects.Components.Body.Circulatory
/// </summary>
[ViewVariables] public ReagentUnit EmptyVolume => _internalSolution.EmptyVolume;
[ViewVariables] public GasMixture Air { get; set; }
[ViewVariables]
public GasMixture Air { get; set; } = new(6)
{Temperature = Atmospherics.NormalBodyTemperature};
[ViewVariables] public SolutionContainerComponent Solution => _internalSolution;
@@ -45,15 +50,6 @@ namespace Content.Server.GameObjects.Components.Body.Circulatory
_internalSolution.MaxVolume = _initialMaxVolume;
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
Air = new GasMixture(6) {Temperature = Atmospherics.NormalBodyTemperature};
serializer.DataField(ref _initialMaxVolume, "maxVolume", ReagentUnit.New(250));
}
/// <summary>
/// Attempt to transfer provided solution to internal solution.
/// Only supports complete transfers

View File

@@ -16,7 +16,9 @@ using Robust.Server.Player;
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.Body.Surgery
@@ -33,13 +35,15 @@ namespace Content.Server.GameObjects.Components.Body.Surgery
private readonly Dictionary<int, object> _optionsCache = new();
private float _baseOperateTime;
[DataField("baseOperateTime")]
private float _baseOperateTime = 5;
private ISurgeon.MechanismRequestCallback? _callbackCache;
private int _idHash;
private SurgeryType _surgeryType;
[DataField("surgeryType")]
private SurgeryType _surgeryType = SurgeryType.Incision;
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(SurgeryUIKey.Key);
@@ -141,14 +145,6 @@ namespace Content.Server.GameObjects.Components.Body.Surgery
}
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _surgeryType, "surgeryType", SurgeryType.Incision);
serializer.DataField(ref _baseOperateTime, "baseOperateTime", 5);
}
public override void Initialize()
{
base.Initialize();

View File

@@ -28,6 +28,7 @@ using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -52,6 +53,7 @@ namespace Content.Server.GameObjects.Components.Botany
[ViewVariables(VVAccess.ReadWrite)] private bool _updateSpriteAfterUpdate;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("drawWarnings")]
public bool DrawWarnings { get; private set; } = false;
[ViewVariables(VVAccess.ReadWrite)]
@@ -124,12 +126,6 @@ namespace Content.Server.GameObjects.Components.Botany
Owner.EnsureComponentWarn<SolutionContainerComponent>();
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(this, x => x.DrawWarnings, "drawWarnings", false);
}
public void WeedInvasion()
{
// TODO

View File

@@ -1,4 +1,5 @@
using Content.Server.Botany;
#nullable enable
using Content.Server.Botany;
using Content.Server.GameObjects.Components.Chemistry;
using Content.Shared.Chemistry;
using Robust.Server.GameObjects;
@@ -7,39 +8,36 @@ using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Botany
{
[RegisterComponent]
public class ProduceComponent : Component
public class ProduceComponent : Component, ISerializationHooks
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override string Name => "Produce";
[DataField("seed")]
private string? _seedName;
[ViewVariables]
public Seed Seed { get; set; } = null;
public float Potency => Seed.Potency;
public override void ExposeData(ObjectSerializer serializer)
public Seed? Seed
{
base.ExposeData(serializer);
serializer.DataReadFunction<string>("seed", null,
(s) =>
{
if(!string.IsNullOrEmpty(s))
Seed = _prototypeManager.Index<Seed>(s);
});
get => _seedName != null ? IoCManager.Resolve<IPrototypeManager>().Index<Seed>(_seedName) : null;
set => _seedName = value?.ID;
}
public float Potency => Seed?.Potency ?? 0;
public void Grown()
{
if (Seed == null)
return;
if (Owner.TryGetComponent(out SpriteComponent sprite))
if (Owner.TryGetComponent(out SpriteComponent? sprite))
{
sprite.LayerSetRSI(0, Seed.PlantRsi);
sprite.LayerSetState(0, Seed.PlantIconState);

View File

@@ -1,10 +1,12 @@
using Content.Server.Botany;
#nullable enable
using Content.Server.Botany;
using Content.Shared.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -16,19 +18,15 @@ namespace Content.Server.GameObjects.Components.Botany
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override string Name => "Seed";
[DataField("seed")]
private string? _seedName;
[ViewVariables]
public Seed Seed { get; set; } = null;
public override void ExposeData(ObjectSerializer serializer)
public Seed? Seed
{
base.ExposeData(serializer);
serializer.DataReadFunction<string>("seed", null,
(s) =>
{
if(!string.IsNullOrEmpty(s))
Seed = _prototypeManager.Index<Seed>(s);
});
get => _seedName != null ? IoCManager.Resolve<IPrototypeManager>().Index<Seed>(_seedName) : null;
set => _seedName = value?.ID;
}
public void Examine(FormattedMessage message, bool inDetailsRange)

View File

@@ -22,7 +22,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Timing;
using Robust.Shared.ViewVariables;
@@ -42,14 +42,16 @@ namespace Content.Server.GameObjects.Components.Buckle
[ComponentDependency] private readonly StunnableComponent? _stunnable = null;
[ComponentDependency] private readonly MobStateComponent? _mobState = null;
private int _size;
[DataField("size")]
private int _size = 100;
/// <summary>
/// The amount of time that must pass for this entity to
/// be able to unbuckle after recently buckling.
/// </summary>
[DataField("delay")]
[ViewVariables]
private TimeSpan _unbuckleDelay;
private TimeSpan _unbuckleDelay = TimeSpan.FromSeconds(0.25f);
/// <summary>
/// The time that this entity buckled at.
@@ -383,19 +385,6 @@ namespace Content.Server.GameObjects.Components.Buckle
return TryBuckle(user, to);
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _size, "size", 100);
serializer.DataReadWriteFunction(
"cooldown",
0.25f,
seconds => _unbuckleDelay = TimeSpan.FromSeconds(seconds),
() => (float) _unbuckleDelay.TotalSeconds);
}
protected override void Startup()
{
base.Startup();

View File

@@ -14,6 +14,9 @@ using Robust.Shared.ViewVariables;
using System.Collections.Generic;
using Robust.Server.GameObjects;
using Robust.Shared.Map;
using System.Linq;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.GameObjects.Components.Cargo
{
@@ -55,6 +58,7 @@ namespace Content.Server.GameObjects.Components.Cargo
}
}
[DataField("requestOnly")]
private bool _requestOnly = false;
private bool Powered => !Owner.TryGetComponent(out PowerReceiverComponent? receiver) || receiver.Powered;
@@ -88,16 +92,6 @@ namespace Content.Server.GameObjects.Components.Cargo
base.OnRemove();
}
/// <summary>
/// Reads data from YAML
/// </summary>
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _requestOnly, "requestOnly", false);
}
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage serverMsg)
{
if (!Owner.TryGetComponent(out CargoOrderDatabaseComponent? orders))

View File

@@ -20,6 +20,9 @@ using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Chemistry

Some files were not shown because too many files have changed in this diff Show More