public VehicleSpawn(Entities.Room r, Entities.Vehicle Vehicle) : base(30000) { Append(1); Append(-1); Append(r.ID); Append(2); Append(151); Append(0); Append(1); Append(Vehicle.MapID); Append(500); Append(0); Append(1); Append(0); Append(15); Append(1); Append(5); Append(1); Append(1090909); Append(-60401); Append(1090909); Append(4256.2275); Append(1100.4197); Append(3323.0078); Append(-229.4619); Append(-33.1609); Append(-190.3880); Append(0); Append(0); Append("DU02"); }
public List <Entities.Vehicle> BuildArray(byte _mapId, byte _vehicleCount) { List <Entities.Vehicle> VehicleList = new List <Entities.Vehicle>(); foreach (string _stamp in VehicleTable) { byte _pMapId; string[] _stampParts = _stamp.Split('-'); byte.TryParse(_stampParts[0], out _pMapId); if (_pMapId == _mapId) { //0 = mapId, 1 = vehicleMapID; 2 = vehicleCode try { Entities.Vehicle Sheet = GetVehicleBy(_stampParts[2]); Entities.Vehicle Vehicle = new Entities.Vehicle(Sheet.VehicleClass, Convert.ToByte(_stampParts[1]), Sheet.Code, Sheet.SeatCount, Sheet.MaxHealth, Sheet.SpawnInterval); VehicleList.Add(Vehicle); } catch { Log.Instance.WriteError("Warning: Could not generate sheet vehicle " + _stampParts + " from vehicle types table... Vehicle not found!!!!"); } } } VehicleList.OrderBy(x => x.MapID); return(VehicleList); }
public VehicleExplode(Entities.Room r, Entities.Vehicle v) : base(30000) { Append(1); Append(-1); // Sender Append(r.ID); // Room id Append(2); Append(153); Append(0); Append(1); Append(0); Append(v.MapID); // Target Append(0); Append(2); Append(0); Append(7); Append(2); Append(0); Append(1); Append(100); Append(0); Append(0); // Coords // Append(0); Append(0); Append(0); // End Coords // Append(0); Append(0); Append(0); Append(0); Append(0); Append("FFFF"); }
public async Task <ActionResult <Entities.Vehicle> > CreateVehicle([FromBody] Entities.Vehicle vehicle) { await _repository.Create(vehicle); this.PublishEvent("create", "company.vehicle", vehicle: vehicle); return(CreatedAtAction("GetVehicles", new { vehicle.Id }, vehicle)); //CreatedAtRoute("GetVehicle", new { id = vehicle.Id }, vehicle); }
private bool IsOperative(Entities.Vehicle Vehicle) { if (Vehicle.Health > 0 && Vehicle.IsAlive) { return(true); } return(false); }
private bool isFriendlyFire(Entities.Player Attacker, Entities.Vehicle Victim) { if (Room.FriendlyFire && Attacker.Team == Victim.Team && Room.Mode != Mode.Free_For_All) { return(true); } return(false); }
private bool CanInFlictDamageTo(Entities.Player Attacker, Entities.Vehicle Vehicle) { bool _result = false; if (IsOperative(Vehicle) && Attacker.Health > 0 && Attacker.IsAlive) { if (Attacker.Team != Vehicle.Team || Room.FriendlyFire || Room.Mode == Mode.Free_For_All) { _result = true; } } return(_result); }
private void PublishEvent(string eventString, string topicString, Entities.Vehicle vehicle = null, string id = null) { Dictionary <string, object> headers = new Dictionary <string, object>(); headers.Add("Action", eventString); headers.Add("Class", "Vehicle"); if (vehicle != null) { publisher.Publish(JsonConvert.SerializeObject(vehicle), topicString, headers); } else { publisher.Publish(JsonConvert.SerializeObject(id ?? ""), topicString, headers); } return; }
protected override void Handle() { if (Room.State == RoomState.Playing && (Room.Channel == ChannelType.Urban_Ops || Room.Channel == ChannelType.Battle_Group)) { if (!Player.IsAlive) { return; } byte _targetVehicleId = GetByte(2); byte _fromTower = GetByte(3); if (_targetVehicleId >= Room.Vehicles.Count) { return; } Entities.Vehicle TargetVehicle = Room.Vehicles[_targetVehicleId]; if ((TargetVehicle.Team == Team.None || TargetVehicle.Team == Player.Team) && TargetVehicle.Health < TargetVehicle.MaxHealth) { double _repairRate; if (_fromTower == 0) { _repairRate = GetRepairRate(Player.Weapon); } else { _repairRate = 0.20; } if (_repairRate != 0) { uint _repairAmount = (uint)Math.Round(TargetVehicle.MaxHealth * _repairRate); TargetVehicle.Repair(_repairAmount); Set(3, TargetVehicle.Health); Set(4, TargetVehicle.MaxHealth); respond = true; } } } else { Player.User.Disconnect(); } }
private bool LoadVehicles() { bool _result = false; ConcurrentDictionary <string, Entities.Vehicle> tempVeh = new ConcurrentDictionary <string, Entities.Vehicle>(); MySqlCommand Queue2 = new MySqlCommand("SELECT code, seats, health, spawninterval, type from vehicletypes", Databases.Game.connection); MySqlDataReader Reader2 = Queue2.ExecuteReader(); try { if (Reader2.HasRows) { while (Reader2.Read()) { string _code = Reader2.GetString("code"); byte _seats = Reader2.GetByte("seats"); uint _health = Reader2.GetUInt32("health"); uint _spawnInterval = Reader2.GetUInt32("spawninterval"); byte _type = Reader2.GetByte("type"); Entities.Vehicle Vehicle = new Entities.Vehicle((Enums.VehicleType)_type, _code, _seats, _health, _spawnInterval, GetSeatsFor(_code)); tempVeh.TryAdd(_code, Vehicle); } Reader2.Close(); Vehicles = tempVeh; _result = true; } else { Log.Instance.WriteError("Vehicle types table is empty"); } } catch { Log.Instance.WriteError("Couldn´t load vehicle types table"); } return(_result); }
public async Task <MutationResult> ExecuteAsync(VehicleMutationsHandler handler) { var vehicle = new Entities.Vehicle( id: Id, year: Year, fuel: FuelId, color: ColorId, modelId: ModelId, photoDate: string.IsNullOrWhiteSpace(ImageBase64) ? null : (Nullable <DateTime>)DateTime.Now ); if (!string.IsNullOrWhiteSpace(ImageBase64)) { await Base64.SaveAsync(ImageBase64, EPath.Photos, $"{vehicle.Id}.jpg"); } await handler.DbContext.Vehicles.AddAsync(vehicle); var rows = await handler.DbContext.SaveChangesAsync(); return(new MutationResult(rows)); }
private int BuildVehicleComments(eDriverCommunicationType communicationType, StringBuilder sbComments, Entities.Vehicle vehicle) { switch (communicationType) { case eDriverCommunicationType.Phone: sbComments.Append("LORRY: "); break; case eDriverCommunicationType.Text: sbComments.Append("V: "); break; } sbComments.Append(vehicle.RegNo); sbComments.Append(". "); int lastLorry = vehicle.ResourceId; return(lastLorry); }
protected override void Handle() { if (Room.State != RoomState.Playing) { Player.User.Disconnect(); } //Packet info: byte _entityType = GetByte(2); //player = 1, Veh seems to be 0. Other types??? byte _targetVehicle = GetByte(4); ushort _totalDamage = GetUShort(5); long _outOfPlayableZone = GetLong(6); if (_totalDamage == 0) { return; } if (_entityType == 1) //player { if (!Player.IsAlive) { return; } if (Player.Health > _totalDamage) { Player.Health -= _totalDamage; } else { Player.AddDeaths(); Player.Health = 0; type = GameSubs.Suicide; Set(2, Player.User.RoomSlot); if (Player.Team != Team.None) { Room.CurrentGameMode.OnPlayerSuicide(Player); } } Set(7, _totalDamage); Set(8, Player.Health); respond = true; } else { Entities.Vehicle TargetVehicle = Room.Vehicles[_targetVehicle]; if (_outOfPlayableZone != 1) { TargetVehicle.Damage(_totalDamage); } else { TargetVehicle.Damage((ushort)TargetVehicle.Health); } if (!TargetVehicle.IsAlive) { //kill players string[] _buffer = new string[this.packet.Blocks.Length + 5]; foreach (Objects.VehicleSeat Seat in TargetVehicle.Seats) { Entities.Player Driver = Seat.UsedBy; if (Driver != null) { Driver.AddDeaths(); Driver.Health = 0; _buffer[0] = "1"; _buffer[1] = Player.Id.ToString(); _buffer[2] = Room.ID.ToString(); _buffer[3] = this.packet.Blocks[2]; _buffer[4] = "157"; Array.Copy(this.packet.Blocks, 0, _buffer, 5, this.packet.Blocks.Length); _buffer[2] = Driver.User.RoomSlot.ToString(); _buffer[23] = "$"; Room.Send(new Packets.GameData(_buffer).BuildEncrypted()); Room.CurrentGameMode.OnPlayerSuicide(Driver); //ur team lost points u idiot } } Room.Send(new Packets.VehicleExplode(Room, TargetVehicle).BuildEncrypted()); } else { Set(7, _totalDamage); Set(8, TargetVehicle.Health); Set(23, "$"); respond = true; } } }
public Entities.Vehicle GetVehicleBy(string _code) { Entities.Vehicle Vehicle = null; Vehicles.TryGetValue(_code, out Vehicle); return(Vehicle); }
/// <summary> /// Load Vehicle /// </summary> private void LoadVehicle() { if (ViewState["vehicle"] == null) { Facade.IVehicle facVehicle = new Facade.Resource(); vehicle = facVehicle.GetForVehicleId(m_resourceId); ViewState["vehicle"] = vehicle; } else { vehicle = (Entities.Vehicle)ViewState["vehicle"]; } if (vehicle != null) { txtRegistrationNo.Text = vehicle.RegNo; vehicleRegistrationNo = vehicle.RegNo; txtChassisNo.Text = vehicle.ChassisNo; txtTelephoneNumber.Text = vehicle.CabPhoneNumber; cboClass.SelectedIndex = -1; dteMOTExpiry.SelectedDate = vehicle.MOTExpiry; dteServiceDate.SelectedDate = vehicle.VehicleServiceDueDate; cboManufacturer.ClearSelection(); cboClass.Items.FindByValue(vehicle.VehicleClassId.ToString()).Selected = true; cboManufacturer.Items.FindByValue(vehicle.VehicleManufacturerId.ToString()).Selected = true; chkIsFixedUnit.Checked = vehicle.IsFixedUnit; pnlTrailerDetails.Visible = !vehicle.IsFixedUnit; if (pnlTrailerDetails.Visible && vehicle.TrailerResourceID.HasValue) { lblTrailer.Text = vehicle.TrailerResource; } cboVehicleType.ClearSelection(); if (vehicle.VehicleTypeID > 0) { cboVehicleType.Items.FindByValue(vehicle.VehicleTypeID.ToString()).Selected = true; } if (telematicsOption.Visible) { cboTelematicsSolution.ClearSelection(); if (vehicle.TelematicsSolution.HasValue) { cboTelematicsSolution.Items.FindByText(vehicle.TelematicsSolution.ToString()).Selected = true; } } // Need to load model after manufacturer has loaded and then loaded // model dropdown with the relevant results cboManufacturer_SelectedIndexChanged(cboManufacturer, EventArgs.Empty); cboModel.Items.FindByValue(vehicle.VehicleModelId.ToString()).Selected = true; // Need to load model after manufacturer has loaded and then loaded // model dropdown with the relevant results cboManufacturer_SelectedIndexChanged(cboManufacturer, EventArgs.Empty); cboModel.Items.FindByValue(vehicle.VehicleModelId.ToString()).Selected = true; Facade.IPoint facPoint = new Facade.Point(); Entities.Point point = facPoint.GetPointForPointId(vehicle.HomePointId); cboOrganisation.Text = point.OrganisationName; cboOrganisation.SelectedValue = point.IdentityId.ToString(); m_organisationId = point.IdentityId; m_startTown = point.PostTown.TownName; m_startTownId = point.PostTown.TownId; cboPoint.Text = point.Description; cboPoint.SelectedValue = point.PointId.ToString(); m_pointId = point.PointId; // Set the nominal code if (vehicle.NominalCodeId > 0) { cboNominalCode.Items.FindByValue(vehicle.NominalCodeId.ToString()).Selected = true; } PopulateKeys(); if (vehicle.ResourceStatus == eResourceStatus.Deleted) { chkDelete.Checked = true; } Entities.ControlArea ca = null; Entities.TrafficArea ta = null; using (Facade.IResource facResource = new Facade.Resource()) facResource.GetControllerForResourceId(vehicle.ResourceId, ref ca, ref ta); cboDepot.ClearSelection(); if (vehicle.DepotId > 0) { cboDepot.Items.FindByValue(vehicle.DepotId.ToString()).Selected = true; } if (ca != null && ta != null) { cboControlArea.ClearSelection(); cboControlArea.Items.FindByValue(ca.ControlAreaId.ToString()).Selected = true; cboTrafficArea.ClearSelection(); cboTrafficArea.Items.FindByValue(ta.TrafficAreaId.ToString()).Selected = true; } cboDedicatedToClient.SelectedValue = vehicle.DedicatedToClientIdentityID.ToString(); if (vehicle.DedicatedToClientIdentityID.HasValue) { using (var uow = DIContainer.CreateUnitOfWork()) { var repo = DIContainer.CreateRepository <IOrganisationRepository>(uow); var client = repo.Find(vehicle.DedicatedToClientIdentityID.Value); cboDedicatedToClient.Text = client.OrganisationName; } } else { cboDedicatedToClient.Text = "- none -"; } chkDelete.Visible = true; pnlVehicleDeleted.Visible = true; txtGPSUnitID.Text = vehicle.GPSUnitID; txtGPSUnitID.Text = txtGPSUnitID.Text.ToUpper(); txtThirdPartyIntegrationID.Text = (vehicle.ThirdPartyIntegrationID.HasValue) ? vehicle.ThirdPartyIntegrationID.ToString() : string.Empty; //Find all tree nodes that correspond to the org units var treeNodesToCheck = m_orgUnitTreeNodes.Where(x => vehicle.OrgUnitIDs.Contains(x.OrgUnitId.Value)); foreach (var treeNode in treeNodesToCheck) { treeNode.Checked = true; } } btnAdd.Text = "Update"; }
private void DamageVehicle(Networking.GameDataHandler handler, Entities.Player Attacker, Entities.Vehicle DamagedVehicle, short _damageTaken) { DamagedVehicle.Damage((ushort)_damageTaken); if (DamagedVehicle.IsAlive) //vehicle is still ok { handler.type = GameSubs.ObjectDamage; handler.Set(12, DamagedVehicle.Health); handler.Set(13, _damageTaken); handler.respond = true; } else //vehicle has been destroyed { if (DamagedVehicle.Team != Team.None) { //Creating the death packet from the original buffer foreach (Objects.VehicleSeat Seat in DamagedVehicle.Seats) { Entities.Player Victim = Seat.UsedBy; if (Victim != null && Victim.IsAlive) { Networking.GameDataHandler DeathHandler = Managers.PacketManager.Instance.GetHandler((ushort)GameSubs.PlayerDeath); if (DeathHandler != null) { try { DeathHandler.Process(Victim.User, handler.GetIncPacket()); if (!isFriendlyFire(Attacker, Victim)) { Victim.AddDeaths(); Attacker.AddKill(false); } else { Attacker.SubtractKill(); Attacker.AddFakeDeath(); } OnDeath(Attacker, Victim); } catch { ServerLogger.Instance.Append(ServerLogger.AlertLevel.ServerError, string.Concat("Could not kill player ", Victim.User.Displayname, " on vehicle ", DamagedVehicle.Code)); } } } } } //Destroying veh handler.type = GameSubs.ObjectDestroy; handler.Set(12, DamagedVehicle.Health); handler.Set(13, _damageTaken); handler.Set(14, 15); handler.respond = true; if (!isFriendlyFire(Attacker, DamagedVehicle)) { Attacker.VehiclesDestroyed++; Attacker.User.VehiclesDestroyed++; } ServerLogger.Instance.Append(ServerLogger.AlertLevel.Gaming, string.Concat(Attacker.User.Displayname, " destroyed a vehicle: ", DamagedVehicle.Code)); } }
public virtual void OnObjectDamage(Networking.GameDataHandler handler) { bool _isPlayer = handler.GetBool(2); byte _objectDamagedId = handler.GetByte(3); bool _isSubWeapon = handler.GetBool(9); bool _isRadiusWeapon = handler.GetBool(10); uint _radius = handler.GetuInt(11); //vehicles don´t seem to have a hitbox string _weaponCode = handler.GetString(22).ToUpper(); short _damageTaken = 0; Entities.Player Attacker = handler.Player; Entities.Vehicle VehicleDamaged = null; Objects.Items.Weapon Weapon = null; try { VehicleDamaged = Room.Vehicles[_objectDamagedId]; } catch { VehicleDamaged = null; Log.Instance.WriteError("Unknown damaged object with ID: " + _objectDamagedId.ToString()); } if (VehicleDamaged != null && CanInFlictDamageTo(Attacker, VehicleDamaged)) { if (_isPlayer) { try { Weapon = (Objects.Items.Weapon)Managers.ItemManager.Instance.Items.Values.Where(n => n.Code == _weaponCode).First(); } catch { Weapon = null; } if (Weapon != null) { short _weaponMultiplier = 100; switch (VehicleDamaged.VehicleClass) { case VehicleType.Surface: _weaponMultiplier = Weapon.PowerSurface[0]; break; case VehicleType.Air: _weaponMultiplier = Weapon.PowerAir[0]; break; case VehicleType.Ship: _weaponMultiplier = Weapon.PowerShip[0]; break; default: _weaponMultiplier = Weapon.PowerPersonal[0]; break; } _damageTaken = DamageCalculator(Weapon.Power, _weaponMultiplier, _radius); } } else //Vehicle attaking other vehicle { if (Attacker.VehicleId != -1) { Entities.Vehicle AttackerVehicle = Room.Vehicles[Attacker.VehicleId]; if (_weaponCode == AttackerVehicle.Code) //dont trust the client { Objects.VehicleSeat Seat = AttackerVehicle.Seats[AttackerVehicle.GetSeatOf(Attacker)]; Objects.VehicleWeapon VehWeapon = null; if (_isSubWeapon) //he is shooting with the subCT { Seat.Weapons.TryGetValue(VehicleWeaponType.Sub, out VehWeapon); } else { Seat.Weapons.TryGetValue(VehicleWeaponType.Main, out VehWeapon); } if (VehWeapon != null) { _damageTaken = DamageCalculator((short)VehWeapon.Damage, VehWeapon.HitBox[(byte)VehicleDamaged.VehicleClass], _radius); } } } else //maybe it´s an artillery attack { if (!isValidArtilleryAttack(Attacker)) { Attacker.User.Disconnect(); } Objects.VehicleWeapon Artillery = Managers.VehicleManager.Instance.GetWeaponBy(_weaponCode); if (Artillery != null) { _damageTaken = DamageCalculator((short)Artillery.Damage, Artillery.HitBox[(byte)VehicleDamaged.VehicleClass], _radius); } else { Log.Instance.WriteError("Couldn´t find artillery weapon " + _weaponCode + " in the Manager"); } } } DamageVehicle(handler, Attacker, VehicleDamaged, _damageTaken); } }
void cboVehicle_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e) { ((Telerik.Web.UI.RadComboBox)sender).Items.Clear(); Telerik.Web.UI.RadComboBoxItem rcItem = new Telerik.Web.UI.RadComboBoxItem(); DataSet ds = null; string[] clientArgs = e.Context["FilterString"].ToString().Split(':'); if (e.Context["FilterString"] != null) { if (clientArgs[0] == "true") { // Get the Drivers usual vehicle Facade.IDriver facDriver = new Facade.Resource(); Entities.Driver driver = facDriver.GetDriverForResourceId(int.Parse(clientArgs[1])); Entities.Vehicle vehicle = ((Facade.IVehicle)facDriver).GetForVehicleId(driver.AssignedVehicleId); if (vehicle != null) { rcItem.Text = vehicle.RegNo; rcItem.Value = vehicle.ResourceId.ToString(); rcItem.Selected = true; ((Telerik.Web.UI.RadComboBox)sender).Items.Add(rcItem); } } else { int controlAreaId = 0; int[] trafficAreas = new int[clientArgs.Length - 1]; controlAreaId = int.Parse(clientArgs[0]); for (int i = 1; i < clientArgs.Length; i++) { trafficAreas[i - 1] = int.Parse(clientArgs[i]); } Facade.IResource facResource = new Facade.Resource(); ds = facResource.GetAllResourcesFiltered(e.Text, eResourceType.Vehicle, controlAreaId, trafficAreas, true); } } else { Facade.IResource facResource = new Facade.Resource(); ds = facResource.GetAllResourcesFiltered(e.Text, eResourceType.Vehicle, false); } if (ds != null) { int itemsPerRequest = 20; int itemOffset = e.NumberOfItems; int endOffset = itemOffset + itemsPerRequest; if (endOffset > ds.Tables[0].Rows.Count) { endOffset = ds.Tables[0].Rows.Count; } DataTable dt = ds.Tables[0]; for (int i = itemOffset; i < endOffset; i++) { rcItem = new Telerik.Web.UI.RadComboBoxItem(); rcItem.Text = dt.Rows[i]["Description"].ToString(); rcItem.Value = dt.Rows[i]["ResourceId"].ToString(); ((Telerik.Web.UI.RadComboBox)sender).Items.Add(rcItem); } if (dt.Rows.Count > 0) { e.Message = string.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), dt.Rows.Count.ToString()); } } }
/// <summary> /// Populate Vehicle /// </summary> private void populateVehicle() { if (ViewState["vehicle"] == null) { vehicle = new Entities.Vehicle(); if (m_resourceId > 0) { vehicle.ResourceId = m_resourceId; } if (Orchestrator.Globals.Configuration.FleetMetrikInstance) { // set the owner organisation, home point and last known location Facade.IOrganisation facOrganisation = new Facade.Organisation(); Entities.Organisation ownerOrg = facOrganisation.GetForIdentityId(Configuration.IdentityId); vehicle.HomePointId = ownerOrg.Locations.GetHeadOffice().Point.PointId; vehicle.DepotId = ownerOrg.Locations.GetHeadOffice().OrganisationLocationId; } } else { vehicle = (Entities.Vehicle)ViewState["vehicle"]; } vehicle.ResourceType = eResourceType.Vehicle; vehicle.VehicleClassId = Convert.ToInt32(cboClass.Items[cboClass.SelectedIndex].Value); vehicle.VehicleManufacturerId = Convert.ToInt32(cboManufacturer.Items[cboManufacturer.SelectedIndex].Value); vehicle.VehicleModelId = Convert.ToInt32(cboModel.Items[cboModel.SelectedIndex].Value); vehicle.RegNo = txtRegistrationNo.Text; vehicle.ChassisNo = txtChassisNo.Text; vehicle.MOTExpiry = dteMOTExpiry.SelectedDate.Value; vehicle.VehicleServiceDueDate = dteServiceDate.SelectedDate.Value; vehicle.CabPhoneNumber = txtTelephoneNumber.Text; if (!Orchestrator.Globals.Configuration.FleetMetrikInstance) { if (Orchestrator.Globals.Configuration.ShowVehicleDepot) { vehicle.DepotId = Convert.ToInt32(cboDepot.SelectedValue); } else { Facade.IOrganisation facOrganisation = new Facade.Organisation(); Entities.Organisation ownerOrg = facOrganisation.GetForIdentityId(Configuration.IdentityId); vehicle.DepotId = ownerOrg.Locations.GetHeadOffice().OrganisationLocationId; } vehicle.HomePointId = Convert.ToInt32(cboPoint.SelectedValue); } vehicle.IsFixedUnit = chkIsFixedUnit.Checked; vehicle.IsTTInstalled = true; vehicle.VehicleTypeID = Convert.ToInt32(cboVehicleType.Items[cboVehicleType.SelectedIndex].Value); vehicle.NominalCodeId = Convert.ToInt32(cboNominalCode.Items[cboNominalCode.SelectedIndex].Value); // if the telematics option is visible use the selected solution (validation enforces a non-null selection) if (telematicsOption.Visible) { vehicle.TelematicsSolution = (eTelematicsSolution?)Enum.Parse(typeof(eTelematicsSolution), cboTelematicsSolution.SelectedValue); } else { // if telematics option is not visible and we're creating, use the default if (!m_isUpdate && ViewState["defaultTelematicsSolution"] != null) { vehicle.TelematicsSolution = (eTelematicsSolution)ViewState["defaultTelematicsSolution"]; } //otherwise leave the telematics solution as it is } if (chkDelete.Checked) { vehicle.ResourceStatus = eResourceStatus.Deleted; } else { vehicle.ResourceStatus = eResourceStatus.Active; } vehicle.GPSUnitID = txtGPSUnitID.Text.ToUpper(); vehicle.DedicatedToClientIdentityID = Utilities.ParseNullable <int>(cboDedicatedToClient.SelectedValue); vehicle.ThirdPartyIntegrationID = (string.IsNullOrEmpty(txtThirdPartyIntegrationID.Text)) ? (long?)null : (long?)long.Parse(txtThirdPartyIntegrationID.Text); vehicle.OrgUnitIDs = trvResourceGrouping.CheckedNodes.Select(x => Int32.Parse(x.Attributes["OrgUnitID"])).ToList(); }
private void OnVehicleAttackToPlayer(Networking.GameDataHandler handler, Entities.Player Attacker, Entities.Player Victim) { Entities.Vehicle AttackerVehicle = null; string _vehicleId = handler.GetString(22).ToUpper(); try { AttackerVehicle = handler.Room.Vehicles[Attacker.VehicleId]; } catch { AttackerVehicle = null; } if (AttackerVehicle != null) { if (CanInFlictDamageTo(Attacker, Victim) && IsOperative(AttackerVehicle)) { if (_vehicleId == AttackerVehicle.Code) { Objects.VehicleSeat Seat = AttackerVehicle.Seats[Attacker.VehicleSeatId]; if (Seat.Weapons.Count > 0) { byte _weaponSlot = handler.GetByte(9); //0 = main CT, 1 = subCT Objects.VehicleWeapon Weapon = null; Seat.Weapons.TryGetValue((VehicleWeaponType)_weaponSlot, out Weapon); if (Weapon != null) { //Most vehicles uses Radius even for machineguns... yeah odd short _damageTaken = 0; double _hitboxMultiplier = 1.0; bool _useRadius = handler.GetBool(10); uint _boneId = handler.GetuInt(11); uint _radius = _boneId; uint _realBoneId = _boneId - handler.Player.User.SessionID; //just to make sure... if (!_useRadius) { Enums.Hitbox Location; try { Location = (Hitbox)_realBoneId; } catch { Location = Hitbox.TorsoLimbs; } _hitboxMultiplier = GetHitBoxMultiplier(Location); _radius = 100; } _damageTaken = DamageCalculator((short)Weapon.Damage, Weapon.HitBox[(byte)VehWeapDamType.Personal], _radius); DamagePlayer(handler, Attacker, Victim, _damageTaken, false); } } } } } else //Artillery Attack? { Objects.VehicleWeapon Artillery = null; Artillery = Managers.VehicleManager.Instance.GetWeaponBy(handler.GetString(22).ToUpper()); if (Artillery != null && isValidArtilleryAttack(Attacker)) { uint _radius = handler.GetuInt(11); short _damageTaken = DamageCalculator((short)Artillery.Damage, Artillery.HitBox[(byte)VehWeapDamType.Personal], _radius); DamagePlayer(handler, Attacker, Victim, _damageTaken, false); } else { Attacker.User.Disconnect(); } } }
public async Task <bool> Update(Entities.Vehicle vehicle) { var updated = await _context.Vehicles.ReplaceOneAsync(filter : item => item.Id == vehicle.Id, replacement : vehicle); return(updated.IsAcknowledged && updated.ModifiedCount > 0); }
public async Task <IActionResult> UpdateVehicle([FromBody] Entities.Vehicle vehicle) { this.PublishEvent("update", "company.vehicle", vehicle: vehicle); return(Ok(await _repository.Update(vehicle))); }
private void LoadCommunication() { Facade.IInstruction facInstrucion = new Facade.Instruction(); var jobInstructions = facInstrucion.GetForJobId(_jobId); var instruction = jobInstructions.Single(i => i.InstructionID == _instructionID); // Get the driver. Facade.IDriver facDriver = new Facade.Resource(); Entities.Driver driver = facDriver.GetDriverForResourceId(_driverId); var communicationTypes = Utilities.GetEnumPairs <eDriverCommunicationType>(); // We don't offer the option to communicate by Tough Touch if the driver doesn't have a passcode or the vehicle doesn't have a Tough Touch installed. if (string.IsNullOrWhiteSpace(driver.Passcode) || instruction.Vehicle == null || !instruction.Vehicle.IsTTInstalled) { communicationTypes.Remove((int)eDriverCommunicationType.ToughTouch); } cboCommunicationType.DataSource = communicationTypes; cboCommunicationType.DataBind(); cboCommunicationType.Items.Insert(0, new ListItem("-- Select a communication type --", "")); cboCommunicationType.Attributes.Add("onchange", "cboCommunicationTypeIndex_Changed();"); cboCommunicationStatus.DataSource = Utilities.UnCamelCase(Enum.GetNames(typeof(eDriverCommunicationStatus))); cboCommunicationStatus.DataBind(); RadioButton rb = null; Entities.ContactCollection contacts = new Entities.ContactCollection(); if (driver != null && driver.Individual.Contacts != null) { contacts = driver.Individual.Contacts; } // Get the vehicle the driver is currently assigned to. Facade.IJourney facJourney = new Facade.Journey(); Entities.Vehicle currentVehicle = facJourney.GetCurrentVehicleForDriver(_driverId); if (currentVehicle != null) { contacts.Add(new Entities.Contact(eContactType.MobilePhone, currentVehicle.CabPhoneNumber)); } Entities.ContactCollection cs = new Orchestrator.Entities.ContactCollection(); rb = new RadioButton(); bool numberSelected = false; foreach (Entities.Contact contact in contacts) { if (contact.ContactDetail.Length > 0) { rb = new RadioButton(); rb.GroupName = "rblNumbers"; rb.Text = contact.ContactDetail; rb.Attributes.Add("onclick", "setNumberUsed('" + contact.ContactDetail + "');"); if (contact.ContactType == eContactType.MobilePhone || contact.ContactType == eContactType.PersonalMobile || contact.ContactType == eContactType.Telephone) { if (!numberSelected) { rb.Checked = true; txtNumber.Text = contact.ContactDetail; numberSelected = true; } } plcNumbers.Controls.Add(rb); plcNumbers.Controls.Add(new LiteralControl("<br/>")); } } rb = new RadioButton(); rb.Text = "Other"; rb.GroupName = "rblNumbers"; rb.Attributes.Add("onclick", "enableOtherTextBox();"); plcNumbers.Controls.Add(rb); bool isInvolvedInLoad = false; foreach (Entities.Instruction i in jobInstructions) { if (i.Driver != null && i.Driver.ResourceId == _driverId) { if ((eInstructionType)i.InstructionTypeId == eInstructionType.Load) { isInvolvedInLoad = true; } } } trLoadOrder.Visible = isInvolvedInLoad; if (isInvolvedInLoad) { var loadComments = BuildLoadComments(_driverId, jobInstructions); lblLoadOrder.Text = loadComments; trLoadOrder.Visible = !string.IsNullOrWhiteSpace(loadComments); } var legPlan = new Facade.Instruction().GetLegPlan(jobInstructions, false); txtComments.Text = GetComments(legPlan, eDriverCommunicationType.Phone); txtSMSText.Text = GetComments(legPlan, eDriverCommunicationType.Text); var defaultCommunicationTypeID = driver.DefaultCommunicationTypeID == 0 ? (int)eDriverCommunicationType.Phone : driver.DefaultCommunicationTypeID; //lookup the communication type in the drop down, dont select if it doesnt exist - this should only happen if the driver whos default method of communitication // is tough touch but has now moved into a vechicial without one being installed if (cboCommunicationType.Items.FindByValue(defaultCommunicationTypeID.ToString()) != null) { cboCommunicationType.Items.FindByValue(defaultCommunicationTypeID.ToString()).Selected = true; } Facade.IControlArea facControlArea = new Facade.Traffic(); cboControlArea.DataSource = facControlArea.GetAll(); cboControlArea.DataBind(); for (int instructionIndex = jobInstructions.Count - 1; instructionIndex >= 0; instructionIndex--) { if (jobInstructions[instructionIndex].Driver != null && jobInstructions[instructionIndex].Driver.ResourceId == _driverId) { hidLastInstructionInvolvedWith.Value = jobInstructions[instructionIndex].InstructionOrder.ToString(); cboControlArea.ClearSelection(); cboControlArea.Items.FindByValue(jobInstructions[instructionIndex].Point.Address.TrafficArea.ControlAreaId.ToString()).Selected = true; BindTrafficAreas(Convert.ToInt32(cboControlArea.SelectedValue), jobInstructions[instructionIndex].Point.Address.TrafficArea.TrafficAreaId); break; } } ShowPCVS(); }
public async Task Create(Entities.Vehicle vehicle) { await _context.Vehicles.InsertOneAsync(vehicle); }