private void MainResponses(int responseID) { var data = BaseService.GetPlayerTempData(GetPC()); switch (responseID) { case 1: // Change Player Permissions if (!BasePermissionService.HasStructurePermission(GetPC(), data.StructureID, StructurePermission.CanAdjustPermissions)) { GetPC().FloatingText("You do not have permission to change other players' permissions."); return; } BuildPlayerListPage(); ChangePage("PlayerListPage"); break; case 2: // Change Public Permissions if (!BasePermissionService.HasStructurePermission(GetPC(), data.StructureID, StructurePermission.CanAdjustPublicPermissions)) { GetPC().FloatingText("You do not have permission to change this building's PUBLIC permissions."); return; } BuildPublicPermissionsPage(); ChangePage("PublicPermissionsPage"); break; } }
private void LoadManageStructureDetails() { ClearPageResponses("ManageStructureDetailsPage"); var data = BaseService.GetPlayerTempData(GetPC()); var structure = data.ManipulatingStructure.Structure; var pcBaseStructureID = data.ManipulatingStructure.Structure.Area.GetLocalString("PC_BASE_STRUCTURE_ID"); Guid?structureID = string.IsNullOrWhiteSpace(pcBaseStructureID) ? null : (Guid?)new Guid(pcBaseStructureID); bool canRetrieveStructures; bool canPlaceEditStructures; if (structureID != null) { canRetrieveStructures = BasePermissionService.HasStructurePermission(GetPC(), (Guid)structureID, StructurePermission.CanRetrieveStructures); canPlaceEditStructures = BasePermissionService.HasStructurePermission(GetPC(), (Guid)structureID, StructurePermission.CanPlaceEditStructures); } else { canRetrieveStructures = BasePermissionService.HasBasePermission(GetPC(), data.ManipulatingStructure.PCBaseID, BasePermission.CanRetrieveStructures); canPlaceEditStructures = BasePermissionService.HasBasePermission(GetPC(), data.ManipulatingStructure.PCBaseID, BasePermission.CanPlaceEditStructures); } string header = ColorTokenService.Green("Structure: ") + structure.Name + "\n\n"; header += "What would you like to do with this structure?"; SetPageHeader("ManageStructureDetailsPage", header); AddResponseToPage("ManageStructureDetailsPage", "Retrieve Structure", canRetrieveStructures); AddResponseToPage("ManageStructureDetailsPage", "Rotate", canPlaceEditStructures); }
private void DoEnterBuilding() { NWPlayer oPC = GetPC(); NWPlaceable door = GetDialogTarget().Object; string pcBaseStructureID = door.GetLocalString("PC_BASE_STRUCTURE_ID"); if (string.IsNullOrWhiteSpace(pcBaseStructureID)) { _.FloatingTextStringOnCreature("ERROR: Door doesn't have a structure ID assigned. Notify an admin about this issue.", oPC.Object, _.FALSE); return; } var structureID = new Guid(pcBaseStructureID); bool canEnterBuilding = BasePermissionService.HasStructurePermission(GetPC(), structureID, StructurePermission.CanEnterBuilding); if (!canEnterBuilding) { oPC.FloatingText("You don't have permission to enter that building."); return; } NWArea instance = BaseService.GetAreaInstance(structureID, false); if (instance == null) { instance = BaseService.CreateAreaInstance(oPC, structureID, false); } BaseService.JumpPCToBuildingInterior(oPC, instance); }
public override void Initialize() { NWPlaceable door = GetDialogTarget().Object; var structureID = new Guid(door.GetLocalString("PC_BASE_STRUCTURE_ID")); bool canEnterBuilding = BasePermissionService.HasStructurePermission(GetPC(), structureID, StructurePermission.CanEnterBuilding); SetHeader(); SetResponseVisible("MainPage", 1, canEnterBuilding); }
public void Main() { NWPlayer oPC = (_.GetLastUsedBy()); NWPlaceable container = (_.OBJECT_SELF); Guid structureID = new Guid(container.GetLocalString("PC_BASE_STRUCTURE_ID")); if (!BasePermissionService.HasStructurePermission(oPC, structureID, StructurePermission.CanAccessStructureInventory)) { oPC.FloatingText("You do not have permission to access this structure."); return; } DialogService.StartConversation(oPC, container, "StructureStorage"); }
public override void Initialize() { NWPlaceable container = (NWPlaceable)GetDialogTarget(); Guid structureID = new Guid(container.GetLocalString("PC_BASE_STRUCTURE_ID")); if (!BasePermissionService.HasStructurePermission(GetPC(), structureID, StructurePermission.CanAccessStructureInventory)) { SetResponseVisible("MainPage", 1, false); } if (!BasePermissionService.HasStructurePermission(GetPC(), structureID, StructurePermission.CanRenameStructures)) { SetResponseVisible("MainPage", 2, false); } }
private void BuildMainPageResponses() { var player = GetPC(); var data = BaseService.GetPlayerTempData(player); Player dbPlayer = DataService.Player.GetByID(player.GlobalID); Player primaryResident; bool isPrimaryResident; bool canEditPrimaryResidence; bool canRemovePrimaryResidence; if (data.BuildingType == BuildingType.Interior || data.BuildingType == BuildingType.Starship) { Guid structureID = data.StructureID; primaryResident = DataService.Player.GetByPrimaryResidencePCBaseStructureIDOrDefault(structureID); isPrimaryResident = dbPlayer.PrimaryResidencePCBaseStructureID != null && dbPlayer.PrimaryResidencePCBaseStructureID == structureID; canEditPrimaryResidence = BasePermissionService.HasStructurePermission(player, structureID, StructurePermission.CanEditPrimaryResidence); canRemovePrimaryResidence = BasePermissionService.HasStructurePermission(player, structureID, StructurePermission.CanRemovePrimaryResidence); } else if (data.BuildingType == BuildingType.Apartment) { Guid pcBaseID = data.PCBaseID; primaryResident = DataService.Player.GetByPrimaryResidencePCBaseIDOrDefault(pcBaseID); isPrimaryResident = dbPlayer.PrimaryResidencePCBaseID != null && dbPlayer.PrimaryResidencePCBaseID == pcBaseID; canEditPrimaryResidence = BasePermissionService.HasBasePermission(player, pcBaseID, BasePermission.CanEditPrimaryResidence); canRemovePrimaryResidence = BasePermissionService.HasBasePermission(player, pcBaseID, BasePermission.CanRemovePrimaryResidence); } else { throw new Exception("Invalid building type on EditPrimaryResidence conversation. Type = " + data.BuildingType); } // If another person is a resident and this player does not have the "remove" permission, don't allow them to make primary residence. if (!isPrimaryResident && primaryResident != null && !canRemovePrimaryResidence) { canEditPrimaryResidence = false; } SetResponseVisible("MainPage", 1, canEditPrimaryResidence); SetResponseVisible("MainPage", 2, canRemovePrimaryResidence || isPrimaryResident); }
public override PlayerDialog SetUp(NWPlayer player) { PlayerDialog dialog = new PlayerDialog("MainPage"); string structureID = _.GetLocalString(_.GetArea(player), "PC_BASE_STRUCTURE_ID"); if (string.IsNullOrWhiteSpace(structureID)) { player.SendMessage("Base structure ID not found on area. Please report this problem."); return(null); } Guid pcBaseStructureID = new Guid(structureID); PCBaseStructure structure = DataService.PCBaseStructure.GetByID(pcBaseStructureID); PCBase pcBase = DataService.PCBase.GetByID(structure.PCBaseID); bool bSpace = SpaceService.IsLocationSpace(pcBase.ShipLocation); List <string> options = new List <string>(); if (bSpace && BasePermissionService.HasStructurePermission(player, structure.ID, StructurePermission.CanFlyStarship)) { // See if we are near enough to the planet to land. if (SpaceService.CanLandOnPlanet(player.Area)) { options.Add("Land"); } options.Add("Pilot Ship"); options.Add("Hyperspace Jump"); } else if (BasePermissionService.HasStructurePermission(player, structure.ID, StructurePermission.CanFlyStarship)) { options.Add("Take Off"); } if (!bSpace && BasePermissionService.HasBasePermission(player, structure.PCBaseID, BasePermission.CanManageBaseFuel)) { options.Add("Access Fuel Bay"); options.Add("Access Stronidium Bay"); } if (BasePermissionService.HasBasePermission(player, structure.PCBaseID, BasePermission.CanAccessStructureInventory)) { if (!bSpace) { options.Add("Access Resource Bay"); } options.Add("Export Starcharts"); } DialogPage mainPage = new DialogPage("", options.ToArray()); dialog.AddPage("MainPage", mainPage); // Hyperspace destinations. string[] responses = SpaceService.GetHyperspaceDestinationList(pcBase); DialogPage destinationPage = new DialogPage("Please select a destination to fly to.", responses); dialog.AddPage("HyperDestPage", destinationPage); // Landing destinations. Hashtable landingspots = SpaceService.GetLandingDestinationList(player, pcBase); List <String> responseList = landingspots.Keys.Cast <String>().ToList(); DialogPage landingPage = new DialogPage("Where do you want to land?", responseList.ToArray()); dialog.AddPage("LandingDestPage", landingPage); // Save off the landing responses in CustomData. This ensures we can access the structure IDs later. foreach (var key in landingspots.Keys) { dialog.CustomData.Add("LAND_" + key, landingspots[key]); } return(dialog); }
private void DoSetAsResidence() { var player = GetPC(); var data = BaseService.GetPlayerTempData(player); var newResident = DataService.Player.GetByID(player.GlobalID); Player currentResident; bool isPrimaryResident; bool canEditPrimaryResidence; bool canRemovePrimaryResidence; if (data.BuildingType == BuildingType.Interior || data.BuildingType == BuildingType.Starship) { Guid structureID = data.StructureID; currentResident = DataService.Player.GetByPrimaryResidencePCBaseStructureIDOrDefault(structureID); isPrimaryResident = newResident.PrimaryResidencePCBaseStructureID != null && newResident.PrimaryResidencePCBaseStructureID == structureID; canEditPrimaryResidence = BasePermissionService.HasStructurePermission(player, structureID, StructurePermission.CanEditPrimaryResidence); canRemovePrimaryResidence = BasePermissionService.HasStructurePermission(player, structureID, StructurePermission.CanRemovePrimaryResidence); } else if (data.BuildingType == BuildingType.Apartment) { Guid pcBaseID = data.PCBaseID; currentResident = DataService.Player.GetByPrimaryResidencePCBaseIDOrDefault(pcBaseID); isPrimaryResident = newResident.PrimaryResidencePCBaseID != null && newResident.PrimaryResidencePCBaseID == pcBaseID; canEditPrimaryResidence = BasePermissionService.HasBasePermission(player, pcBaseID, BasePermission.CanEditPrimaryResidence); canRemovePrimaryResidence = BasePermissionService.HasBasePermission(player, pcBaseID, BasePermission.CanRemovePrimaryResidence); } else { throw new Exception("EditPrimaryResidence -> DoSetAsResidence: Can't handle building type ID " + data.BuildingType); } // If another person is a resident and this player does not have the "remove" permission, don't allow them to make primary residence. if (!isPrimaryResident && currentResident != null && !canRemovePrimaryResidence) { player.FloatingText("You do not have permission to revoke the current resident's residency."); return; } if (!canEditPrimaryResidence) { player.FloatingText("You do not have permission to select this as your primary residency."); return; } if (currentResident != null) { currentResident.PrimaryResidencePCBaseID = null; currentResident.PrimaryResidencePCBaseStructureID = null; NotifyPlayer(currentResident.ID); DataService.SubmitDataChange(currentResident, DatabaseActionType.Update); } if (data.BuildingType == BuildingType.Interior || data.BuildingType == BuildingType.Starship) { newResident.PrimaryResidencePCBaseStructureID = data.StructureID; newResident.PrimaryResidencePCBaseID = null; } else if (data.BuildingType == BuildingType.Apartment) { newResident.PrimaryResidencePCBaseStructureID = null; newResident.PrimaryResidencePCBaseID = data.PCBaseID; } DataService.SubmitDataChange(newResident, DatabaseActionType.Update); BuildMainPageHeader(); BuildMainPageResponses(); ClearNavigationStack(); ChangePage("MainPage", false); }
private void DoRotate(float degrees, bool isSet) { var data = BaseService.GetPlayerTempData(GetPC()); bool canPlaceEditStructures; var structure = data.ManipulatingStructure.Structure; if (data.BuildingType == Enumeration.BuildingType.Exterior || data.BuildingType == Enumeration.BuildingType.Apartment) { canPlaceEditStructures = BasePermissionService.HasBasePermission(GetPC(), data.ManipulatingStructure.PCBaseID, BasePermission.CanPlaceEditStructures); } else if (data.BuildingType == Enumeration.BuildingType.Interior) { var structureID = new Guid(data.ManipulatingStructure.Structure.Area.GetLocalString("PC_BASE_STRUCTURE_ID")); canPlaceEditStructures = BasePermissionService.HasStructurePermission(GetPC(), structureID, StructurePermission.CanPlaceEditStructures); } else { throw new Exception("BaseManagementTool -> DoRotate: Cannot handle building type " + data.BuildingType); } if (!canPlaceEditStructures) { GetPC().FloatingText("You don't have permission to edit structures."); return; } float facing = structure.Facing; if (isSet) { facing = degrees; } else { facing += degrees; } while (facing > 360) { facing -= 360; } structure.Facing = facing; LoadRotatePage(); var dbStructure = DataService.PCBaseStructure.GetByID(data.ManipulatingStructure.PCBaseStructureID); var baseStructure = DataService.BaseStructure.GetByID(dbStructure.BaseStructureID); dbStructure.LocationOrientation = facing; if (baseStructure.BaseStructureTypeID == (int)BaseStructureType.Building) { // The structure's facing isn't updated until after this code executes. // Build a new location object for use with spawning the door. var exteriorStyle = DataService.BuildingStyle.GetByID(Convert.ToInt32(dbStructure.ExteriorStyleID)); Location locationOverride = _.Location(data.TargetArea.Object, structure.Position, facing); data.ManipulatingStructure.ChildStructure.Destroy(); data.ManipulatingStructure.ChildStructure = BaseService.SpawnBuildingDoor(exteriorStyle.DoorRule, structure, locationOverride); // Update the cache List <AreaStructure> areaStructures = data.TargetArea.Data["BASE_SERVICE_STRUCTURES"]; var cacheStructure = areaStructures.Single(x => x.PCBaseStructureID == data.ManipulatingStructure.PCBaseStructureID && x.ChildStructure == null); int doorIndex = areaStructures.IndexOf(cacheStructure); areaStructures[doorIndex].Structure = data.ManipulatingStructure.ChildStructure; } DataService.SubmitDataChange(dbStructure, DatabaseActionType.Update); }
private void DoRetrieveStructure() { var data = BaseService.GetPlayerTempData(GetPC()); PCBaseStructure structure = DataService.PCBaseStructure.GetByID(data.ManipulatingStructure.PCBaseStructureID); BaseStructure baseStructure = DataService.BaseStructure.GetByID(structure.BaseStructureID); PCBase pcBase = DataService.PCBase.GetByID(structure.PCBaseID); BaseStructureType structureType = (BaseStructureType)baseStructure.BaseStructureTypeID; var tempStorage = _.GetObjectByTag("TEMP_ITEM_STORAGE"); var pcStructureID = structure.ID; int impoundedCount = 0; var controlTower = BaseService.GetBaseControlTower(pcBase.ID); int maxShields = BaseService.CalculateMaxShieldHP(controlTower); if (structureType == BaseStructureType.Starship) { GetPC().SendMessage("You cannot pick up starships once they are built. You can only fly them away."); return; } if (pcBase.PCBaseTypeID != (int)Enumeration.PCBaseType.Starship && pcBase.ShieldHP < maxShields && structureType != BaseStructureType.ControlTower) { GetPC().FloatingText("You cannot retrieve any structures because the control tower has less than 100% shields."); return; } bool canRetrieveStructures; if (data.BuildingType == Enumeration.BuildingType.Exterior || data.BuildingType == Enumeration.BuildingType.Apartment) { canRetrieveStructures = BasePermissionService.HasBasePermission(GetPC(), data.ManipulatingStructure.PCBaseID, BasePermission.CanRetrieveStructures); } else if (data.BuildingType == Enumeration.BuildingType.Interior || data.BuildingType == Enumeration.BuildingType.Starship) { var structureID = new Guid(data.ManipulatingStructure.Structure.Area.GetLocalString("PC_BASE_STRUCTURE_ID")); canRetrieveStructures = BasePermissionService.HasStructurePermission(GetPC(), structureID, StructurePermission.CanRetrieveStructures); } else { throw new Exception("BaseManagementTool -> DoRetrieveStructure: Cannot handle building type " + data.BuildingType); } if (!canRetrieveStructures) { GetPC().FloatingText("You don't have permission to retrieve structures."); return; } if (structureType == BaseStructureType.ControlTower) { var structureCount = DataService.PCBaseStructure.GetAllByPCBaseID(structure.PCBaseID).Count(); if (structureCount > 1) { GetPC().FloatingText("You must remove all structures in this sector before picking up the control tower."); return; } // Impound resources retrieved by drills. var items = DataService.PCBaseStructureItem.GetAllByPCBaseStructureID(structure.ID); foreach (var item in items) { ImpoundService.Impound(item); DataService.SubmitDataChange(item, DatabaseActionType.Delete); impoundedCount++; } } else if (structureType == BaseStructureType.Building) { var childStructures = DataService.PCBaseStructure.GetAllByParentPCBaseStructureID(structure.ID).ToList(); for (int x = childStructures.Count - 1; x >= 0; x--) { var furniture = childStructures.ElementAt(x); NWItem furnitureItem = BaseService.ConvertStructureToItem(furniture, tempStorage); ImpoundService.Impound(GetPC().GlobalID, furnitureItem); furnitureItem.Destroy(); DataService.SubmitDataChange(furniture, DatabaseActionType.Delete); impoundedCount++; } // Remove any primary owner permissions. var primaryOwner = DataService.Player.GetByPrimaryResidencePCBaseStructureIDOrDefault(structure.ID); if (primaryOwner != null) { primaryOwner.PrimaryResidencePCBaseStructureID = null; DataService.SubmitDataChange(primaryOwner, DatabaseActionType.Update); } // Remove any access permissions. foreach (var buildingPermission in DataService.PCBaseStructurePermission.GetAllByPCBaseStructureID(structure.ID)) { DataService.SubmitDataChange(buildingPermission, DatabaseActionType.Delete); } } else if (structureType == BaseStructureType.StarshipProduction && data.ManipulatingStructure.Structure.GetLocalInt("DOCKED_STARSHIP") == 1) { GetPC().SendMessage("You cannot move a dock that has a starship docked in it. Fly the ship away first."); return; } BaseService.ConvertStructureToItem(structure, GetPC()); DataService.SubmitDataChange(structure, DatabaseActionType.Delete); data.ManipulatingStructure.Structure.Destroy(); // Impound any fuel that's over the limit. if (structureType == BaseStructureType.StronidiumSilo || structureType == BaseStructureType.FuelSilo) { int maxFuel = BaseService.CalculateMaxFuel(pcBase.ID); int maxReinforcedFuel = BaseService.CalculateMaxReinforcedFuel(pcBase.ID); if (pcBase.Fuel > maxFuel) { int returnAmount = pcBase.Fuel - maxFuel; NWItem refund = _.CreateItemOnObject("fuel_cell", tempStorage, returnAmount); pcBase.Fuel = maxFuel; ImpoundService.Impound(pcBase.PlayerID, refund); GetPC().SendMessage("Excess fuel cells have been impounded by the planetary government. The owner of the base will need to retrieve it."); refund.Destroy(); } if (pcBase.ReinforcedFuel > maxReinforcedFuel) { int returnAmount = pcBase.ReinforcedFuel - maxReinforcedFuel; NWItem refund = _.CreateItemOnObject("stronidium", tempStorage, returnAmount); pcBase.ReinforcedFuel = maxReinforcedFuel; ImpoundService.Impound(pcBase.PlayerID, refund); GetPC().SendMessage("Excess stronidium units have been impounded by the planetary government. The owner of the base will need to retrieve it."); refund.Destroy(); } } else if (structureType == BaseStructureType.ResourceSilo) { int maxResources = BaseService.CalculateResourceCapacity(pcBase.ID); var items = DataService.PCBaseStructureItem.GetAllByPCBaseStructureID(controlTower.ID).ToList(); while (items.Count > maxResources) { var item = items.ElementAt(0); var impoundItem = new PCImpoundedItem { PlayerID = pcBase.PlayerID, ItemResref = item.ItemResref, ItemObject = item.ItemObject, DateImpounded = DateTime.UtcNow, ItemName = item.ItemName, ItemTag = item.ItemTag }; DataService.SubmitDataChange(impoundItem, DatabaseActionType.Insert); GetPC().SendMessage(item.ItemName + " has been impounded by the planetary government because your base ran out of space to store resources. The owner of the base will need to retrieve it."); DataService.SubmitDataChange(item, DatabaseActionType.Delete); } } // Update the cache List <AreaStructure> areaStructures = data.TargetArea.Data["BASE_SERVICE_STRUCTURES"]; var records = areaStructures.Where(x => x.PCBaseStructureID == pcStructureID).ToList(); for (int x = records.Count() - 1; x >= 0; x--) { var record = records[x]; record.ChildStructure?.Destroy(); areaStructures.Remove(record); } EndConversation(); if (impoundedCount > 0) { GetPC().FloatingText(impoundedCount + " item(s) were sent to the planetary impound."); } }
private void LoadMainPage() { ClearPageResponses("MainPage"); var data = BaseService.GetPlayerTempData(GetPC()); int cellX = (int)(_.GetPositionFromLocation(data.TargetLocation).m_X / 10.0f); int cellY = (int)(_.GetPositionFromLocation(data.TargetLocation).m_Y / 10.0f); string sector = BaseService.GetSectorOfLocation(data.TargetLocation); Area dbArea = DataService.Area.GetByResref(data.TargetArea.Resref); bool hasUnclaimed = false; Guid playerID = GetPC().GlobalID; int buildingTypeID = data.TargetArea.GetLocalInt("BUILDING_TYPE"); Enumeration.BuildingType buildingType = buildingTypeID <= 0 ? Enumeration.BuildingType.Exterior : (Enumeration.BuildingType)buildingTypeID; data.BuildingType = buildingType; bool canEditBasePermissions = false; bool canEditBuildingPermissions = false; bool canEditBuildingPublicPermissions = false; bool canEditStructures = false; bool canEditPrimaryResidence = false; bool canRemovePrimaryResidence = false; bool canRenameStructure = false; bool canChangeStructureMode = false; bool canEditPublicBasePermissions = false; string header = ColorTokenService.Green("Base Management Menu\n\n"); header += ColorTokenService.Green("Area: ") + data.TargetArea.Name + " (" + cellX + ", " + cellY + ")\n\n"; // Are we in a starship? if (buildingType == Enumeration.BuildingType.Starship) { Guid pcBaseStructureID = new Guid(data.TargetArea.GetLocalString("PC_BASE_STRUCTURE_ID")); var structure = DataService.PCBaseStructure.GetByID(pcBaseStructureID); var buildingStyle = DataService.BuildingStyle.GetByID(Convert.ToInt32(structure.InteriorStyleID)); int itemLimit = buildingStyle.FurnitureLimit + structure.StructureBonus; var childStructures = DataService.PCBaseStructure.GetAllByParentPCBaseStructureID(structure.ID); header += ColorTokenService.Green("Structure Limit: ") + childStructures.Count() + " / " + itemLimit + "\n"; // Get all child structures contained by this building which improve atmosphere. var structures = DataService.PCBaseStructure.GetAllByParentPCBaseStructureID(pcBaseStructureID).Where(x => { var childStructure = DataService.BaseStructure.GetByID(x.BaseStructureID); return(childStructure.HasAtmosphere); }); // Add up the total atmosphere rating, being careful not to go over the cap. int bonus = structures.Sum(x => 1 + x.StructureBonus) * 2; if (bonus > 150) { bonus = 150; } header += ColorTokenService.Green("Atmosphere Bonus: ") + bonus + "% / " + "150%"; header += "\n"; canEditPrimaryResidence = BasePermissionService.HasStructurePermission(GetPC(), pcBaseStructureID, StructurePermission.CanEditPrimaryResidence); canRemovePrimaryResidence = BasePermissionService.HasStructurePermission(GetPC(), pcBaseStructureID, StructurePermission.CanRemovePrimaryResidence); canRenameStructure = BasePermissionService.HasStructurePermission(GetPC(), pcBaseStructureID, StructurePermission.CanRenameStructures); canEditStructures = BasePermissionService.HasStructurePermission(GetPC(), pcBaseStructureID, StructurePermission.CanPlaceEditStructures); canEditBuildingPermissions = BasePermissionService.HasStructurePermission(GetPC(), pcBaseStructureID, StructurePermission.CanAdjustPermissions); canEditBuildingPublicPermissions = BasePermissionService.HasStructurePermission(GetPC(), pcBaseStructureID, StructurePermission.CanAdjustPublicPermissions); canChangeStructureMode = false; // Starships cannot be workshops. data.StructureID = pcBaseStructureID; } // Area is not buildable. else if (!dbArea.IsBuildable) { header += "Land in this area cannot be claimed. However, you can still manage any leases you own from the list below."; } // Building type is an interior of a building else if (buildingType == Enumeration.BuildingType.Interior) { Guid pcBaseStructureID = new Guid(data.TargetArea.GetLocalString("PC_BASE_STRUCTURE_ID")); var structure = DataService.PCBaseStructure.GetByID(pcBaseStructureID); var baseStructure = DataService.BaseStructure.GetByID(structure.BaseStructureID); int itemLimit = baseStructure.Storage + structure.StructureBonus; var childStructures = DataService.PCBaseStructure.GetAllByParentPCBaseStructureID(structure.ID); header += ColorTokenService.Green("Structure Limit: ") + childStructures.Count() + " / " + itemLimit + "\n"; // Get all child structures contained by this building which improve atmosphere. var structures = DataService.PCBaseStructure.GetAllByParentPCBaseStructureID(pcBaseStructureID).Where(x => { var childStructure = DataService.BaseStructure.GetByID(x.BaseStructureID); return(childStructure.HasAtmosphere); }); // Add up the total atmosphere rating, being careful not to go over the cap. int bonus = structures.Sum(x => 1 + x.StructureBonus) * 2; if (bonus > 150) { bonus = 150; } header += ColorTokenService.Green("Atmosphere Bonus: ") + bonus + "% / " + "150%"; header += "\n"; // The building must be set to the "Residence" mode in order for a primary resident to be selected. if (structure.StructureModeID == (int)StructureModeType.Residence) { canEditPrimaryResidence = BasePermissionService.HasStructurePermission(GetPC(), pcBaseStructureID, StructurePermission.CanEditPrimaryResidence); canRemovePrimaryResidence = BasePermissionService.HasStructurePermission(GetPC(), pcBaseStructureID, StructurePermission.CanRemovePrimaryResidence); } canRenameStructure = BasePermissionService.HasStructurePermission(GetPC(), pcBaseStructureID, StructurePermission.CanRenameStructures); canEditStructures = BasePermissionService.HasStructurePermission(GetPC(), pcBaseStructureID, StructurePermission.CanPlaceEditStructures); canEditBuildingPermissions = BasePermissionService.HasStructurePermission(GetPC(), pcBaseStructureID, StructurePermission.CanAdjustPermissions); canEditBuildingPublicPermissions = BasePermissionService.HasStructurePermission(GetPC(), pcBaseStructureID, StructurePermission.CanAdjustPublicPermissions); canChangeStructureMode = BasePermissionService.HasStructurePermission(GetPC(), pcBaseStructureID, StructurePermission.CanChangeStructureMode); data.StructureID = pcBaseStructureID; } // Building type is an apartment // Apartments may only ever be in the "Residence" mode. else if (buildingType == Enumeration.BuildingType.Apartment) { Guid pcBaseID = new Guid(data.TargetArea.GetLocalString("PC_BASE_ID")); var pcBase = DataService.PCBase.GetByID(pcBaseID); var buildingStyle = DataService.BuildingStyle.GetByID(Convert.ToInt32(pcBase.BuildingStyleID)); int itemLimit = buildingStyle.FurnitureLimit; var structures = DataService.PCBaseStructure.GetAllByPCBaseID(pcBase.ID); header += ColorTokenService.Green("Structure Limit: ") + structures.Count() + " / " + itemLimit + "\n"; // Add up the total atmosphere rating, being careful not to go over the cap. int bonus = structures.Sum(x => 1 + x.StructureBonus) * 2; if (bonus > 150) { bonus = 150; } header += ColorTokenService.Green("Atmosphere Bonus: ") + bonus + "% / " + "150%"; header += "\n"; canEditStructures = BasePermissionService.HasBasePermission(GetPC(), pcBaseID, BasePermission.CanPlaceEditStructures); canEditBasePermissions = BasePermissionService.HasBasePermission(GetPC(), pcBaseID, BasePermission.CanAdjustPermissions); canEditPrimaryResidence = BasePermissionService.HasBasePermission(GetPC(), pcBaseID, BasePermission.CanEditPrimaryResidence); canRemovePrimaryResidence = BasePermissionService.HasBasePermission(GetPC(), pcBaseID, BasePermission.CanRemovePrimaryResidence); canRenameStructure = BasePermissionService.HasBasePermission(GetPC(), pcBaseID, BasePermission.CanRenameStructures); data.PCBaseID = pcBaseID; } // Building type is an exterior building else if (buildingType == Enumeration.BuildingType.Exterior) { var pcBase = DataService.PCBase.GetByAreaResrefAndSectorOrDefault(data.TargetArea.Resref, sector); var northeastOwner = dbArea.NortheastOwner == null ? null : DataService.Player.GetByID((Guid)dbArea.NortheastOwner); var northwestOwner = dbArea.NorthwestOwner == null ? null : DataService.Player.GetByID((Guid)dbArea.NorthwestOwner); var southeastOwner = dbArea.SoutheastOwner == null ? null : DataService.Player.GetByID((Guid)dbArea.SoutheastOwner); var southwestOwner = dbArea.SouthwestOwner == null ? null : DataService.Player.GetByID((Guid)dbArea.SouthwestOwner); if (northeastOwner != null) { header += ColorTokenService.Green("Northeast Owner: ") + "Claimed"; if (dbArea.NortheastOwner == playerID) { header += " (" + northeastOwner.CharacterName + ")"; } header += "\n"; } else { header += ColorTokenService.Green("Northeast Owner: ") + "Unclaimed\n"; hasUnclaimed = true; } if (northwestOwner != null) { header += ColorTokenService.Green("Northwest Owner: ") + "Claimed"; if (dbArea.NorthwestOwner == playerID) { header += " (" + northwestOwner.CharacterName + ")"; } header += "\n"; } else { header += ColorTokenService.Green("Northwest Owner: ") + "Unclaimed\n"; hasUnclaimed = true; } if (southeastOwner != null) { header += ColorTokenService.Green("Southeast Owner: ") + "Claimed"; if (dbArea.SoutheastOwner == playerID) { header += " (" + southeastOwner.CharacterName + ")"; } header += "\n"; } else { header += ColorTokenService.Green("Southeast Owner: ") + "Unclaimed\n"; hasUnclaimed = true; } if (southwestOwner != null) { header += ColorTokenService.Green("Southwest Owner: ") + "Claimed"; if (dbArea.SouthwestOwner == playerID) { header += " (" + southwestOwner.CharacterName + ")"; } header += "\n"; } else { header += ColorTokenService.Green("Southwest Owner: ") + "Unclaimed\n"; hasUnclaimed = true; } canEditStructures = pcBase != null && BasePermissionService.HasBasePermission(GetPC(), pcBase.ID, BasePermission.CanPlaceEditStructures); canEditBasePermissions = pcBase != null && BasePermissionService.HasBasePermission(GetPC(), pcBase.ID, BasePermission.CanAdjustPermissions); canEditPublicBasePermissions = pcBase != null && BasePermissionService.HasBasePermission(GetPC(), pcBase.ID, BasePermission.CanAdjustPublicPermissions); if (pcBase != null) { data.PCBaseID = pcBase.ID; } } else { throw new Exception("BaseManagementTool -> Cannot locate building type with ID " + buildingTypeID); } SetPageHeader("MainPage", header); bool showManage = DataService.PCBasePermission.GetAllByPlayerID(GetPC().GlobalID).Count(x => x.CanExtendLease) > 0; AddResponseToPage("MainPage", "Manage My Leases", showManage); AddResponseToPage("MainPage", "Purchase Territory", hasUnclaimed && dbArea.IsBuildable); AddResponseToPage("MainPage", "Edit Nearby Structures", canEditStructures); AddResponseToPage("MainPage", "Edit Base Permissions", canEditBasePermissions || canEditPublicBasePermissions); AddResponseToPage("MainPage", "Edit Building Permissions", canEditBuildingPermissions || canEditBuildingPublicPermissions); AddResponseToPage("MainPage", "Edit Primary Residence", canEditPrimaryResidence || canRemovePrimaryResidence); AddResponseToPage("MainPage", "Rename Building", canRenameStructure); AddResponseToPage("MainPage", "Edit Building Mode", canChangeStructureMode); }