using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
+using System.Runtime.Serialization;
+
+using Newtonsoft.Json;
using Vintagestory.API.Client;
using Vintagestory.API.Common;
/// <summary>
/// Point of Interest Rule Designator
/// </summary>
+ [JsonObject(MemberSerialization.OptIn)]
public class BlockDesignator
{
+ [JsonProperty]
public Color OverwriteColor;
- public BlockDesignatorAction SpecialAction;
+
+ [JsonIgnore]
+ public BlockDesignatonAction SpecialAction;
+
+ [JsonProperty]
+ public string SpecialActionName;
+
+ [JsonProperty]
public AssetLocation Pattern;
+
+ [JsonProperty]
public EnumBlockMaterial? Material;
+
+ [JsonProperty]
public bool Enabled { get; set; }
private BlockDesignator()
{
- throw new NotSupportedException();
+ //throw new NotSupportedException();
}
public BlockDesignator(AssetLocation pattern, Color overwriteColor, EnumBlockMaterial? material)
this.OverwriteColor = overwriteColor;
this.Material = material;
this.SpecialAction = specialAct;
+ this.SpecialActionName = specialAct.Method.Name;
this.Enabled = true;
}
{
return Pattern.ToShortString() + "|" + OverwriteColor.Name + "|" + Material ?? "";
}
+
+ [OnDeserialized]
+ public void RelinkDesignator(StreamingContext sCtx )
+ {
+ //TODO: properly Via reflection - and support for external designators?
+ if (SpecialAction == null && !String.IsNullOrEmpty(SpecialActionName)) {
+ switch (SpecialActionName) {
+
+ case "DecodeSign":
+ SpecialAction = DefaultDesignators.DecodeSign;
+ break;
+
+ case "DecodePostSign":
+ SpecialAction = DefaultDesignators.DecodePostSign;
+ break;
+
+ case "DecodeTranslocator":
+ SpecialAction = DefaultDesignators.DecodeTranslocator;
+ break;
+
+ }
+ }
+
+ }
}
}