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 EntityDesignator
{
+ [JsonProperty]
public Color Color;
- public EntityDesignatorAction SpecialAction;
+
+ [JsonIgnore]
+ public EntityDesignatonAction SpecialAction;
+
+ [JsonProperty]
+ public string SpecialActionName;
+
+ [JsonProperty]
public AssetLocation Pattern;
+
+ [JsonProperty]
public EnumEntityState? StateCheck;//Needed?
+
+ [JsonProperty]
public bool Enabled { get; set; }
private EntityDesignator()
{
- throw new NotSupportedException();
+ //throw new NotSupportedException();
}
public EntityDesignator(AssetLocation pattern, Color color, EnumEntityState? state)
Color = color;
StateCheck = state;
SpecialAction = specialAct;
+ SpecialActionName = specialAct.Method.Name;
Enabled = true;
}
public override string ToString()
=> Pattern.ToShortString() + "|" + Color.Name + "|" + StateCheck ?? "";
+
+ [OnDeserialized]
+ public void RelinkDesignator(StreamingContext sCtx)
+ {
+ //TODO: properly Via reflection - and support for external designators?
+ if (SpecialAction == null && !String.IsNullOrEmpty(SpecialActionName)) {
+ switch (SpecialActionName) {
+
+ case "KeepTrackOfMerchant":
+ SpecialAction = DefaultDesignators.KeepTrackOfMerchant;
+ break;
+
+
+ }
+ }
+
+ }
}
}