public static T CreateWithParentAndId <T, A, B, C, D>(Entity parent, long id, A a, B b, C c, D d, bool isFromPool = false) where T : Entity { Type type = typeof(T); T component = (T)Entity.Create(type, isFromPool); component.Id = id; component.Parent = parent; EventSystem.Instance.Awake(component, a, b, c, d); return(component); }
public static ETTask <FUI_ActityHead> CreateInstanceAsync(Entity domain) { ETTask <FUI_ActityHead> tcs = ETTask <FUI_ActityHead> .Create(true); CreateGObjectAsync((go) => { tcs.SetResult(Entity.Create <FUI_ActityHead, GObject>(domain, go)); }); return(tcs); }
/// <summary> /// 创建一个RepeatedTimer /// </summary> private long NewRepeatedTimerInner(long time, Action action) { #if SERVER if (time < 100) { throw new Exception($"repeated timer < 100, timerType: time: {time}"); } #endif long tillTime = TimeHelper.ServerNow() + time; TimerAction timer = Entity.Create <TimerAction, TimerClass, long, object>(this, TimerClass.RepeatedTimer, time, action, true); this.AddTimer(tillTime, timer); return(timer.Id); }
/// <summary> /// 加载一个Map的数据 /// </summary> public void LoadMapNavData(int mapId, char[] navDataPath) { if (m_RecastPathProcessorDic.ContainsKey(mapId)) { Log.Warning($"已存在Id为{mapId}的地图Nav数据,请勿重复加载!"); return; } if (RecastInterface.LoadMap(mapId, navDataPath)) { RecastPathProcessor recastPathProcessor = Entity.Create <RecastPathProcessor>(this); recastPathProcessor.MapId = mapId; m_RecastPathProcessorDic[mapId] = recastPathProcessor; Log.Debug($"加载Id为{mapId}的地图Nav数据成功!"); } }
public async ETVoid Lock(long key, long instanceId, int time = 0) { CoroutineLock coroutineLock = await CoroutineLockComponent.Instance.Wait(CoroutineLockType.Location, key); LockInfo lockInfo = Entity.Create <LockInfo, long, CoroutineLock>(this, instanceId, coroutineLock); this.lockInfos.Add(key, lockInfo); Log.Debug($"location lock key: {key} instanceId: {instanceId}"); if (time > 0) { long lockInfoInstanceId = lockInfo.InstanceId; await TimerComponent.Instance.WaitAsync(time); if (lockInfo.InstanceId != lockInfoInstanceId) { return; } UnLock(key, instanceId, instanceId); } }
public async ETTask <bool> WaitAsync(long time, ETCancellationToken cancellationToken = null) { if (time == 0) { return(true); } long tillTime = TimeHelper.ServerNow() + time; ETTask <bool> tcs = ETTask <bool> .Create(true); TimerAction timer = Entity.Create <TimerAction, TimerClass, long, object>(this, TimerClass.OnceWaitTimer, 0, tcs, true); this.AddTimer(tillTime, timer); long timerId = timer.Id; void CancelAction() { if (this.Remove(timerId)) { tcs.SetResult(false); } } bool ret; try { cancellationToken?.Add(CancelAction); ret = await tcs; } finally { cancellationToken?.Remove(CancelAction); } return(ret); }
protected override async ETTask Run(Session session, C2G_LoginGate request, G2C_LoginGate response, Action reply) { Scene scene = session.DomainScene(); string account = scene.GetComponent <GateSessionKeyComponent>().Get(request.Key); if (account == null) { response.Error = ErrorCode.ERR_ConnectGateKeyError; response.Message = "Gate key验证失败!"; reply(); return; } PlayerComponent playerComponent = scene.GetComponent <PlayerComponent>(); Player player = Entity.Create <Player, string>(playerComponent, account); playerComponent.Add(player); session.AddComponent <SessionPlayerComponent>().Player = player; session.AddComponent <MailBoxComponent, MailboxType>(MailboxType.GateSession); response.PlayerId = player.Id; reply(); await ETTask.CompletedTask; }
public static FUI_BottomBtn CreateInstance(Entity domain) { return(Entity.Create <FUI_BottomBtn, GObject>(domain, CreateGObject())); }
public static FUI_Lobby CreateInstance(Entity domain) { return(Entity.Create <FUI_Lobby, GObject>(domain, CreateGObject())); }
/// <summary> /// 仅用于go已经实例化情况下的创建(例如另一个组件引用了此组件) /// </summary> /// <param name="domain"></param> /// <param name="go"></param> /// <returns></returns> public static FUI_Lobby Create(Entity domain, GObject go) { return(Entity.Create <FUI_Lobby, GObject>(domain, go)); }
/// <summary> /// 仅用于go已经实例化情况下的创建(例如另一个组件引用了此组件) /// </summary> /// <param name="domain"></param> /// <param name="go"></param> /// <returns></returns> public static FUI_Btn_ToTestScene Create(Entity domain, GObject go) { return(Entity.Create <FUI_Btn_ToTestScene, GObject>(domain, go)); }
/// <summary> /// 仅用于go已经实例化情况下的创建(例如另一个组件引用了此组件) /// </summary> /// <param name="domain"></param> /// <param name="go"></param> /// <returns></returns> public static FUI_Btn_Registe Create(Entity domain, GObject go) { return(Entity.Create <FUI_Btn_Registe, GObject>(domain, go)); }
public override void Awake(FUIManagerComponent self) { GRoot.inst.SetContentScaleFactor(1280, 720, UIContentScaler.ScreenMatchMode.MatchWidthOrHeight); self.Root = Entity.Create <FUI, GObject>(self.Domain, GRoot.inst); }
/// <summary> /// 仅用于go已经实例化情况下的创建(例如另一个组件引用了此组件) /// </summary> /// <param name="domain"></param> /// <param name="go"></param> /// <returns></returns> public static FUI_ActityHead Create(Entity domain, GObject go) { return(Entity.Create <FUI_ActityHead, GObject>(domain, go)); }
public static FUI_ActityHead CreateInstance(Entity domain) { return(Entity.Create <FUI_ActityHead, GObject>(domain, CreateGObject())); }
/// <summary> /// 仅用于go已经实例化情况下的创建(例如另一个组件引用了此组件) /// </summary> /// <param name="domain"></param> /// <param name="go"></param> /// <returns></returns> public static FUI_BottomBtn Create(Entity domain, GObject go) { return(Entity.Create <FUI_BottomBtn, GObject>(domain, go)); }
public static FUI_Btn_ToTestScene CreateInstance(Entity domain) { return(Entity.Create <FUI_Btn_ToTestScene, GObject>(domain, CreateGObject())); }
public static FUI_Btn_Registe CreateInstance(Entity domain) { return(Entity.Create <FUI_Btn_Registe, GObject>(domain, CreateGObject())); }