Exemple #1
0
        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));
                }
            }
        }