Skip to content

Commit

Permalink
i was unable to get it working
Browse files Browse the repository at this point in the history
  • Loading branch information
RedFoxIV committed Jan 15, 2025
1 parent 77ea955 commit 9425dfd
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions Content.Shared/Mobs/Components/MobStateComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Content.Shared.Mobs.Components;
public sealed partial class MobStateComponent : Component
{

[DataField("mobStateParams", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<MobStateParametersPrototype>))]
[DataField("mobStateParams")]
public Dictionary<string, string> InitMobStateParams = new()
{
{"Alive", "AliveDefault" },
Expand Down Expand Up @@ -191,32 +191,3 @@ public sealed partial class MobStateParametersPrototype : IPrototype, IInheritin
[DataField]
public float StrippingTimeMultiplier = 1f;
}

public class PrototypeIdDictionarySerializer<TPrototype> :
ITypeValidator<Dictionary<string, string>, MappingDataNode> where TPrototype : class, IPrototype
{
protected virtual PrototypeIdSerializer<TPrototype> PrototypeSerializer => new();

public ValidationNode Validate(ISerializationManager serializationManager, MappingDataNode node,
IDependencyCollection dependencies, ISerializationContext? context = null)
{
var mapping = new Dictionary<ValidationNode, ValidationNode>();

foreach (var (key, val) in node.Children)
{
var keyVal = serializationManager.ValidateNode<string>(key, context);

var listVal = (val is ValueDataNode valuenode)
? PrototypeSerializer.Validate(serializationManager, valuenode, dependencies, context)
: new ErrorNode(val, "PrototypeIdDictionarySerializer failed to get ValueDataNode");

mapping.Add(keyVal, listVal);
}

return new ValidatedMappingNode(mapping);
}

public ValidationNode Validate(ISerializationManager serializationManager, ValueDataNode node,
IDependencyCollection dependencies, ISerializationContext? context = null) =>
PrototypeSerializer.Validate(serializationManager, node, dependencies, context);
}

0 comments on commit 9425dfd

Please sign in to comment.