public void Deserialize(BinaryReader reader) { int len_tidLinks = reader.ReadInt32(); tidLinks = new STIDLink[len_tidLinks]; for (int i_tidLinks = 0; i_tidLinks < len_tidLinks; ++i_tidLinks) { tidLinks[i_tidLinks] = new STIDLink(); tidLinks[i_tidLinks].Deserialize(reader); } int len_envs = reader.ReadInt32(); envs = new TID[len_envs]; for (int i_envs = 0; i_envs < len_envs; ++i_envs) { envs[i_envs] = new TID(); envs[i_envs].Deserialize(reader); } int len_envLinks = reader.ReadInt32(); envLinks = new SEnvLink[len_envLinks]; for (int i_envLinks = 0; i_envLinks < len_envLinks; ++i_envLinks) { envLinks[i_envLinks] = new SEnvLink(); envLinks[i_envLinks].Deserialize(reader); } }
/// <summary> /// Link tid to template. /// </summary> public void LinkTemplate(TID id, TID to) { BaseTemplate ret; if (tmpls.TryGetValue(id, out ret)) { // 目前认为template为空的TID都是可以RuntimeLink的 if (ret == null) { ret = GetTemplate(to); tmpls[id] = ret; // todo: demonyang singleton if (ret == null) { Logger.Error("LinkTemplate '{0}' to '{1}' failed, {1} doesn't have a template", id, to); } } else { Logger.Error("LinkTemplate failed, {0} was assigned before.", id); } } else { Logger.Error("LinkTemplate failed, {0} is not a linkable TID.", id); } }
public void Deserialize(BinaryReader reader) { link = new TID(); link.Deserialize(reader); to = new TID(); to.Deserialize(reader); }
public override bool Equals(object obj) { if (!(obj is TID)) { return(false); } TID tid = (TID)obj; return(tid.id == this.id); }
/// <summary> /// Get the template. /// </summary> public T GetTemplate <T>(TID id) where T : BaseTemplate { BaseTemplate ret; if (tmpls.TryGetValue(id, out ret)) { return(ret as T); } return(null); }
/// <summary> /// Get the template. /// </summary> public BaseTemplate GetTemplate(TID id) { BaseTemplate ret; if (tmpls.TryGetValue(id, out ret)) { return(ret); } return(null); }
public void Deserialize(BinaryReader reader) { fromEnv = new TID(); fromEnv.Deserialize(reader); toEnv = new TID(); toEnv.Deserialize(reader); sameThreadDirect = reader.ReadBoolean(); bufferSize = reader.ReadInt32(); }
static partial void CreateObject_Inner(uint typeId, TID tid, ref BaseObject ret) { switch (typeId) { case TGameApp.TYPE: ret = new zf.core.GameApp(); break; case TMod.TYPE: ret = new zf.core.Mod(); break; case TRunEnv.TYPE: ret = new zf.core.RunEnv(); break; default: break; } }
/// <summary> /// Create binding class instance with tid. if exists. /// </summary> public BaseObject CreateObject(TID tid) { BaseObject obj; if (tidInsts.TryGetValue(tid, out obj)) { return(obj); } BaseTemplate tmpl = GetTemplate(tid); if (tmpl == null) { Logger.Error("CreateObject failed, tmpl of {0} is null", tid); return(null); } CreateObject_Inner(tmpl.TypeID, tid, ref obj); if (obj == null) { for (int i = 0; i < createObjFuncs.Count; ++i) { createObjFuncs[i](tmpl.TypeID, tid, ref obj); if (obj != null) { break; } } } if (obj == null) { Logger.Error("CreateObject failed, can't create Object of {0}", tid); return(null); } if (tmpl.singletonType == SingletonType.TemplateMgr) { tidInsts.Add(tid, obj); } obj.Tid = tid; obj.InitTemplate(tmpl); obj.OnCreated(); return(obj); }
public override void Deserialize(BinaryReader reader) { base.Deserialize(reader); name = StringAtom.FromReader(reader); maxPlayerNum = reader.ReadInt32(); int len_teams = reader.ReadInt32(); teams = new STeam[len_teams]; for (int i_teams = 0; i_teams < len_teams; ++i_teams) { teams[i_teams] = new STeam(); teams[i_teams].Deserialize(reader); } int len_campRelations = reader.ReadInt32(); campRelations = new SCampRelation[len_campRelations]; for (int i_campRelations = 0; i_campRelations < len_campRelations; ++i_campRelations) { campRelations[i_campRelations] = new SCampRelation(); campRelations[i_campRelations].Deserialize(reader); } int len_configs = reader.ReadInt32(); configs = new Dictionary <TID, SModConfig>(); for (int i_configs = 0; i_configs < len_configs; ++i_configs) { TID key = new TID(); key.Deserialize(reader); SModConfig val = new SModConfig(); val.Deserialize(reader); configs.Add(key, val); } spawnVehicleNum = reader.ReadInt32(); }
public override void Deserialize(BinaryReader reader) { base.Deserialize(reader); name = StringAtom.FromReader(reader); startNow = reader.ReadBoolean(); timeMode = (ETimeMode)reader.ReadInt16(); updateTick = reader.ReadInt32(); fixedUpdateTick = reader.ReadInt32(); sleepMinTick = reader.ReadInt32(); minUid = reader.ReadInt32(); runInThread = reader.ReadBoolean(); int len_services = reader.ReadInt32(); services = new TID[len_services]; for (int i_services = 0; i_services < len_services; ++i_services) { services[i_services] = new TID(); services[i_services].Deserialize(reader); } proxyMode = reader.ReadBoolean(); proxyNetEnv = new TID(); proxyNetEnv.Deserialize(reader); proxyApp = new TID(); proxyApp.Deserialize(reader); }
public virtual void Deserialize(BinaryReader reader) { tid = new TID(); tid.id = reader.ReadInt32(); singletonType = (SingletonType)reader.ReadByte(); }
/// <summary> /// Create the object. /// Auto generate the implement in Templates_impl.cs. /// </summary> static partial void CreateObject_Inner(uint typeId, TID tid, ref BaseObject ret);