Beispiel #1
0
        private void LoadCategoryPageResponses()
        {
            Model model = GetDialogCustomData <Model>();

            ClearPageResponses("BlueprintCategoryPage");

            PCTerritoryFlag         flag   = _structure.GetPCTerritoryFlagByID(model.FlagID);
            TerritoryStructureCount counts = _structure.GetNumberOfStructuresInTerritory(model.FlagID);

            List <StructureCategory> categories = _structure.GetStructureCategoriesByType(GetPC().GlobalID, model.IsTerritoryFlag, false, false, false, false).ToList();

            if (flag != null && counts.VanityCount < flag.StructureBlueprint.VanityCount)
            {
                categories.AddRange(_structure.GetStructureCategoriesByType(GetPC().GlobalID, model.IsTerritoryFlag, true, false, false, false));
            }
            if (flag != null && counts.SpecialCount < flag.StructureBlueprint.SpecialCount)
            {
                categories.AddRange(_structure.GetStructureCategoriesByType(GetPC().GlobalID, model.IsTerritoryFlag, false, true, false, false));
            }
            if (flag != null && counts.ResourceCount < flag.StructureBlueprint.ResourceCount)
            {
                categories.AddRange(_structure.GetStructureCategoriesByType(GetPC().GlobalID, model.IsTerritoryFlag, false, false, true, false));
            }
            if (flag != null && counts.BuildingCount < flag.StructureBlueprint.BuildingCount)
            {
                categories.AddRange(_structure.GetStructureCategoriesByType(GetPC().GlobalID, model.IsTerritoryFlag, false, false, false, true));
            }

            foreach (StructureCategory category in categories)
            {
                AddResponseToPage("BlueprintCategoryPage", category.Name, category.IsActive, new Tuple <string, dynamic>(string.Empty, category.StructureCategoryID));
            }

            AddResponseToPage("BlueprintCategoryPage", "Back");
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        private string BuildChangePrivacyHeader()
        {
            Model           model  = GetDialogCustomData <Model>();
            PCTerritoryFlag entity = _structure.GetPCTerritoryFlagByID(model.FlagID);

            string header = _color.Green("Current Build Privacy: ") + entity.BuildPrivacyDomain.Name + "\n\n";

            header += _color.Green("Owner Only: ") + "Only the owner of this territory may build and manipulate structures at this territory.\n";
            header += _color.Green("Friends Only: ") + "Only you and the people you mark as friends may build and manipulate structures at this territory.\n";
            header += _color.Green("Public: ") + "Anyone may build and manipulate structures at this territory.";

            return(header);
        }
Beispiel #4
0
        private void LoadBlueprintListPageResponses()
        {
            Model model = GetDialogCustomData <Model>();

            ClearPageResponses("BlueprintListPage");
            Location location = GetDialogTarget().Location;
            PCSkill  pcSkill  = _skill.GetPCSkill(GetPC(), SkillType.Construction);

            if (pcSkill == null)
            {
                return;
            }

            PCTerritoryFlag         flag   = _structure.GetPCTerritoryFlagByID(model.FlagID);
            TerritoryStructureCount counts = _structure.GetNumberOfStructuresInTerritory(model.FlagID);

            List <StructureBlueprint> blueprints = _structure.GetStructuresByCategoryAndType(GetPC().GlobalID, model.CategoryID, false, false, false, false); // Territory markers

            if (flag != null && counts.VanityCount < flag.StructureBlueprint.VanityCount)
            {
                blueprints.AddRange(_structure.GetStructuresByCategoryAndType(GetPC().GlobalID, model.CategoryID, true, false, false, false)); // Vanity
            }
            if (flag != null && counts.SpecialCount < flag.StructureBlueprint.SpecialCount)
            {
                blueprints.AddRange(_structure.GetStructuresByCategoryAndType(GetPC().GlobalID, model.CategoryID, false, true, false, false)); // Special
            }
            if (flag != null && counts.ResourceCount < flag.StructureBlueprint.ResourceCount)
            {
                blueprints.AddRange(_structure.GetStructuresByCategoryAndType(GetPC().GlobalID, model.CategoryID, false, false, true, false)); // Resource
            }
            if (flag != null && counts.BuildingCount < flag.StructureBlueprint.BuildingCount)
            {
                blueprints.AddRange(_structure.GetStructuresByCategoryAndType(GetPC().GlobalID, model.CategoryID, false, false, false, true)); // Building
            }

            foreach (StructureBlueprint entity in blueprints)
            {
                string entityName = entity.Name + " (Lvl. " + entity.Level + ")";
                if (model.IsTerritoryFlag)
                {
                    if (_structure.WillBlueprintOverlapWithExistingFlags(location, entity.StructureBlueprintID))
                    {
                        entityName = _color.Red(entityName + " [OVERLAPS]");
                    }
                }
                AddResponseToPage("BlueprintListPage", entityName, entity.IsActive, new Tuple <string, dynamic>(string.Empty, entity.StructureBlueprintID));
            }

            AddResponseToPage("BlueprintListPage", "Back");
        }
Beispiel #5
0
        private void BuildMainPageHeader()
        {
            Model                   model  = GetDialogCustomData <Model>();
            int                     flagID = model.FlagID;
            PCTerritoryFlag         flag   = _structure.GetPCTerritoryFlagByID(flagID);
            TerritoryStructureCount counts = _structure.GetNumberOfStructuresInTerritory(flagID);

            var    blueprint = flag.StructureBlueprint;
            string header    = _color.Green("Territory Management Menu") + "\n\n"
                               + _color.Green("Vanity Slots: ") + counts.VanityCount + " / " + blueprint.VanityCount + "\n"
                               + _color.Green("Special Slots: ") + counts.SpecialCount + " / " + blueprint.SpecialCount + "\n"
                               + _color.Green("Resource Slots: ") + counts.ResourceCount + " / " + blueprint.ResourceCount + "\n"
                               + _color.Green("Building Slots: ") + counts.BuildingCount + " / " + blueprint.BuildingCount + "\n"
                               + "Please select an option.";

            SetPageHeader("MainPage", header);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        private void ToggleOwnerName()
        {
            Model           model = GetDialogCustomData <Model>();
            PCTerritoryFlag flag  = _structure.GetPCTerritoryFlagByID(model.FlagID);

            flag.ShowOwnerName = !flag.ShowOwnerName;

            if (flag.ShowOwnerName)
            {
                PlayerCharacter owner = _player.GetPlayerEntity(flag.PlayerID);

                // Building
                if (model.FlagMarker == null)
                {
                    GetPC().FloatingText("Now displaying owner's name on this building.");
                }
                // Territory Marker
                else
                {
                    GetPC().FloatingText("Now displaying owner's name on this territory marker.");
                    model.FlagMarker.Name = owner.CharacterName + "'s Territory";
                }
            }
            else
            {
                if (model.FlagMarker == null)
                {
                    GetPC().FloatingText("No longer displaying owner's name on this building.");
                }
                else
                {
                    GetPC().FloatingText("No longer displaying owner's name on this territory marker.");
                    model.FlagMarker.Name = "Claimed Territory";
                }
            }

            _structure.SaveChanges();
            BuildMainPageHeader();
        }
Beispiel #8
0
        private void DoEnterBuilding()
        {
            NWPlayer    oPC  = GetPC();
            NWPlaceable door = (NWPlaceable)GetDialogTarget();

            int structureID = _structure.GetPlaceableStructureID(door);

            if (structureID <= 0)
            {
                _.FloatingTextStringOnCreature("ERROR: Door doesn't have a structure ID assigned. Notify an admin about this issue.", oPC.Object, FALSE);
                return;
            }

            PCTerritoryFlagsStructure structure = _structure.GetPCStructureByID(structureID);

            if (structure.BuildingInterior == null)
            {
                _.FloatingTextStringOnCreature("ERROR: Could not locate interior object for structure. Notify an admin about this issue.", oPC.Object, FALSE);
                return;
            }

            NWArea instance = GetAreaInstance(structureID);

            if (instance == null)
            {
                PCTerritoryFlag flag = _structure.GetPCTerritoryFlagByBuildingStructureID(structureID);

                string name = structure.CustomName;
                if (name == string.Empty)
                {
                    PlayerCharacter owner = _player.GetPlayerEntity(structure.PCTerritoryFlag.PlayerID);

                    if (flag.ShowOwnerName)
                    {
                        name = owner.CharacterName + "'s Building";
                    }
                    else
                    {
                        name = "Building";
                    }
                }

                instance = NWArea.Wrap(_.CreateArea(structure.BuildingInterior.AreaResref, "", name));
                instance.SetLocalInt("BUILDING_STRUCTURE_ID", structureID);
                instance.SetLocalInt("TERRITORY_FLAG_ID", flag.PCTerritoryFlagID);

                // Load structures & construction sites
                foreach (Data.Entities.ConstructionSite entity in flag.ConstructionSites)
                {
                    if (entity.IsActive)
                    {
                        _structure.CreateConstructionSiteFromEntity(entity);
                    }
                }
                foreach (PCTerritoryFlagsStructure entity in flag.PCTerritoryFlagsStructures)
                {
                    if (entity.IsActive)
                    {
                        _structure.CreateStructureFromEntity(entity);
                    }
                }
            }

            instance.SetLocalInt("BUILDING_DISABLED", 0);
            _structure.JumpPCToBuildingInterior(oPC, instance);
        }