public EquipmentInstallationResult InstallEquipment(int equipmentIdentifier, string userReferenceName, MountPoint mountPoint) { b.Verbose.Log("InstallEquipment - selecting " + equipmentIdentifier + " as user - " + userReferenceName); CheckPreparation(); EquipmentInstallationResult result = new EquipmentInstallationResult(); ItemClassification clas = KnownEquipmentIds.GetClassificationFromId(equipmentIdentifier); if ((this.PowerPack != null) && (clas == ItemClassification.PowerPack)) { return(null); } if (namedEquipment.ContainsKey(userReferenceName)) { throw new BdBaseException("The name is already in use"); } EquipmentInstallationResult ae = engineActionProvider.MountEquipment(this, equipmentIdentifier, mountPoint); b.Assert.True(ae != null, "You have to return a result, if it failed use the status indicator."); if (ae.Result != InstallationResult.Installed) { b.Warning.Log("Failed to install equipment to " + mountPoint.ToString() + " reason " + ae.Result.ToString()); return(ae); } else { namedEquipment.Add(userReferenceName, ae); allInstalledEquipment.Add(ae); if (clas == ItemClassification.PowerPack) { b.Verbose.Log("Powerpack Installed"); this.PowerPack = ae; } } return(ae); }
private EquipmentInstallationResult PerformEquipmentInstallation(Message_BotPerformAction actionMessage) { EquipmentInstallationContext eic = (EquipmentInstallationContext)actionMessage.RequestContext; EquipmentInstallationResult result = new EquipmentInstallationResult(); var baseEquipment = equipment.GetEquipmentTypeById(eic.EquipmentIdentifier); ActiveEquipment ei = new ActiveEquipment(baseEquipment); result.InstanceId = ei.InstanceId = Guid.NewGuid(); result.EquipmentId = ei.EquipmentId = eic.EquipmentIdentifier; result.Result = InstallationResult.Installed; ei.OwningBotId = eic.OwningBotIdentity; ei.MountPoint = eic.MountPoint; ei.Classification = KnownEquipmentIds.GetClassificationFromId(eic.EquipmentIdentifier); if (ei.Classification == ItemClassification.OffsensiveWeapon) { var eq = equipment.GetWeaponEquipmentById(eic.EquipmentIdentifier); ei.RoundsRemaining = eq.InitialAmmunition; } installedEquipment.Add(ei); return(result); }