예제 #1
0
        /// <summary>
        /// Cache target quest and resource objects.
        /// If true then TargetQuest and TargetResource objects are cached and available.
        /// </summary>
        bool CacheTarget()
        {
            // Check already cached
            if (targetQuest != null && targetResource != null)
            {
                return(true);
            }

            // Must have a questUID and targetSymbol
            if (questUID == 0 || targetSymbol == null)
            {
                return(false);
            }

            // Get the quest this resource belongs to
            targetQuest = QuestMachine.Instance.GetActiveQuest(questUID);
            if (targetQuest == null)
            {
                return(false);
            }

            // Get the resource from quest
            targetResource = targetQuest.GetResource(targetSymbol);
            if (targetResource == null)
            {
                return(false);
            }

            return(true);
        }
예제 #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>
        /// Cache target quest and resource objects.
        /// If true then TargetQuest and TargetResource objects are cached and available.
        /// </summary>
        bool CacheTarget()
        {
            // Check already cached
            if (targetQuest != null && targetResource != null)
            {
                return(true);
            }

            // Must have a questUID and targetSymbol
            if (questUID == 0 || targetSymbol == null)
            {
                return(false);
            }

            // Get the quest this resource belongs to
            targetQuest = QuestMachine.Instance.GetQuest(questUID);
            if (targetQuest == null)
            {
                return(false);
            }

            // Get the resource from quest
            targetResource = targetQuest.GetResource(targetSymbol);
            if (targetResource == null)
            {
                return(false);
            }

            // Cache local EnemyEntity behaviour if resource is a Foe
            if (targetResource != null && targetResource is Foe)
            {
                enemyEntityBehaviour = gameObject.GetComponent <DaggerfallEntityBehaviour>();
            }

            return(true);
        }