コード例 #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
        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);
            }
        }
コード例 #3
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));
                }
            }
        }
コード例 #4
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);
        }
コード例 #5
0
        private void BuildMainPage()
        {
            NWPlayer oPC = GetPC();
            string   header;
            Model    model = GetDialogCustomData <Model>();

            ClearPageResponses("MainPage");

            if (model.ConstructionSiteID <= 0)
            {
                header = "Please select an option.";

                if (model.IsTerritoryFlag)
                {
                    AddResponseToPage("MainPage", "Select Blueprint");
                    AddResponseToPage("MainPage", "Move");
                    AddResponseToPage("MainPage", _color.Red("Raze"));
                }
                else
                {
                    AddResponseToPage("MainPage", "Select Blueprint", _structure.PlayerHasPermission(oPC, StructurePermission.CanBuildStructures, model.FlagID));
                    AddResponseToPage("MainPage", "Move", _structure.PlayerHasPermission(oPC, StructurePermission.CanMoveStructures, model.FlagID));
                    AddResponseToPage("MainPage", _color.Red("Raze"), _structure.PlayerHasPermission(oPC, StructurePermission.CanRazeStructures, model.FlagID));
                }
            }
            else
            {
                Data.Entities.ConstructionSite entity = _structure.GetConstructionSiteByID(model.ConstructionSiteID);

                header = _color.Green("Blueprint: ") + entity.StructureBlueprint.Name + "\n";
                if (entity.StructureBlueprint.IsVanity)
                {
                    header += _color.Green("Type: ") + "Vanity\n";
                }
                if (entity.StructureBlueprint.IsSpecial)
                {
                    header += _color.Green("Type: ") + "Special\n";
                }
                if (entity.StructureBlueprint.IsResource)
                {
                    header += _color.Green("Type: ") + "Resource\n";
                }
                if (entity.StructureBlueprint.IsBuilding)
                {
                    header += _color.Green("Type: ") + "Building\n";
                }

                header += _color.Green("Level: ") + entity.StructureBlueprint.Level + "\n";

                header += _color.Green("Required Tool Level: ") + entity.StructureBlueprint.CraftTierLevel + "\n\n";


                if (entity.StructureBlueprint.MaxBuildDistance > 0.0f)
                {
                    header += _color.Green("Build Distance: ") + entity.StructureBlueprint.MaxBuildDistance + " meters" + "\n";
                }
                if (entity.StructureBlueprint.VanityCount > 0)
                {
                    header += _color.Green("Max # of Vanity Structures: ") + entity.StructureBlueprint.VanityCount + "\n";
                }
                if (entity.StructureBlueprint.SpecialCount > 0)
                {
                    header += _color.Green("Max # of Special Structures: ") + entity.StructureBlueprint.SpecialCount + "\n";
                }
                if (entity.StructureBlueprint.ItemStorageCount > 0)
                {
                    header += _color.Green("Item Storage: ") + entity.StructureBlueprint.ItemStorageCount + " items" + "\n";
                }
                if (entity.BuildingInterior != null)
                {
                    header += _color.Green("Interior Layout: ") + entity.BuildingInterior.Name + "\n";
                }

                header += _color.Green("Resources Required: ") + "\n\n";

                foreach (ConstructionSiteComponent comp in entity.ConstructionSiteComponents)
                {
                    header += comp.Quantity > 0 ? comp.Quantity + "x " + _item.GetNameByResref(comp.StructureComponent.Resref) + "\n" : "";
                }

                AddResponseToPage("MainPage", "Quick Build", _authorization.IsPCRegisteredAsDM(GetPC()));
                AddResponseToPage("MainPage", "Build");
                AddResponseToPage("MainPage", "Preview");
                AddResponseToPage("MainPage", "Preview Interior", entity.BuildingInterior != null);
                AddResponseToPage("MainPage", "Change Interior Layout", entity.BuildingInterior != null);
                AddResponseToPage("MainPage", "Rotate", _structure.PlayerHasPermission(oPC, StructurePermission.CanRotateStructures, model.FlagID));
                AddResponseToPage("MainPage", "Move", _structure.PlayerHasPermission(oPC, StructurePermission.CanMoveStructures, model.FlagID));
                AddResponseToPage("MainPage", _color.Red("Raze"), _structure.PlayerHasPermission(oPC, StructurePermission.CanRazeStructures, model.FlagID));
            }

            SetPageHeader("MainPage", header);
        }