private Player() { OnRespondToMission = new Event <int, GameObject, Lot>(); OnFireServerEvent = new Event <string, FireServerEventMessage>(); OnPositionUpdate = new Event <Vector3, Quaternion>(); OnLootPickup = new Event <Lot>(); OnWorldLoad = new Event(); Lock = new SemaphoreSlim(1, 1); Listen(OnStart, async() => { Connection.Disconnected += reason => { Connection = default; Destroy(this); return(Task.CompletedTask); }; Listen(OnPositionUpdate, UpdatePhysics); if (TryGetComponent <DestructibleComponent>(out var destructibleComponent)) { destructibleComponent.OnResurrect.AddListener(() => { GetComponent <DestroyableComponent>().Imagination = 6; }); } await using var ctx = new UchuContext(); var character = await ctx.Characters .Include(c => c.UnlockedEmotes) .FirstAsync(c => c.Id == Id); foreach (var unlockedEmote in character.UnlockedEmotes) { await UnlockEmoteAsync(unlockedEmote.EmoteId); } // Update the player view filters every five seconds Zone.Update(this, async() => { await Perspective.TickAsync(); }, 20 * 5); // Check banned status every minute // TODO: Find an active method instead of polling Zone.Update(this, async() => { await CheckBannedStatusAsync(); }, 20 * 60); });
private Player() { OnFireServerEvent = new AsyncEventDictionary <string, FireServerEventMessage>(); OnPositionUpdate = new Event <Vector3, Quaternion>(); OnLootPickup = new Event <Lot>(); OnWorldLoad = new Event(); Lock = new SemaphoreSlim(1, 1); Listen(OnStart, async() => { Connection.Disconnected += reason => { Connection = default; Destroy(this); return(Task.CompletedTask); }; Listen(OnPositionUpdate, UpdatePhysics); if (TryGetComponent <DestructibleComponent>(out var destructibleComponent)) { destructibleComponent.OnResurrect.AddListener(() => { GetComponent <Stats>().Imagination = 6; }); } await using var ctx = new UchuContext(); var character = await ctx.Characters .Include(c => c.UnlockedEmotes) .FirstAsync(c => c.Id == Id); foreach (var unlockedEmote in character.UnlockedEmotes) { await UnlockEmoteAsync(unlockedEmote.EmoteId); } Zone.Update(this, async() => { await Perspective.TickAsync(); await CheckBannedStatusAsync(); }, 20 * 5); });