EditorData.Vars.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using CommonLang.Property;
  5. using CommonAI.Zone.ZoneEditor.EventTrigger;
  6. using CommonAI.Zone.ZoneEditor;
  7. using CommonLang.IO;
  8. using CommonLang.IO.Attribute;
  9. using CommonAI.Zone.EventTrigger;
  10. namespace CommonAI.ZoneEditor
  11. {
  12. [MessageType(0x4500)]
  13. [TableClassAttribute("Name")]
  14. public class ZoneVar : IExternalizable
  15. {
  16. public string Key;
  17. public object Value;
  18. public bool SyncToClient = false;
  19. public DescAttribute ValueDesc
  20. {
  21. get { return PropertyUtil.GetAttribute<DescAttribute>(Value.GetType()); }
  22. }
  23. public TypeDescAttribute BaseDesc
  24. {
  25. get { return AbstractValueTypeMap.GetBaseValueType(Value.GetType()); }
  26. }
  27. public override string ToString()
  28. {
  29. TypeDescAttribute desc = BaseDesc;
  30. if (desc != null)
  31. {
  32. return string.Format("环境变量[{0}] as {1}", Key, desc.Desc.Desc);
  33. }
  34. return string.Format("环境变量[{0}]", Key);
  35. }
  36. public void WriteExternal(IOutputStream output)
  37. {
  38. output.PutBool(SyncToClient);
  39. output.PutUTF(Key);
  40. output.PutObj2Xml(Value);
  41. }
  42. public void ReadExternal(IInputStream input)
  43. {
  44. this.SyncToClient = input.GetBool();
  45. this.Key = input.GetUTF();
  46. this.Value = input.GetXml2Obj<object>();
  47. }
  48. }
  49. }