示例#1
0
        /// <summary>
        /// Primary client entrypoint.
        /// Initializes a new instance of the <see cref="Client"/> class.
        /// </summary>
        public Client()
        {
            // -- INIT
            Log("Init");

            // Singleton
            Instance = this;

            this.Managers = new ManagerRegistry
            {
                new HudManager(),                 // Resets and hides all HUD elements
                new MapManager(),                 // Loads IPLs and blips
                new MenuManager()                 // Set initial menu options
            };

            this.Services = new ServiceRegistry
            {
                new VehicleRollService(),         // Disable rolling cars back over
                new PlayerDeathService(),         // Knock down players rather than death
                new PlayerIdleService(),          // Kick idle players
                new PedFilterService(),           // Block blacklisted peds
                new AiPoliceService(),            // Disable AI police
                new PlayerIndicatorService(),     // Show nearby players
                new DateTimeService(),            // Set the date and time
                new BlackoutService(),            // Allow city blackouts
                new AtmService(),                 // Add ATMs
                new BranchService()
            };

            this.Services.Initialize();             // Attach handlers

            // -- SERVICE EVENTS

            // Player Death Service
            this.Services.First <PlayerDeathService>().OnDowned += (s, e) =>
            {
                UI.ShowNotification("Downed");

                if (this.LocalPlayer.Character.Weapons.Current.Group != WeaponGroup.Unarmed)
                {
                    this.LocalPlayer.Character.Weapons.Remove(this.LocalPlayer.Character.Weapons.Current);
                }
            };

            this.Services.First <PlayerDeathService>().OnRevived += (s, e) =>
            {
                Screen.ShowNotification("Revived");
            };

            //HandleEvent("igi:character:revive", this.Services.First<PlayerDeathService>().Revive);

            //HandleEvent<string>("igi:car:spawn", SpawnVehicle<Car>);
            //HandleEvent<string>("igi:car:claim", ClaimVehicle<Car>);
            //HandleEvent<string>("igi:car:unclaim", UnclaimVehicle<Car>);
            //HandleEvent<string>("igi:bike:spawn", SpawnVehicle<Bike>);
            //HandleEvent<string>("igi:bike:claim", ClaimVehicle<Bike>);
            //HandleEvent<string>("igi:bike:unclaim", UnclaimVehicle<Bike>);

            Startup();
        }
示例#2
0
        /// <summary>
        /// Primary client entrypoint.
        /// Initializes a new instance of the <see cref="Client"/> class.
        /// </summary>
        public Client()
        {
            // -- INIT
            Log("Init");

            // Singleton
            Instance = this;

            this.Controllers = new ControllerRegistry
            {
                new ClientController(),
                new UserController(),
                new CharacterController(),
                new VehicleController(),
            };

            this.Managers = new ManagerRegistry
            {
                new HudManager(),                 // Resets and hides all HUD elements
                new MapManager(),                 // Loads IPLs and blips
                new MenuManager()                 // Set initial menu options
            };

            this.Services = new ServiceRegistry
            {
                new VehicleService(),         // Vehicle tracking service
                new VehicleRollService(),     // Disable rolling cars back over
                new PlayerDeathService(),     // Knock down players rather than death
                new PlayerIdleService(),      // Kick idle players
                new AutosaveService(),
                new PedFilterService(),       // Block blacklisted peds
                new AiPoliceService(),        // Disable AI police
                new PlayerIndicatorService(), // Show nearby players
                new DateTimeService(),        // Set the date and time
                new BlackoutService(),        // Allow city blackouts
                new AtmService(),             // Add ATMs
                new BranchService(),          // Add Bank Tellers
                new DowntownCabService()
            };

            this.Services.Initialize();             // Attach handlers

            // -- SERVICE EVENTS

            // Player Death Service
            this.Services.First <PlayerDeathService>().OnDowned += (s, e) =>
            {
                UI.ShowNotification("Downed");
                if (this.LocalPlayer.Character.Weapons.Current.Group != WeaponGroup.Unarmed)
                {
                    this.LocalPlayer.Character.Weapons.Remove(this.LocalPlayer.Character.Weapons.Current);
                }
            };

            this.Services.First <PlayerDeathService>().OnRevived += (s, e) => Screen.ShowNotification("Revived");

            this.Controllers.First <ClientController>().Startup();
        }