From 8e10522bd20448113ff43c3448070f8d3473848b Mon Sep 17 00:00:00 2001 From: zumorica Date: Wed, 29 Apr 2020 14:26:13 +0200 Subject: [PATCH] Read enums only when reading from serialized data --- .../GameObjects/Components/Interactable/MultitoolComponent.cs | 3 ++- .../GameObjects/Components/Interactable/ToolComponent.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Content.Server/GameObjects/Components/Interactable/MultitoolComponent.cs b/Content.Server/GameObjects/Components/Interactable/MultitoolComponent.cs index 124115d262..4c9d0c8abd 100644 --- a/Content.Server/GameObjects/Components/Interactable/MultitoolComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/MultitoolComponent.cs @@ -36,7 +36,8 @@ namespace Content.Server.GameObjects.Components.Interactable public void ExposeData(ObjectSerializer serializer) { - Behavior = (Tool)serializer.ReadStringEnumKey("behavior"); + if(serializer.Reading) + Behavior = (Tool)serializer.ReadStringEnumKey("behavior"); serializer.DataField(ref _state, "state", string.Empty); serializer.DataField(ref _sprite, "sprite", string.Empty); serializer.DataField(ref _texture, "texture", string.Empty); diff --git a/Content.Server/GameObjects/Components/Interactable/ToolComponent.cs b/Content.Server/GameObjects/Components/Interactable/ToolComponent.cs index 83feab60e4..042d7fd113 100644 --- a/Content.Server/GameObjects/Components/Interactable/ToolComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/ToolComponent.cs @@ -132,10 +132,11 @@ namespace Content.Server.GameObjects.Components.Interactable { base.ExposeData(serializer); + if(serializer.Reading) + _behavior = (Tool)serializer.ReadStringEnumKey("behavior"); serializer.DataField(ref _speedModifier, "speed", 1); serializer.DataField(ref _useSound, "useSound", string.Empty); serializer.DataField(ref _useSoundCollection, "useSoundCollection", string.Empty); - _behavior = (Tool)serializer.ReadStringEnumKey("behavior"); } ///