Esempio n. 1
0
 public void ProcessVehicle(ushort vehicleId, VehicleHandler handler)
 {
     ProcessVehicle(
         vehicleId,
         ref Singleton <VehicleManager> .instance.m_vehicles.m_buffer[vehicleId],
         handler);
 }
Esempio n. 2
0
        public Vehicle[] CreateVehicles(int n)
        {
            var test_cars = VehicleHandler.GetTestVehicles();

            Array.Resize(ref test_cars, n);
            return(test_cars);
        }
Esempio n. 3
0
        /// <summary>
        /// Add Passenger
        /// </summary>
        public void Enter(Unit passenger)
        {
            this._passenger = passenger;

            passenger.m_vehicleSeat        = this;
            passenger.MovementFlags       |= MovementFlags.OnTransport;
            passenger.TransportPosition    = Entry.AttachmentOffset;
            passenger.TransportOrientation = Entry.PassengerYaw;
            Vehicle._passengerCount++;

            if (IsDriverSeat)
            {
                Vehicle.Charmer    = passenger;
                passenger.Charm    = Vehicle;
                Vehicle.UnitFlags |= UnitFlags.Possessed;
            }

            var chr = passenger as Character;
            var pos = Vehicle.Position;

            // this will be null if its not a character
            if (chr != null)
            {
                VehicleHandler.Send_SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA(chr);
                VehicleHandler.SendBreakTarget(chr, Vehicle);
            }

            MovementHandler.SendEnterTransport(passenger);

            if (chr != null)
            {
                MiscHandler.SendCancelAutoRepeat(chr, Vehicle);
                //var orientation = Vehicle.m_vehicleSeat != null ? Vehicle.m_vehicleSeat.Entry.PassengerYaw : 0;
                //var moveflags = Vehicle.m_vehicleSeat != null ? MonsterMoveFlags.Flag_0x1000000 : MonsterMoveFlags.Walk;
                //MovementHandler.SendMoveToPacket(Vehicle, ref pos, orientation, 0, moveflags);
                PetHandler.SendVehicleSpells(chr, Vehicle);
            }

            passenger.IncMechanicCount(SpellMechanic.Rooted, true);
            passenger.HasPermissionToMove = false;
            passenger.MovementFlags      |= MovementFlags.Root;

            if (chr != null)
            {
                chr.SetMover(Vehicle, IsDriverSeat);
                chr.FarSight = Vehicle.EntityId;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Main loop, runs the WebSocket connection.
        /// </summary>
        protected void RunSocket()
        {
            //We don't really need to store the handlers;
            //just create them and let them call our EnqueueMessage method.
            //XXX automatically find these like WebServer does.
            Log($"Creating socket handlers (thread: {Thread.CurrentThread.Name})");
            BudgetHandler       budgetHandler       = new BudgetHandler(this);
            BuildingHandler     buildingHandler     = new BuildingHandler(this);
            CameraHandler       cameraHandler       = new CameraHandler(this);
            ChirperHandler      chirperHandler      = new ChirperHandler(this);
            CitizenHandler      citizenHandler      = new CitizenHandler(this);
            CityInfoHandler     cityInfoHandler     = new CityInfoHandler(this);
            DebugHandler        debugHandler        = new DebugHandler(this);
            DistrictHandler     districtHandler     = new DistrictHandler(this);
            FlagsHandler        flagsHandler        = new FlagsHandler(this);
            InstancesHandler    instancesHandler    = new InstancesHandler(this);
            LimitsHandler       limitsHandler       = new LimitsHandler(this);
            NotificationHandler notificationHandler = new NotificationHandler(this);
            ReflectionHandler   reflectionHandler   = new ReflectionHandler(this);
            TerrainHandler      terrainHandler      = new TerrainHandler(this);
            TransportHandler    transportHandler    = new TransportHandler(this);
            VehicleHandler      vehicleHandler      = new VehicleHandler(this);

            Log("Waiting for messages");
            try {
                while (true)
                {
                    if (stream.DataAvailable)
                    {
                        HandleNextMessage();
                    }
                    String msg = GetNextOutgoingMessage();
                    if (msg != null)
                    {
                        byte[] buf = Encoding.UTF8.GetBytes(msg);
                        SendFrame(buf);
                    }
                    Thread.Sleep(100);
                }
            }
            catch (ObjectDisposedException) {
                //we're done, stream is closed
                Log("Connection closed");
            }
            catch (OperationCanceledException) {
                Log("Connection closed");
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Remove Passenger
        /// </summary>
        public void ClearSeat()
        {
            if (_passenger == null)
            {
                return;
            }

            if (IsDriverSeat)
            {
                Vehicle.Charmer    = null;
                _passenger.Charm   = null;
                Vehicle.UnitFlags &= ~UnitFlags.Possessed;
            }

            Vehicle._passengerCount--;
            if (_passenger.MovementFlags.HasFlag(MovementFlags.Flying))
            {
                var cast = Vehicle.SpellCast;
                if (cast != null)
                {
                    cast.Trigger(SpellId.EffectParachute);
                }
            }

            _passenger.MovementFlags &= ~MovementFlags.OnTransport;
            _passenger.Auras.RemoveFirstVisibleAura(aura => aura.Spell.IsVehicle);

            if (_passenger is Character)
            {
                var chr = (Character)_passenger;
                VehicleHandler.Send_SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA(chr);
                //SendTeleportAck
                MovementHandler.SendMoved(chr);
                MiscHandler.SendCancelAutoRepeat(chr, Vehicle);
                PetHandler.SendEmptySpells(chr);
                chr.ResetMover();
                chr.FarSight = EntityId.Zero;

                //MovementHandler.SendEnterTransport(chr);
            }
            _passenger.m_vehicleSeat = null;
            MovementHandler.SendHeartbeat(_passenger, _passenger.Position, _passenger.Orientation);
            _passenger.DecMechanicCount(SpellMechanic.Rooted, true);
            _passenger.HasPermissionToMove = true;
            _passenger.MovementFlags      &= ~MovementFlags.Root;
            _passenger = null;
        }
Esempio n. 6
0
        /// <summary>Add Passenger</summary>
        public void Enter(Unit passenger)
        {
            this._passenger                = passenger;
            passenger.m_vehicleSeat        = this;
            passenger.MovementFlags       |= MovementFlags.OnTransport;
            passenger.TransportPosition    = this.Entry.AttachmentOffset;
            passenger.TransportOrientation = this.Entry.PassengerYaw;
            ++this.Vehicle._passengerCount;
            if (this.IsDriverSeat)
            {
                this.Vehicle.Charmer    = passenger;
                passenger.Charm         = (Unit)this.Vehicle;
                this.Vehicle.UnitFlags |= UnitFlags.Possessed;
            }

            Character chr      = passenger as Character;
            Vector3   position = this.Vehicle.Position;

            if (chr != null)
            {
                VehicleHandler.Send_SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA(chr);
                VehicleHandler.SendBreakTarget((IPacketReceiver)chr, (IEntity)this.Vehicle);
            }

            MovementHandler.SendEnterTransport(passenger);
            if (chr != null)
            {
                MiscHandler.SendCancelAutoRepeat((IPacketReceiver)chr, (IEntity)this.Vehicle);
                PetHandler.SendVehicleSpells((IPacketReceiver)chr, (NPC)this.Vehicle);
            }

            passenger.IncMechanicCount(SpellMechanic.Rooted, true);
            passenger.HasPermissionToMove = false;
            passenger.MovementFlags      |= MovementFlags.Root;
            if (chr == null)
            {
                return;
            }
            chr.SetMover((WorldObject)this.Vehicle, this.IsDriverSeat);
            chr.FarSight = this.Vehicle.EntityId;
        }
Esempio n. 7
0
        public void AddNewVehicleTest()
        {
            DbConnector con  = new DbConnector();
            string      resp = con.connect();

            Assert.AreEqual("Done", resp);

            Vehicle vehicle = new Vehicle();

            vehicle.VehicleType    = "Truck";
            vehicle.ModelName      = "starz45";
            vehicle.ProductionYear = new DateTime(2015);
            vehicle.EngineNumber   = "56562651";
            vehicle.WeightLimit    = 500.20M;
            vehicle.VehicleStatus  = "Available";
            vehicle.Price          = 1522.00M;

            VehicleHandler vehicHandlr = new VehicleHandler();
            int            resp2       = vehicHandlr.addNewVehicle(con.getConn(), vehicle);

            Assert.AreEqual(1, resp2);
        }
Esempio n. 8
0
 public GetVehicleCommand(long vehicleId, ApplicationDbContext dbContext)
 {
     VehicleHandler = new VehicleHandler(dbContext);
     VehicleId      = vehicleId;
 }
Esempio n. 9
0
 public UpdateVehicleComparisonSourceCommand(ApplicationDbContext dbContext, int vehicleId, string comparisonSourceURL)
 {
     VehicleHandler      = new VehicleHandler(dbContext);
     VehicleId           = vehicleId;
     ComparisonSourceURL = comparisonSourceURL;
 }
Esempio n. 10
0
 public void ProcessVehicle(ushort vehicleId, ref Vehicle vehicle, VehicleHandler handler)
 {
     handler(vehicleId, ref vehicle);
 }
Esempio n. 11
0
 public GetVehicleTypesCommand(ApplicationDbContext dbContext)
 {
     VehicleHandler = new VehicleHandler(dbContext);
 }
Esempio n. 12
0
 public AddVehicleCommand(Vehicle vehicle, ApplicationDbContext dbContext)
 {
     VehicleHandler = new VehicleHandler(dbContext);
     NewVehicle     = vehicle;
 }
Esempio n. 13
0
 public GetTransmissionTypesCommand(ApplicationDbContext dbContext)
 {
     VehicleHandler = new VehicleHandler(dbContext);
 }
Esempio n. 14
0
        /// <summary>Remove Passenger</summary>
        public void ClearSeat()
        {
            if (this._passenger == null)
            {
                return;
            }
            if (this.IsDriverSeat)
            {
                this.Vehicle.Charmer    = (Unit)null;
                this._passenger.Charm   = (Unit)null;
                this.Vehicle.UnitFlags &= UnitFlags.CanPerformAction_Mask1 | UnitFlags.Flag_0_0x1 |
                                          UnitFlags.SelectableNotAttackable | UnitFlags.Influenced |
                                          UnitFlags.PlayerControlled | UnitFlags.Flag_0x10 | UnitFlags.Preparation |
                                          UnitFlags.PlusMob | UnitFlags.SelectableNotAttackable_2 |
                                          UnitFlags.NotAttackable | UnitFlags.Passive | UnitFlags.Looting |
                                          UnitFlags.PetInCombat | UnitFlags.Flag_12_0x1000 | UnitFlags.Silenced |
                                          UnitFlags.Flag_14_0x4000 | UnitFlags.Flag_15_0x8000 |
                                          UnitFlags.SelectableNotAttackable_3 | UnitFlags.Combat |
                                          UnitFlags.TaxiFlight | UnitFlags.Disarmed | UnitFlags.Confused |
                                          UnitFlags.Feared | UnitFlags.NotSelectable | UnitFlags.Skinnable |
                                          UnitFlags.Mounted | UnitFlags.Flag_28_0x10000000 |
                                          UnitFlags.Flag_29_0x20000000 | UnitFlags.Flag_30_0x40000000 |
                                          UnitFlags.Flag_31_0x80000000;
            }

            --this.Vehicle._passengerCount;
            if (this._passenger.MovementFlags.HasFlag((Enum)MovementFlags.Flying))
            {
                SpellCast spellCast = this.Vehicle.SpellCast;
                if (spellCast != null)
                {
                    spellCast.Trigger(SpellId.EffectParachute);
                }
            }

            this._passenger.MovementFlags &= MovementFlags.MaskMoving | MovementFlags.PitchUp |
                                             MovementFlags.PitchDown | MovementFlags.WalkMode |
                                             MovementFlags.DisableGravity | MovementFlags.Root |
                                             MovementFlags.PendingStop | MovementFlags.PendingStrafeStop |
                                             MovementFlags.PendingForward | MovementFlags.PendingBackward |
                                             MovementFlags.PendingStrafeLeft | MovementFlags.PendingStrafeRight |
                                             MovementFlags.PendingRoot | MovementFlags.Swimming | MovementFlags.CanFly |
                                             MovementFlags.Flying | MovementFlags.SplineElevation |
                                             MovementFlags.SplineEnabled | MovementFlags.Waterwalking |
                                             MovementFlags.CanSafeFall | MovementFlags.Hover | MovementFlags.LocalDirty;
            this._passenger.Auras.RemoveFirstVisibleAura((Predicate <Aura>)(aura => aura.Spell.IsVehicle));
            if (this._passenger is Character)
            {
                Character passenger = (Character)this._passenger;
                VehicleHandler.Send_SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA(passenger);
                MovementHandler.SendMoved(passenger);
                MiscHandler.SendCancelAutoRepeat((IPacketReceiver)passenger, (IEntity)this.Vehicle);
                PetHandler.SendEmptySpells((IPacketReceiver)passenger);
                passenger.ResetMover();
                passenger.FarSight = EntityId.Zero;
            }

            this._passenger.m_vehicleSeat = (VehicleSeat)null;
            MovementHandler.SendHeartbeat(this._passenger, this._passenger.Position, this._passenger.Orientation);
            this._passenger.DecMechanicCount(SpellMechanic.Rooted, true);
            this._passenger.HasPermissionToMove = true;
            this._passenger.MovementFlags      &= MovementFlags.MaskMoving | MovementFlags.PitchUp |
                                                  MovementFlags.PitchDown | MovementFlags.WalkMode |
                                                  MovementFlags.OnTransport | MovementFlags.DisableGravity |
                                                  MovementFlags.PendingStop | MovementFlags.PendingStrafeStop |
                                                  MovementFlags.PendingForward | MovementFlags.PendingBackward |
                                                  MovementFlags.PendingStrafeLeft | MovementFlags.PendingStrafeRight |
                                                  MovementFlags.PendingRoot | MovementFlags.Swimming | MovementFlags.CanFly |
                                                  MovementFlags.Flying | MovementFlags.SplineElevation |
                                                  MovementFlags.SplineEnabled | MovementFlags.Waterwalking |
                                                  MovementFlags.CanSafeFall | MovementFlags.Hover | MovementFlags.LocalDirty;
            this._passenger = (Unit)null;
        }
 public UpdateVehicleCostPerDayCommand(ApplicationDbContext dbContext, long vehicleId, int newCostPerDay)
 {
     VehicleHandler = new VehicleHandler(dbContext);
     VehicleId      = vehicleId;
     NewCostPerDay  = newCostPerDay;
 }
Esempio n. 16
0
 public VehicleController()
 {
     handler = new VehicleHandler();
 }