Esempio n. 1
0
        void UpdateRemotePlayers()
        {
            if (GetGameTimer() - lastUpdateTime > 100)
            {
                var remotePlayers = GetActivePlayers();

                foreach (var player in remotePlayers)
                {
                    if (player == PlayerId())
                    {
                        continue;
                    }

                    if (!remoteVehicles.ContainsKey(player))
                    {
                        remoteVehicles[player] = new TrailVehicle(player);
                    }
                }

                lastUpdateTime = GetGameTimer();
            }
        }
Esempio n. 2
0
        async Task Update()
        {
            // set up local player trails
            if (localVehicle == null)
            {
                localVehicle = new TrailVehicle(PlayerId());
            }

            // update local vehicle
            await localVehicle.Update();

            // set up remote player trails
            UpdateRemotePlayers();

            // update remote vehicles
            foreach (var player in remoteVehicles.Keys)
            {
                var trail = remoteVehicles[player];

                // If the player is not valid
                if (player == -1 || !NetworkIsPlayerActive(player))
                {
                    if (DoesEntityExist(trail.PlayerVehicle))
                    {
                        DecorRemove(trail.PlayerVehicle, DecorName);
                    }

                    await trail.StopAll();

                    removeList.Add(player);
                    continue;
                }

                await trail.GetPlayerVehicle();

                // If there is no decor on the vehicle
                if (!DecorExistOn(trail.PlayerVehicle, DecorName))
                {
                    await trail.StopAll();

                    //removeList.Add(player);
                    continue;
                }

                var decorTrailMode = (TrailMode)DecorGetInt(trail.PlayerVehicle, DecorName);

                // If the decor is set to Off
                if (decorTrailMode == TrailMode.Off)
                {
                    await trail.StopAll();

                    //removeList.Add(player);
                    continue;
                }

                await trail.SetTrailModeAsync(decorTrailMode);

                await trail.UpdatePlayerVehicle();
            }

            foreach (var item in removeList)
            {
                remoteVehicles.Remove(item);
            }
            removeList.Clear();
        }