コード例 #1
0
        /// <summary>
        /// Creates a new SiteLink at Place.
        /// </summary>
        public static void CreateSiteLink(Quest parentQuest, Symbol placeSymbol)
        {
            // Attempt to get Place resource
            Place place = parentQuest.GetPlace(placeSymbol);

            if (place == null)
            {
                throw new Exception(string.Format("Attempted to add SiteLink for invalid Place symbol {0}", placeSymbol.Name));
            }

            // Create SiteLink in QuestMachine
            SiteLink siteLink = new SiteLink();

            siteLink.questUID    = parentQuest.UID;
            siteLink.placeSymbol = placeSymbol;
            siteLink.siteType    = place.SiteDetails.siteType;
            siteLink.mapId       = place.SiteDetails.mapId;
            siteLink.buildingKey = place.SiteDetails.buildingKey;
            Instance.AddSiteLink(siteLink);

            // Output debug information
            switch (siteLink.siteType)
            {
            case SiteTypes.Building:
                Debug.LogFormat("Created Building SiteLink to {0} in {1}/{2}", place.SiteDetails.buildingName, place.SiteDetails.regionName, place.SiteDetails.locationName);
                break;

            case SiteTypes.Dungeon:
                Debug.LogFormat("Created Dungeon SiteLink to {0}/{1}", place.SiteDetails.regionName, place.SiteDetails.locationName);
                break;
            }
        }
コード例 #2
0
        /// <summary>
        /// Walks SiteLink > Quest > Place > QuestMarkers > Target to see if an individual NPC has been placed elsewhere.
        /// Used only to determine if an individual NPC should be disabled at home location by layout builders.
        /// Ignores non-individual NPCs.
        /// </summary>
        /// <param name="factionID">Faction ID of individual NPC.</param>
        /// <returns>True if individual has been placed elsewhere, otherwise false.</returns>
        public bool IsIndividualQuestNPCAtSiteLink(int factionID)
        {
            // Check this is a valid individual
            if (!IsIndividualNPC(factionID))
                return false;

            // Iterate site links
            foreach (SiteLink link in siteLinks)
            {
                // Attempt to get Quest target
                Quest quest = GetQuest(link.questUID);
                if (quest == null)
                    continue;

                // Attempt to get Place target
                Place place = quest.GetPlace(link.placeSymbol);
                if (place == null)
                    continue;

                // Must have target resources
                SiteDetails siteDetails = place.SiteDetails;
                QuestMarker marker = siteDetails.questSpawnMarkers[siteDetails.selectedQuestItemMarker];
                if (marker.targetResources == null)
                {
                    Debug.Log("IsIndividualQuestNPCAtSiteLink() found a SiteLink with no targetResources assigned.");
                    continue;
                }

                // Check spawn marker at this site for target NPC resource
                foreach(Symbol target in marker.targetResources)
                {
                    // Get target resource
                    QuestResource resource = quest.GetResource(target);
                    if (resource == null)
                        continue;

                    // Must be a Person resource
                    if (!(resource is Person))
                        continue;

                    // Person must be an individual and not at home
                    Person person = (Person)resource;
                    if (!person.IsIndividualNPC || person.IsIndividualAtHome)
                        continue;

                    // Check if factionID match to placed NPC
                    // This means we found an individual placed at site who is not supposed to be at their home location
                    if (person.FactionData.id == factionID)
                        return true;
                }
            }

            return false;
        }
コード例 #3
0
        /// <summary>
        /// Checks if a Place has a SiteLink available.
        /// </summary>
        public static bool HasSiteLink(Quest parentQuest, Symbol placeSymbol)
        {
            // Attempt to get Place resource
            Place place = parentQuest.GetPlace(placeSymbol);
            if (place == null)
                throw new Exception(string.Format("HasSiteLink() could not find Place symbol {0}", placeSymbol.Name));

            // Collect any SiteLinks associdated with this site
            SiteLink[] siteLinks = Instance.GetSiteLinks(place.SiteDetails.siteType, place.SiteDetails.mapId, place.SiteDetails.buildingKey);
            if (siteLinks == null || siteLinks.Length == 0)
                return false;

            return true;
        }
コード例 #4
0
        /// <summary>
        /// Gets the quest spawn marker in player's current location.
        /// </summary>
        /// <param name="markerType">Get quest spawn or item marker.</param>
        /// <param name="questMarkerOut">QuestMarker out.</param>
        /// <param name="buildingOriginOut">Building origin in scene, or Vector3.zero if not inside a building.</param>
        /// <returns>True if successful.</returns>
        public bool GetCurrentLocationQuestMarker(MarkerTypes markerType, out QuestMarker questMarkerOut, out Vector3 buildingOriginOut)
        {
            questMarkerOut    = new QuestMarker();
            buildingOriginOut = Vector3.zero;

            // Get PlayerEnterExit for world context
            PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit;

            if (!playerEnterExit)
            {
                return(false);
            }

            // Get SiteLinks for player's current location
            SiteLink[] siteLinks = null;
            if (playerEnterExit.IsPlayerInsideBuilding)
            {
                StaticDoor[] exteriorDoors = playerEnterExit.ExteriorDoors;
                if (exteriorDoors == null || exteriorDoors.Length < 1)
                {
                    return(false);
                }

                siteLinks = GetSiteLinks(SiteTypes.Building, GameManager.Instance.PlayerGPS.CurrentMapID, exteriorDoors[0].buildingKey);
                if (siteLinks == null || siteLinks.Length == 0)
                {
                    return(false);
                }

                Vector3 buildingPosition = exteriorDoors[0].buildingMatrix.GetColumn(3);
                buildingOriginOut = exteriorDoors[0].ownerPosition + buildingPosition;
            }
            else if (playerEnterExit.IsPlayerInsideDungeon)
            {
                siteLinks = GetSiteLinks(SiteTypes.Dungeon, GameManager.Instance.PlayerGPS.CurrentMapID);
            }
            else
            {
                return(false);
            }

            // Exit if no links found
            if (siteLinks == null || siteLinks.Length == 0)
            {
                return(false);
            }

            // Walk through all found SiteLinks
            foreach (SiteLink link in siteLinks)
            {
                // Get the Quest object referenced by this link
                Quest quest = GetActiveQuest(link.questUID);
                if (quest == null)
                {
                    return(false);
                }

                // Get the Place resource referenced by this link
                Place place = quest.GetPlace(link.placeSymbol);
                if (place == null)
                {
                    return(false);
                }

                // Get spawn marker
                QuestMarker spawnMarker = place.SiteDetails.questSpawnMarkers[place.SiteDetails.selectedQuestSpawnMarker];
                if (markerType == MarkerTypes.QuestSpawn && spawnMarker.targetResources != null)
                {
                    questMarkerOut = spawnMarker;
                    return(true);
                }

                // Get item marker
                QuestMarker itemMarker = place.SiteDetails.questItemMarkers[place.SiteDetails.selectedQuestItemMarker];
                if (markerType == MarkerTypes.QuestItem && itemMarker.targetResources != null)
                {
                    questMarkerOut = itemMarker;
                    return(true);
                }
            }

            return(false);
        }