コード例 #1
0
        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);
            }
        }
コード例 #2
0
ファイル: BuildToolMenu.cs プロジェクト: zunath/Freescape
        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));
                }
            }
        }
コード例 #3
0
        public override void Initialize()
        {
            int structureID = _structure.GetPlaceableStructureID((NWPlaceable)GetDialogTarget());
            PCTerritoryFlagsStructure structure = _structure.GetPCStructureByID(structureID);

            if (!_structure.PlayerHasPermission(GetPC(), StructurePermission.CanAccessPersistentStorage, structure.PCTerritoryFlagID))
            {
                SetResponseVisible("MainPage", 1, false);
            }

            if (!_structure.PlayerHasPermission(GetPC(), StructurePermission.CanRenameStructures, structure.PCTerritoryFlagID))
            {
                SetResponseVisible("MainPage", 2, false);
            }
        }
コード例 #4
0
        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();
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        public bool Run(params object[] args)
        {
            NWPlayer    oPC                     = NWPlayer.Wrap(_.GetLastUsedBy());
            NWPlaceable objSelf                 = NWPlaceable.Wrap(Object.OBJECT_SELF);
            int         structureID             = _structure.GetPlaceableStructureID(objSelf);
            PCTerritoryFlagsStructure structure = _structure.GetPCStructureByID(structureID);

            if (_structure.PlayerHasPermission(oPC, StructurePermission.CanAccessPersistentStorage, structure.PCTerritoryFlagID) ||
                _structure.PlayerHasPermission(oPC, StructurePermission.CanRenameStructures, structure.PCTerritoryFlagID))
            {
                _dialog.StartConversation(oPC, objSelf, "StructureStorage");
            }
            else
            {
                oPC.FloatingText("You do not have permission to access this structure.");
            }

            return(true);
        }