public void Export(BinaryWriter w) { #if UNITY_EDITOR if (gameObject == null) { Debug.Log("<color=yellow> entity:" + Id + " is destoryed, prefab path:" + mPrefabPath + "</color>"); } #endif w.Write((int)CURRENT_VERSION); if (entityProto != null) { w.Write((int)entityProto.proto); w.Write((int)entityProto.protoId); } else { w.Write((int)-1); w.Write((int)-1); } GetCmpts(s_tmpLstCmps); w.Write(s_tmpLstCmps.Count); for (int i = 0; i < s_tmpLstCmps.Count; i++) { IPeCmpt cmpt = s_tmpLstCmps [i] as IPeCmpt; if (cmpt != null) { w.Write(cmpt.GetTypeName()); PETools.Serialize.WriteData(cmpt.Serialize, w); } } }
public bool Remove(IPeCmpt cmpt) { if (cmpt is MonoBehaviour) { Object.Destroy(cmpt as MonoBehaviour); } return(true); }
public void Import(byte[] buffer) { PETools.Serialize.Import(buffer, (r) => { version = r.ReadInt32(); if (version > CURRENT_VERSION) { Debug.LogError("error version:" + version); return; } if (version >= VERSION_0002) { int entityPrototype = r.ReadInt32(); int entityPrototypeId = r.ReadInt32(); if (entityPrototype != -1) { entityProto = new EntityProto() { proto = (EEntityProto)entityPrototype, protoId = entityPrototypeId }; } } int count = r.ReadInt32(); for (int i = 0; i < count; i++) { string name = r.ReadString(); byte[] buff = PETools.Serialize.ReadBytes(r); if (null == buff || buff.Length <= 0) { continue; } IPeCmpt c = GetCmpt(name); if (null != c) { PETools.Serialize.Import(buff, (r1) => { c.Deserialize(r1); }); } } }); }