public ActorProxy Get(long id) { if (this.ActorProxys.TryGetValue(id, out ActorProxy actorProxy)) { return(actorProxy); } actorProxy = EntityFactory.CreateWithId <ActorProxy>(id); this.ActorProxys[id] = actorProxy; return(actorProxy); }
public Task <Disposer> Get(string collectionName, long id) { Disposer entity = GetFromCache(collectionName, id); if (entity != null) { return(Task.FromResult(entity)); } TaskCompletionSource <Disposer> tcs = new TaskCompletionSource <Disposer>(); DBQueryTask dbQueryTask = EntityFactory.CreateWithId <DBQueryTask, string, TaskCompletionSource <Disposer> >(id, collectionName, tcs); this.tasks[(int)((ulong)id % taskCount)].Add(dbQueryTask); return(tcs.Task); }
public Task <bool> Add(Disposer disposer, string collectionName = "") { TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>(); this.AddToCache(disposer, collectionName); if (collectionName == "") { collectionName = disposer.GetType().Name; } DBSaveTask task = EntityFactory.CreateWithId <DBSaveTask, Disposer, string, TaskCompletionSource <bool> >(disposer.Id, disposer, collectionName, tcs); this.tasks[(int)((ulong)task.Id % taskCount)].Add(task); return(tcs.Task); }
public static Unit Create(long id) { UnitComponent unitComponent = Game.Scene.GetComponent <UnitComponent>(); GameObject prefab = ((GameObject)Resources.Load("Unit")).Get <GameObject>("Skeleton"); Unit unit = EntityFactory.CreateWithId <Unit>(id); unit.GameObject = UnityEngine.Object.Instantiate(prefab); GameObject parent = GameObject.Find($"/Global/Unit"); unit.GameObject.transform.SetParent(parent.transform, false); unit.AddComponent <AnimatorComponent>(); unit.AddComponent <MoveComponent>(); unitComponent.Add(unit); return(unit); }