Exemplo n.º 1
0
        public async Task TakeMe(IMyPlayer player, int index)
        {
            if (player == null)
            {
                throw new ArgumentException("calling player not found");
            }

            var entities = _clusters[index];

            if (entities.Length == 0)
            {
                throw new InvalidOperationException("entities not found");
            }

            var(_, center) = VRageUtils.GetBound(entities.Select(e => e.Position));
            player.Character.SetPosition(center);

            DeleteGpss(player.IdentityId);

            await GameLoopObserver.MoveToGameLoop(); // to create gps entities

            foreach (var grid in entities)
            {
                var gps = CreateGridGps($"{GpsNamePrefix}{grid.Name}", grid.Position, "", Color.Purple);
                MySession.Static.Gpss.SendAddGps(player.IdentityId, ref gps);
            }

            await TaskUtils.MoveToThreadPool();
        }
Exemplo n.º 2
0
        public async Task Run(CancellationToken cancellationToken)
        {
            while (!cancellationToken.IsCancellationRequested)
            {
                await GameLoopObserver.MoveToGameLoop(cancellationToken);

                foreach (var player in MySession.Static.Players.GetOnlinePlayers())
                {
                    if (player == null)
                    {
                        continue;
                    }

                    var steamId = player.SteamId();
                    if (steamId == 0)
                    {
                        continue;
                    }

                    var position = player.GetPosition();

                    if (_lastPositions.TryGetValue(steamId, out var lastPosition))
                    {
                        NotifyIfTierChanged(steamId, position, lastPosition);
                    }

                    _lastPositions[steamId] = position;
                }

                await Task.Delay(1.Seconds(), cancellationToken);
            }
        }
Exemplo n.º 3
0
        async Task Profile()
        {
            using (var profiler = new PhysicsProfiler())
                using (ProfilerResultQueue.Profile(profiler))
                {
                    await GameLoopObserver.MoveToGameLoop();

                    profiler.MarkStart();

                    for (var i = 0; i < _physicsConfig.PhysicsFrameCount; i++)
                    {
                        await GameLoopObserver.MoveToGameLoop();
                    }

                    profiler.MarkEnd();

                    var result = profiler.GetResult();
                    ProcessResult(result);
                }
        }