Пример #1
0
        public World()
        {
            _updateObjectPool = new UpdateObjectPool(REFRESH_RATE);
            _updateObjectPool.Start();

            VehicleEventsManager = new VehicleEventsManager();
            _updateObjectPool.AddUpdateObject(VehicleEventsManager);

            AimingManager = new AimingManager();
            _updateObjectPool.AddUpdateObject(AimingManager);

            EntityDeathTracker = new EntityDeathTracker();

            ObjectManager = new ObjectManager(REFRESH_RATE);
        }
Пример #2
0
        private void OnClientResourceStart(string resourceName)
        {
            if (GetCurrentResourceName() != resourceName)
            {
                return;
            }

            _updateObjectPool = new UpdateObjectPool(0);
            _updateObjectPool.Start();

            _cameraControl = new CameraControl();

            RegisterCommand("start", new Action <int, List <object>, string>((source, args, raw) =>
            {
                PrintToChat("Starting new camera...");

                if (_camera != null)
                {
                    _toggled = false;
                    RenderScriptCams(false, false, 0, true, true);

                    _updateObjectPool.RemoveUpdateObject(_cameraControl);

                    _camera.Delete();
                    _camera = null;

                    FreezeEntityPosition(Game.PlayerPed.Handle, false);
                }

                var cameraHandle = CreateCam("DEFAULT_SCRIPTED_CAMERA", true);
                _camera          = new Camera(cameraHandle);
                _camera.Position = GetPlayerHeadPosition() + Game.PlayerPed.ForwardVector * 1.5f;
                _camera.PointAt(GetPlayerHeadPosition());
                _camera.StopPointing();

                _toggled = true;
                RenderScriptCams(true, false, 0, true, true);

                _cameraControl.SetCamera(_camera);
                _updateObjectPool.AddUpdateObject(_cameraControl);

                FreezeEntityPosition(Game.PlayerPed.Handle, true);
            }), false);

            RegisterCommand("toggle", new Action <int, List <object>, string>((source, args, raw) =>
            {
                if (_camera == null)
                {
                    return;
                }

                if (!_toggled)
                {
                    _toggled = true;
                    RenderScriptCams(true, false, 0, true, true);
                }
                else
                {
                    _toggled = false;
                    RenderScriptCams(false, false, 0, true, true);
                }
            }), false);

            RegisterCommand("stop", new Action <int, List <object>, string>((source, args, raw) =>
            {
                if (_camera == null)
                {
                    return;
                }

                PrintToChat("Stopping camera...");

                _toggled = false;
                RenderScriptCams(false, false, 0, true, true);

                _updateObjectPool.RemoveUpdateObject(_cameraControl);

                _camera.Delete();
                _camera = null;

                FreezeEntityPosition(Game.PlayerPed.Handle, false);
            }), false);

            RegisterCommand("save", new Action <int, List <object>, string>((source, args, raw) =>
            {
                if (_camera == null)
                {
                    return;
                }

                PrintToChat("Saving camera configuration...");

                var offset = GetOffsetFromEntityGivenWorldCoords(Game.PlayerPed.Handle, _camera.Position.X,
                                                                 _camera.Position.Y, _camera.Position.Z);
                var headPosition = GetPlayerHeadPosition();
                var headOffset   = GetOffsetFromEntityGivenWorldCoords(Game.PlayerPed.Handle, headPosition.X,
                                                                       headPosition.Y, headPosition.Z);

                var result = offset - headOffset;
                Debug.WriteLine($"Camera offset: {result.X}f, {result.Y}f, {result.Z}f");

                var rotation = _camera.Rotation - Game.PlayerPed.Rotation;
                Debug.WriteLine($"Camera rotation: {rotation.X}f, {rotation.Y}f, {rotation.Z}f");

                var fov = _camera.FieldOfView;
                Debug.WriteLine($"Camera fov: {fov}f");
            }), false);
        }
Пример #3
0
 public ObjectManager(int refreshRate)
 {
     _updateObjectPool = new UpdateObjectPool(refreshRate);
     _updateObjectPool.Start();
 }
Пример #4
0
        private void OnClientResourceStart(string resourceName)
        {
            if (GetCurrentResourceName() != resourceName)
            {
                return;
            }

            var configuration = new HubConfiguration
            {
                HubCenter           = new Vector3(2049.88f, 3183.32f, 45.16f),
                HubRadius           = 200f,
                SpawnConfigurations = new List <SpawnConfiguration>
                {
                    new SpawnConfiguration
                    {
                        Position         = new Vector3(2043f, 2198f, 45f),
                        Heading          = 234f,
                        PedConfiguration = new PedConfiguration
                        {
                            Model = "a_m_o_acult_01"
                        }
                    },
                    new SpawnConfiguration
                    {
                        Position         = new Vector3(2057.64f, 3195.24f, 45.19f),
                        Heading          = 114f,
                        PedConfiguration = new PedConfiguration
                        {
                            Model = "a_m_o_acult_02"
                        }
                    },
                    new SpawnConfiguration
                    {
                        Position         = new Vector3(2060.47f, 3174.21f, 45.17f),
                        Heading          = 57f,
                        PedConfiguration = new PedConfiguration
                        {
                            Model = "a_m_y_acult_01"
                        }
                    },
                    new SpawnConfiguration
                    {
                        Position         = new Vector3(2053.91f, 3175.48f, 45.17f),
                        Heading          = 356.26f,
                        PedConfiguration = new PedConfiguration
                        {
                            Model = "a_m_y_methhead_01"
                        }
                    },
                    new SpawnConfiguration
                    {
                        Position         = new Vector3(2039.88f, 3183.31f, 45.22f),
                        Heading          = 253.27f,
                        PedConfiguration = new PedConfiguration
                        {
                            Model = "a_f_m_fatcult_01"
                        }
                    }
                }
            };

            var updateObjectPool = new UpdateObjectPool(1000);

            updateObjectPool.Start();

            var hub = new Hub(configuration);

            updateObjectPool.AddUpdateObject(hub);

            RegisterCommand("location", new Action <int, List <object>, string>((source, args, raw) =>
            {
                var playerPosition = Game.PlayerPed.Position;
                Debug.WriteLine($"Position: {playerPosition.X}f, {playerPosition.Y}f, {playerPosition.Z}f");

                var playerHeading = Game.PlayerPed.Heading;
                Debug.WriteLine($"Heading: {playerHeading}f");
            }), false);
        }