예제 #1
0
        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);
            });