public void OnGameModeInit(IWorldService worldService)
        {
            var green = Color.Green;

            green.A = 128;
            worldService.CreateTextLabel("text", green, new Vector3(10, 10, 10), 1000);
        }
示例#2
0
        public void OnGameModeInit(IVehicleRepository vehiclesRepository, IWorldService worldService,
                                   IServerService serverService, IVehicleInfoService vehicleInfoService)
        {
            // Event methods have dependency injection alongside the arguments

            Console.WriteLine("Do game mode loading goodies...");

            vehiclesRepository.Foo();

            worldService.CreateActor(101, new Vector3(0, 0, 20), 0);

            var blue = Color.Blue;

            blue.A      = 128;
            _zone       = worldService.CreateGangZone(0, 0, 100, 100);
            _zone.Color = blue;
            _zone.Show();

            var obj = worldService.CreateObject(16638, new Vector3(10, 10, 40), Vector3.Zero, 1000);

            obj.DisableCameraCollisions();

            worldService.CreateVehicle(VehicleModelType.Alpha, new Vector3(40, 40, 10), 0, 0, 0);

            var green = Color.Green;

            green.A = 128;
            worldService.CreateTextLabel("text", green, new Vector3(10, 10, 10), 1000);

            _welcome              = worldService.CreateTextDraw(new Vector2(20, 40), "Hello, world");
            _welcome.Alignment    = TextDrawAlignment.Left;
            _welcome.Font         = TextDrawFont.Diploma;
            _welcome.Proportional = true;
            Console.WriteLine("TD pos: " + _welcome.Position);
            Console.WriteLine(_welcome.Entity.ToString());

            _menu = worldService.CreateMenu("Test menu", new Vector2(200, 300), 100);
            _menu.AddItem("Hello!!!");
            _menu.AddItem("Hello!!");
            _menu.AddItem("Hello!");

            var ctx = SynchronizationContext.Current;

            Task.Run(() =>
            {
                // ... Run things on a worker thread.

                ctx.Send(_ =>
                {
                    // ... Run things on the main thead.
                }, null);
            });

            serverService.SetGameModeText("SampSharp.Entities");

            var size = vehicleInfoService.GetModelInfo(VehicleModelType.AT400, VehicleModelInfoType.Size);

            Console.WriteLine($"AT400 size {size}");
        }
示例#3
0
        public async void RearCommand(Player player, IEntityManager entityManager, IWorldService worldService,
                                      IVehicleInfoService vehicleInfoService)
        {
            var labels = new List <EntityId>();

            foreach (var vehicle in entityManager.GetComponents <Vehicle>())
            {
                var model = vehicle.Model;

                var size   = vehicleInfoService.GetModelInfo(model, VehicleModelInfoType.Size);
                var bumper = vehicleInfoService.GetModelInfo(model, VehicleModelInfoType.RearBumperZ);
                var offset = new Vector3(0, -size.Y / 2, bumper.Z);

                var rotation = vehicle.RotationQuaternion;

                var mRotation =
                    rotation.LengthSquared >
                    10000 // Unoccupied vehicle updates corrupt the internal vehicle world matrix
                        ? Matrix.CreateRotationZ(MathHelper.ToRadians(vehicle.Angle))
                        : Matrix.CreateFromQuaternion(rotation);

                var matrix = Matrix.CreateTranslation(offset) *
                             mRotation *
                             Matrix.CreateTranslation(vehicle.Position);

                var point = matrix.Translation;

                var label = worldService.CreateTextLabel("[x]", Color.Blue, point, 100, 0, false);
                labels.Add(label.Entity);
            }

            player.SendClientMessage("Points added");

            await Task.Delay(10000);

            foreach (var l in labels)
            {
                entityManager.Destroy(l);
            }

            player.SendClientMessage("Points removed");
        }