private void BuildMainMenuResponses(NWObject excludeObject) { NWPlayer oPC = GetPC(); ClearPageResponses("MainPage"); Model model = GetDialogCustomData <Model>(); model.NearbyStructures.Clear(); model.ActiveStructure = null; DialogResponse constructionSiteResponse = new DialogResponse(_color.Green("Create Construction Site")); if (_structure.CanPCBuildInLocation(GetPC(), model.TargetLocation, StructurePermission.CanBuildStructures) != 1) { constructionSiteResponse.IsActive = false; } AddResponseToPage("MainPage", constructionSiteResponse); int flagID = _structure.GetTerritoryFlagID(model.Flag); if (!_structure.PlayerHasPermission(oPC, StructurePermission.CanMoveStructures, flagID) && !_structure.PlayerHasPermission(oPC, StructurePermission.CanRazeStructures, flagID) && !_structure.PlayerHasPermission(oPC, StructurePermission.CanRotateStructures, flagID)) { return; } for (int current = 1; current <= 30; current++) { NWPlaceable structure = NWPlaceable.Wrap(_.GetNearestObjectToLocation(OBJECT_TYPE_PLACEABLE, model.TargetLocation, current)); Location structureLocation = structure.Location; float distance = _.GetDistanceBetweenLocations(model.TargetLocation, structureLocation); if (distance > 15.0f) { break; } if (_structure.GetPlaceableStructureID(structure) > 0 && structure.GetLocalInt("IS_BUILDING_DOOR") == 0) { model.NearbyStructures.Add(structure); } } foreach (NWPlaceable structure in model.NearbyStructures) { if (excludeObject == null || !Equals(excludeObject, structure)) { AddResponseToPage("MainPage", structure.Name, true, new Tuple <string, dynamic>(string.Empty, structure)); } } }
public override void Initialize() { Model model = GetDialogCustomData <Model>(); // Buildings - get flag ID from the area if (GetDialogTarget().GetLocalInt("IS_BUILDING_DOOR") == 1) { int structureID = _structure.GetPlaceableStructureID((NWPlaceable)GetDialogTarget()); if (structureID <= 0) { model.FlagID = GetDialogTarget().Area.GetLocalInt("TERRITORY_FLAG_ID"); } else { var flag = _structure.GetPCTerritoryFlagByBuildingStructureID(structureID); model.FlagID = flag.PCTerritoryFlagID; } // Razing is disabled for buildings SetResponseVisible("MainPage", 4, false); // Raze territory } // Regular territories - get flag ID from the territory flag object else { int flagID = _structure.GetTerritoryFlagID(GetDialogTarget()); model.FlagID = flagID; model.FlagMarker = (NWPlaceable)GetDialogTarget(); } SetDialogCustomData(model); BuildMainPageHeader(); }
private void InitializeConstructionSite() { NWPlaceable site = (NWPlaceable)GetDialogTarget(); NWObject existingFlag = _structure.GetTerritoryFlagOwnerOfLocation(GetDialogTarget().Location); Model model = GetDialogCustomData <Model>(); float distance = _.GetDistanceBetween(existingFlag.Object, GetDialogTarget().Object); if (!existingFlag.IsValid) { model.IsTerritoryFlag = true; } else { int flagID = _structure.GetTerritoryFlagID(existingFlag); model.FlagID = flagID; PCTerritoryFlag entity = _structure.GetPCTerritoryFlagByID(flagID); if (distance <= entity.StructureBlueprint.MaxBuildDistance || Equals(site.Area, existingFlag)) { model.IsTerritoryFlag = false; } else { model.IsTerritoryFlag = true; } } model.ConstructionSiteID = _structure.GetConstructionSiteID(site); SetDialogCustomData(model); }
public override void Initialize() { NWPlayer oPC = GetPC(); NWPlaceable door = (NWPlaceable)GetDialogTarget(); Location location = door.Location; NWObject flag = _structure.GetTerritoryFlagOwnerOfLocation(location); int territoryFlagID = _structure.GetTerritoryFlagID(flag); int structureID = _structure.GetPlaceableStructureID(door); int buildingFlagID = _structure.GetPCTerritoryFlagByBuildingStructureID(structureID).PCTerritoryFlagID; // Only players with permission can enter the building if (!_structure.PlayerHasPermission(oPC, StructurePermission.CanEnterBuildings, territoryFlagID) && !_structure.PlayerHasPermission(oPC, StructurePermission.CanEnterBuildings, buildingFlagID)) { SetResponseVisible("MainPage", 1, false); } // Only territory owner or building owner may adjust permissions. BuildingOwners owners = _structure.GetBuildingOwners(territoryFlagID, structureID); if (oPC.GlobalID != owners.TerritoryOwner && oPC.GlobalID != owners.BuildingOwner) { SetResponseVisible("MainPage", 3, false); } }
public override void Initialize() { NWPlayer oPC = GetPC(); NWPlaceable door = (NWPlaceable)GetDialogTarget(); NWArea area = door.Area; Location location = door.Location; NWObject flag = _structure.GetTerritoryFlagOwnerOfLocation(location); int territoryFlagID = _structure.GetTerritoryFlagID(flag); int structureID = _structure.GetPlaceableStructureID(door); // Only territory owner or building owner may adjust permissions. BuildingOwners owners = _structure.GetBuildingOwners(territoryFlagID, structureID); if (oPC.GlobalID != owners.TerritoryOwner && oPC.GlobalID != owners.BuildingOwner) { SetResponseVisible("MainPage", 3, false); } if (area.GetLocalInt("IS_BUILDING_PREVIEW") == 1) { SetResponseVisible("MainPage", 2, false); SetResponseVisible("MainPage", 3, false); } }
public bool Run(params object[] args) { NWPlaceable site = NWPlaceable.Wrap(Object.OBJECT_SELF); NWPlayer oPC = NWPlayer.Wrap(_.GetLastUsedBy()); int flagID = _structure.GetTerritoryFlagID(site); PCTerritoryFlag entity = _structure.GetPCTerritoryFlagByID(flagID); if (oPC.GlobalID != entity.PlayerID && !oPC.IsDM) { oPC.SendMessage("Only the owner of the territory may use this."); } else { _dialog.StartConversation(oPC, site, "TerritoryFlag"); } return(true); }