/// <summary>
        /// Add interior people flats.
        /// </summary>
        private void AddPeople()
        {
            GameObject node = new GameObject("People Flats");

            node.transform.parent = this.transform;

            // Add block flats
            foreach (DFBlock.RmbBlockPeopleRecord obj in recordData.Interior.BlockPeopleRecords)
            {
                // Calculate position
                Vector3 billboardPosition = new Vector3(obj.XPos, -obj.YPos, obj.ZPos) * MeshReader.GlobalScale;

                // Import 3D character instead of billboard
                if (MeshReplacement.ImportCustomFlatGameobject(obj.TextureArchive, obj.TextureRecord, billboardPosition, node.transform) != null)
                {
                    continue;
                }

                // Spawn billboard gameobject
                GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(obj.TextureArchive, obj.TextureRecord, node.transform);

                // Set position
                DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>();
                go.transform.position  = billboardPosition;
                go.transform.position += new Vector3(0, dfBillboard.Summary.Size.y / 2, 0);

                // Add RMB data to billboard
                dfBillboard.SetRMBPeopleData(obj);

                // Add StaticNPC behaviour
                StaticNPC npc = go.AddComponent <StaticNPC>();
                npc.SetLayoutData(obj);
            }
        }
 public DaggerfallWitchesCovenPopupWindow(IUserInterfaceManager uiManager, StaticNPC npc)
     : base(uiManager)
 {
     witchNPC = npc;
     // Clear background
     ParentPanel.BackgroundColor = Color.clear;
 }
 public DaggerfallMerchantRepairPopupWindow(IUserInterfaceManager uiManager, StaticNPC npc)
     : base(uiManager)
 {
     merchantNPC = npc;
     // Clear background
     ParentPanel.BackgroundColor = Color.clear;
 }
Esempio n. 4
0
        /// <summary>
        /// Add interior people flats.
        /// </summary>
        private void AddPeople(PlayerGPS.DiscoveredBuilding buildingData)
        {
            GameObject node = new GameObject("People Flats");

            node.transform.parent = this.transform;
            bool isMemberOfBuildingGuild = GameManager.Instance.GuildManager.GetGuild(buildingData.factionID).IsMember();

            // Add block flats
            foreach (DFBlock.RmbBlockPeopleRecord obj in recordData.Interior.BlockPeopleRecords)
            {
                // Calculate position
                Vector3 billboardPosition = new Vector3(obj.XPos, -obj.YPos, obj.ZPos) * MeshReader.GlobalScale;

                // Import 3D character instead of billboard
                if (MeshReplacement.ImportCustomFlatGameobject(obj.TextureArchive, obj.TextureRecord, billboardPosition, node.transform) != null)
                {
                    continue;
                }

                // Spawn billboard gameobject
                GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(obj.TextureArchive, obj.TextureRecord, node.transform);

                // Set position
                DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>();
                go.transform.position  = billboardPosition;
                go.transform.position += new Vector3(0, dfBillboard.Summary.Size.y / 2, 0);

                // Add RMB data to billboard
                dfBillboard.SetRMBPeopleData(obj);

                // Add StaticNPC behaviour
                StaticNPC npc = go.AddComponent <StaticNPC>();
                npc.SetLayoutData(obj, entryDoor.buildingKey);

                // Disable people if shop or building is closed
                DFLocation.BuildingTypes buildingType = buildingData.buildingType;
                if ((RMBLayout.IsShop(buildingType) && !GameManager.Instance.PlayerEnterExit.IsPlayerInsideOpenShop) ||
                    (buildingType <= DFLocation.BuildingTypes.Palace && !RMBLayout.IsShop(buildingType) && !PlayerActivate.IsBuildingOpen(buildingType)))
                {
                    go.SetActive(false);
                }
                // Disable people if player owns this house
                else if (DaggerfallBankManager.IsHouseOwned(buildingData.buildingKey))
                {
                    go.SetActive(false);
                }
                // Disable people if this is TG/DB house and player is not a member
                else if (buildingData.buildingType == DFLocation.BuildingTypes.House2 && buildingData.factionID != 0 && !isMemberOfBuildingGuild)
                {
                    go.SetActive(false);
                }
                // Disable people if they are TG spymaster, but not in a legit TG house (TODO: spot any other instances for TG/DB)
                else if (buildingData.buildingType == DFLocation.BuildingTypes.House2 && buildingData.factionID == 0 &&
                         npc.Data.factionID == (int)GuildNpcServices.TG_Spymaster)
                {
                    go.SetActive(false);
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Instantiate a new quest from source text array.
        /// </summary>
        /// <param name="questSource">Array of lines from quuest source file.</param>
        /// <param name="questorNPC">Questor NPC in world offering quest.</param>
        /// <returns>Quest.</returns>
        public Quest ParseQuest(string[] questSource, StaticNPC questorNPC = null)
        {
            // Parse quest
            Parser parser = new Parser();
            Quest  quest  = parser.Parse(questSource, questorNPC);

            return(quest);
        }
 public DaggerfallMerchantServicePopupWindow(IUserInterfaceManager uiManager, StaticNPC npc, Services service)
     : base(uiManager)
 {
     merchantNPC    = npc;
     currentService = service;
     // Clear background
     ParentPanel.BackgroundColor = Color.clear;
 }
 public DaggerfallTavernWindow(IUserInterfaceManager uiManager, StaticNPC npc)
     : base(uiManager)
 {
     merchantNPC  = npc;
     buildingData = GameManager.Instance.PlayerEnterExit.BuildingDiscoveryData;
     // Clear background
     ParentPanel.BackgroundColor = Color.clear;
 }
Esempio n. 8
0
        /// <summary>
        /// Start tracking a new questor.
        /// </summary>
        /// <param name="personSymbol">Symbol of new questor.</param>
        public void AddQuestor(Symbol personSymbol)
        {
            // Must be a valid resource
            if (personSymbol == null || string.IsNullOrEmpty(personSymbol.Name))
            {
                throw new Exception("AddQuestor() must receive a named symbol.");
            }

            // Person must not be a questor already
            if (questors.ContainsKey(personSymbol.Name))
            {
                Debug.LogWarningFormat("Person {0} is already a questor for quest {1} [{2}]", personSymbol.Original, uid, displayName);
                return;
            }

            // Attempt to get person resources
            Person person = GetPerson(personSymbol);

            if (person == null)
            {
                Debug.LogWarningFormat("Could not find matching Person resource to add questor {0}", personSymbol.Original);
                return;
            }

            // Set person as questor
            person.IsQuestor = true;

            // Create new questor symbol
            string      key = personSymbol.Name;
            QuestorData qd  = new QuestorData();

            qd.symbol = personSymbol.Clone();
            qd.name   = person.DisplayName;
            questors.Add(personSymbol.Name, qd);

            // Dynamically relink individual NPC and associated QuestResourceBehaviour (if any) in current scene
            if (person.IsIndividualNPC)
            {
                QuestResourceBehaviour[] behaviours = GameObject.FindObjectsOfType <QuestResourceBehaviour>();
                foreach (var questResourceBehaviour in behaviours)
                {
                    // Get StaticNPC if present
                    StaticNPC npc = questResourceBehaviour.GetComponent <StaticNPC>();
                    if (!npc)
                    {
                        continue;
                    }

                    // Link up resource and behaviour if this person found in scene
                    if (person.FactionData.id == npc.Data.factionID)
                    {
                        questResourceBehaviour.AssignResource(person);
                        person.QuestResourceBehaviour = questResourceBehaviour;
                    }
                }
            }
        }
Esempio n. 9
0
        static ItemCollection merchantItems;    // Temporary

        #endregion

        #region Constructors

        public DaggerfallGuildServicePopupWindow(IUserInterfaceManager uiManager, StaticNPC npc, FactionFile.GuildGroups guild, GuildServices service)
            : base(uiManager)
        {
            serviceNPC   = npc;
            this.guild   = guild;
            this.service = service;
            playerEntity = GameManager.Instance.PlayerEntity;
            // Clear background
            ParentPanel.BackgroundColor = Color.clear;
        }
Esempio n. 10
0
        /// <summary>
        /// Parses a new quest from name.
        /// Quest will attempt to load from QuestSourceFolder property path.
        /// </summary>
        /// <param name="questName">Name of quest filename. Extensions .txt is optional.</param>
        /// <returns>Quest object if successfully parsed, otherwise null.</returns>
        public Quest ParseQuest(string questName, StaticNPC questorNPC = null)
        {
            Debug.LogFormat("Parsing quest {0}", questName);

            string[] source = GetQuestSourceText(questName);
            if (source == null || source.Length == 0)
                throw new Exception(string.Format("Could not load quest '{0}' or source file is empty/invalid.", questName));

            return ParseQuest(source);
        }
        /// <summary>
        /// Add a quest NPC to marker position.
        /// </summary>
        static void AddQuestNPC(SiteTypes siteType, Quest quest, QuestMarker marker, Person person, Transform parent)
        {
            // Get billboard texture data
            FactionFile.FlatData flatData;
            if (person.IsIndividualNPC)
            {
                // Individuals are always flat1 no matter gender
                flatData = FactionFile.GetFlatData(person.FactionData.flat1);
            }
            if (person.Gender == Genders.Male)
            {
                // Male has flat1
                flatData = FactionFile.GetFlatData(person.FactionData.flat1);
            }
            else
            {
                // Female has flat2
                flatData = FactionFile.GetFlatData(person.FactionData.flat2);
            }

            // Create target GameObject
            GameObject go = CreateDaggerfallBillboardGameObject(flatData.archive, flatData.record, parent);

            go.name = string.Format("Quest NPC [{0}]", person.DisplayName);

            // Set position and adjust up by half height if not inside a dungeon
            Vector3 dungeonBlockPosition = new Vector3(marker.dungeonX * RDBLayout.RDBSide, 0, marker.dungeonZ * RDBLayout.RDBSide);

            go.transform.localPosition = dungeonBlockPosition + marker.flatPosition;
            DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>();

            if (siteType != SiteTypes.Dungeon)
            {
                go.transform.localPosition += new Vector3(0, dfBillboard.Summary.Size.y / 2, 0);
            }

            // Add people data to billboard
            dfBillboard.SetRMBPeopleData(person.FactionIndex, person.FactionData.flags);

            // Add QuestResourceBehaviour to GameObject
            QuestResourceBehaviour questResourceBehaviour = go.AddComponent <QuestResourceBehaviour>();

            questResourceBehaviour.AssignResource(person);

            // Set QuestResourceBehaviour in Person object
            person.QuestResourceBehaviour = questResourceBehaviour;

            // Add StaticNPC behaviour
            StaticNPC npc = go.AddComponent <StaticNPC>();

            npc.SetLayoutData((int)marker.flatPosition.x, (int)marker.flatPosition.y, (int)marker.flatPosition.z, person);

            // Set tag
            go.tag = QuestMachine.questPersonTag;
        }
Esempio n. 12
0
        /// <summary>
        /// Add interior people flats.
        /// </summary>
        private void AddPeople(PlayerGPS.DiscoveredBuilding buildingData)
        {
            GameObject node = new GameObject(peopleFlats);

            node.transform.parent = this.transform;
            IGuild guild = GameManager.Instance.GuildManager.GetGuild(buildingData.factionID);
            bool   isMemberOfBuildingGuild = guild.IsMember();

            // Add block flats
            foreach (DFBlock.RmbBlockPeopleRecord obj in recordData.Interior.BlockPeopleRecords)
            {
                // Calculate position
                Vector3 billboardPosition = new Vector3(obj.XPos, -obj.YPos, obj.ZPos) * MeshReader.GlobalScale;

                // Make person gameobject
                GameObject go = MeshReplacement.ImportCustomFlatGameobject(obj.TextureArchive, obj.TextureRecord, billboardPosition, node.transform);
                if (!go)
                {
                    // Spawn billboard gameobject
                    go = GameObjectHelper.CreateDaggerfallBillboardGameObject(obj.TextureArchive, obj.TextureRecord, node.transform);

                    // Set position
                    DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>();
                    go.transform.position  = billboardPosition;
                    go.transform.position += new Vector3(0, dfBillboard.Summary.Size.y / 2, 0);

                    // Add RMB data to billboard
                    dfBillboard.SetRMBPeopleData(obj);
                }

                // Add StaticNPC behaviour
                StaticNPC npc = go.AddComponent <StaticNPC>();
                npc.SetLayoutData(obj, entryDoor.buildingKey);

                // Disable people if shop or building is closed
                DFLocation.BuildingTypes buildingType = buildingData.buildingType;
                if ((RMBLayout.IsShop(buildingType) && !GameManager.Instance.PlayerEnterExit.IsPlayerInsideOpenShop) ||
                    (buildingType <= DFLocation.BuildingTypes.Palace && !RMBLayout.IsShop(buildingType) &&
                     !(PlayerActivate.IsBuildingOpen(buildingType) || buildingType == DFLocation.BuildingTypes.GuildHall && guild.HallAccessAnytime())))
                {
                    go.SetActive(false);
                }
                // Disable people if player owns this house
                else if (DaggerfallBankManager.IsHouseOwned(buildingData.buildingKey))
                {
                    go.SetActive(false);
                }
                // Disable people if this is TG/DB house and player is not a member
                else if (buildingData.buildingType == DFLocation.BuildingTypes.House2 && buildingData.factionID != 0 && !isMemberOfBuildingGuild)
                {
                    go.SetActive(false);
                }
            }
        }
Esempio n. 13
0
        //protected new StaticNPC merchantNPC;
        //protected new PlayerGPS.DiscoveredBuilding buildingData;
        //protected new RoomRental_v1 rentedRoom;
        //protected new int daysToRent = 0;
        //protected new int tradePrice = 0;

        //bool isCloseWindowDeferred = false;
        //bool isTalkWindowDeferred = false;
        //bool isFoodDeferred = false;
        //bool isDrinksDeferred = false;


        #endregion

        #region Constructors

        public FenceWindow(IUserInterfaceManager uiManager, StaticNPC npc, FactionFile.GuildGroups guildGroup)
            : base(uiManager)
        {
            ParentPanel.BackgroundColor = Color.clear;
            guildManager = GameManager.Instance.GuildManager;

            serviceNPC      = npc;
            npcService      = GuildNpcServices.TG_SellMagicItems;
            this.guildGroup = guildGroup;
            guild           = guildManager.GetGuild(guildGroup, buildingFactionId);
            Debug.Log("guild = " + guild.ToString());
        }
Esempio n. 14
0
        /// <summary>
        /// Parse and instantiate a quest from quest name.
        /// </summary>
        /// <param name="questName">Quest name.</param>
        /// <param name="questorNPC">Questor NPC in world offering quest.</param>
        /// <returns>Quest.</returns>
        public Quest InstantiateQuest(string questName, StaticNPC questorNPC = null)
        {
            Quest quest = ParseQuest(questName, questorNPC);

            if (quest != null)
            {
                InstantiateQuest(quest);
                return(quest);
            }

            return(null);
        }
Esempio n. 15
0
        /// <summary>
        /// Parses a new quest from name.
        /// Quest will attempt to load from QuestSourceFolder property path.
        /// </summary>
        /// <param name="questName">Name of quest filename. Extensions .txt is optional.</param>
        /// <param name="questorNPC">Questor NPC in world offering quest.</param>
        /// <returns>Quest object if successfully parsed, otherwise null.</returns>
        public Quest ParseQuest(string questName, StaticNPC questorNPC = null)
        {
            Debug.LogFormat("Parsing quest {0}", questName);

            string[] source = GetQuestSourceText(questName);
            if (source == null || source.Length == 0)
            {
                return(null);
            }

            return(ParseQuest(source, questorNPC));
        }
Esempio n. 16
0
        /// <summary>
        /// Resets operating state - clears all quests, sitelinks, debuggers, etc.
        /// Quests will not be disposed or tombstoned they will just be dropped for garbage collector.
        /// </summary>
        public void ClearState()
        {
            // Clear state
            quests.Clear();
            siteLinks.Clear();
            questsToTombstone.Clear();
            questsToRemove.Clear();
            questsToInvoke.Clear();
            lastNPCClicked = null;

            // Clear debugger state
            DaggerfallUI.Instance.DaggerfallHUD.PlaceMarker.ClearSiteTargets();
        }
Esempio n. 17
0
    void Awake()
    {
        if (exist == null)
        {
            exist = this;
        }

        if (exist != this)
        {
            Destroy(gameObject);
        }
        else
        {
            DontDestroyOnLoad(gameObject);
        }
    }
Esempio n. 18
0
        public FlynsarmyGuildServicePopupWindow(IUserInterfaceManager uiManager, StaticNPC npc, FactionFile.GuildGroups guildGroup, int buildingFactionId)
            : base(uiManager, npc, guildGroup, buildingFactionId)
        {
            playerEntity = GameManager.Instance.PlayerEntity;
            guildManager = GameManager.Instance.GuildManager;

            serviceNPC     = npc;
            npcService     = (GuildNpcServices)npc.Data.factionID;
            currentService = Services.GetService(npcService);
            Debug.Log("NPC offers guild service: " + currentService.ToString());

            this.guildGroup        = guildGroup;
            this.buildingFactionId = buildingFactionId;

            guild = guildManager.GetGuild(guildGroup, buildingFactionId);
        }
Esempio n. 19
0
        /// <summary>
        /// Sets the last StaticNPC clicked by player.
        /// Always called by PlayerActivate when player clicks on GameObject holding StaticNPC behaviour.
        /// </summary>
        public void SetLastNPCClicked(StaticNPC npc)
        {
            // Store the NPC clicked
            lastNPCClicked = npc;

            // Find Person resource if this NPC is involved in any quests
            foreach (Quest quest in quests.Values)
            {
                QuestResource[] questPeople = quest.GetAllResources(typeof(Person));
                foreach (Person person in questPeople)
                {
                    // Set player click in Person resource
                    if (IsNPCDataEqual(person.QuestorData, lastNPCClicked.Data))
                        person.SetPlayerClicked();
                }
            }
        }
Esempio n. 20
0
 public Marker()
 {
     markerObject    = null;
     markerIcon      = null;
     markerType      = Minimap.MarkerGroups.None;
     isActive        = false;
     inVision        = false;
     inLOS           = false;
     markerLayerMask = 10;
     markerDistance  = 0;
     enemySenses     = null;
     npcMesh         = null;
     npcMarkerColor  = Color.magenta;
     mobileNPC       = null;
     mobileEnemy     = null;
     flatNPC         = null;
 }
        public DaggerfallGuildServicePopupWindow(IUserInterfaceManager uiManager, StaticNPC npc, FactionFile.GuildGroups guildGroup, int buildingFactionId)
            : base(uiManager)
        {
            playerEntity = GameManager.Instance.PlayerEntity;
            guildManager = GameManager.Instance.GuildManager;

            serviceNPC = npc;
            npcService = (GuildNpcServices)npc.Data.factionID;
            service    = Services.GetService(npcService);
            Debug.Log("NPC offers guild service: " + service.ToString());

            this.guildGroup        = guildGroup;
            this.buildingFactionId = buildingFactionId;

            guild = guildManager.GetGuild(guildGroup, buildingFactionId);

            // Clear background
            ParentPanel.BackgroundColor = Color.clear;
        }
Esempio n. 22
0
        public override bool CheckTrigger(Task caller)
        {
            // Update faction listener for this individual
            // This allows other agencies to determine if a quest is actively listening on this NPC
            QuestMachine.Instance.AddFactionListener(npcFactionID, this);

            // Check if player has clicked on anyone
            StaticNPC lastClicked = QuestMachine.Instance.LastNPCClicked;

            if (lastClicked == null)
            {
                return(false);
            }

            // Exit if player is spam clicking same NPC, they will need to click someone else and come back
            if (lastClicked == clickMemory)
            {
                return(false);
            }
            else
            {
                clickMemory = null;
            }

            // Check if player clicked on our NPC
            if (lastClicked.Data.factionID != npcFactionID)
            {
                return(false);
            }

            // Not clear when named NPC should be considered available
            // For now they are considered available if no Person record exists for their individual FactionID
            Person[] foundActive = QuestMachine.Instance.ActiveFactionPersons(npcFactionID);
            if (foundActive == null || foundActive.Length == 0)
            {
                // Remember we just clicked this NPC and exit
                clickMemory = lastClicked;
                return(true);
            }

            return(false);
        }
        public DaggerfallQuestOfferWindow(IUserInterfaceManager uiManager, StaticNPC npc, FactionFile.SocialGroups socialGroup)
            : base(uiManager)
        {
            questorNPC = npc;
            TalkManager.Instance.RemoveMerchantQuestor(npc.Data.nameSeed); // Remove potential questor from pool after quest has been offered
            // TODO - assemble quest lists for more social groups
            switch (socialGroup)
            {
            default:
            case FactionFile.SocialGroups.Merchants:
                questsFilename = tempMerchantsQuestsFilename;
                break;

            case FactionFile.SocialGroups.Nobility:
                questsFilename = tempNobilityQuestsFilename;
                break;
            }
            // Clear background
            ParentPanel.BackgroundColor = Color.clear;
        }
Esempio n. 24
0
        public static void ShadowAppraiserClicked(RaycastHit hit)
        {
            FactionFile.FactionData factionData;
            FactionFile.GuildGroups guildGroup;
            npc = QuestMachine.Instance.LastNPCClicked;
            GuildServices service = Services.GetService((GuildNpcServices)npc.Data.factionID);

            if (QuestMachine.Instance.HasFactionListener(npc.Data.factionID))
            {
                return;
            }
            if (GameManager.Instance.PlayerEntity.FactionData.GetFactionData(npc.Data.factionID, out factionData))
            {
                if (Services.HasGuildService(npc.Data.factionID) && npc.Data.factionID == 805)
                {
                    (DaggerfallUI.Instance.UserInterfaceManager.TopWindow as DaggerfallGuildServicePopupWindow).CloseWindow();
                    guildGroup = GameManager.Instance.GuildManager.GetGuildGroup(805);
                    FenceWindow fenceWindow = new FenceWindow(DaggerfallUI.UIManager, npc, guildGroup);
                    DaggerfallUI.UIManager.PushWindow(fenceWindow);
                }
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Immediately tombstones then removes all quests.
        /// </summary>
        /// <returns>Number of quests removed.</returns>
        public int PurgeAllQuests()
        {
            ulong[] uids = GetAllQuests();
            if (uids == null || uids.Length == 0)
                return 0;

            foreach (ulong uid in uids)
            {
                RemoveQuest(uid);
            }

            quests.Clear();
            siteLinks.Clear();
            questsToTombstone.Clear();
            questsToRemove.Clear();
            questsToInvoke.Clear();
            lastNPCClicked = null;

            // Clear debugger state
            DaggerfallUI.Instance.DaggerfallHUD.PlaceMarker.ClearSiteTargets();

            return uids.Length;
        }
Esempio n. 26
0
        /// <summary>
        /// Called by PlayerActivate when clicking on this GameObject.
        /// </summary>
        /// <returns>True if this resource was found in any active quests.</returns>
        public bool DoClick()
        {
            bool foundInActiveQuest = false;

            // Handle linked resource
            if (targetResource != null)
            {
                // Click resource
                targetResource.SetPlayerClicked();

                // If this an item then transfer item to player and hide resource
                if (targetResource is Item)
                {
                    TransferWorldItemToPlayer();
                }

                foundInActiveQuest = true;
            }

            // Possible for NPC to start a direct follow-up quest and new quest needs a bootstrap click
            // But if resource is still associated with old quest from previous layout then click never sent to new quest
            // So if behaviour is peered with an individual StaticNPC then send click to all quests using this NPC
            // This allows new quest to receive click and NPC will be re-linked on next layout or by "add NPC as questor"
            StaticNPC npc = GetComponent <StaticNPC>();

            if (npc)
            {
                int factionID = npc.Data.factionID;
                if (QuestMachine.Instance.IsIndividualNPC(factionID))
                {
                    foundInActiveQuest = ClickAllIndividualNPCs(factionID);
                }
            }

            return(foundInActiveQuest);
        }
Esempio n. 27
0
        private static void OnTransitionToInterior_VariantResidenceNPCsprites(PlayerEnterExit.TransitionEventArgs args)
        {
            if (villagerVarietyMod != null && villagerVarietyNumVariants == 0)
            {
                ModManager.Instance.SendModMessage(VILLAGERVARIETY_MODNAME, "getNumVariants", null, (string message, object data) => { villagerVarietyNumVariants = (int)data; });
            }

            PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit;

            DFLocation.BuildingData buildingData = playerEnterExit.Interior.BuildingData;
            if (RMBLayout.IsResidence(buildingData.BuildingType))
            {
                Races       race         = GetClimateRace();
                int         gender       = -1;
                Billboard[] dfBillboards = playerEnterExit.Interior.GetComponentsInChildren <Billboard>();
                foreach (Billboard billboard in dfBillboards)
                {
                    if (billboard.Summary.Archive == 182)
                    {
                        gender = GetGender182(billboard.Summary.Record);
                    }
                    else if (billboard.Summary.Archive == 184)
                    {
                        gender = GetGender184(billboard.Summary.Record);
                    }

                    if (gender != -1)
                    {
                        StaticNPC npc = billboard.GetComponent <StaticNPC>();
                        if (npc && npc.Data.factionID == 0)
                        {
                            int faceVariant = npc.Data.nameSeed % 29;
                            Debug.LogFormat("Replace house NPC {0}.{1} with faceVariant {2} - {3}", billboard.Summary.Archive, billboard.Summary.Record, faceVariant, faceVariant < 24);

                            if (faceVariant < 24)
                            {
                                int outfitVariant = npc.Data.nameSeed % 4;
                                int archive       = gender == (int)Genders.Male ? raceArchivesMale[race][outfitVariant] : raceArchivesFemale[race][outfitVariant];
                                int record        = 5;
                                int faceRecord    = gender == (int)Genders.Male ? raceFaceRecordMale[race][outfitVariant] : raceFaceRecordFemale[race][outfitVariant];
                                faceRecord += faceVariant;

                                bool materialSet = false;
                                if (villagerVarietyMod != null)
                                {
                                    int    variant = npc.Data.nameSeed % villagerVarietyNumVariants;
                                    string season  = "";
                                    //ModManager.Instance.SendModMessage(VILLAGERVARIETY_MODNAME, "getSeasonStr", null, (string message, object data) => { season = (string)data; });

                                    Debug.LogFormat("Replace house NPC {0}.{1} with {2}.{3}, outfit: {4} faceRecord: {5} ({6}) variant: {7} season: {8}", billboard.Summary.Archive, billboard.Summary.Record, archive, record, outfitVariant, faceRecord, faceVariant, variant, season);

                                    string imageName = null;
                                    ModManager.Instance.SendModMessage(VILLAGERVARIETY_MODNAME, "getImageName",
                                                                       new object[] { archive, record, 0, faceRecord, variant, season },
                                                                       (string message, object data) => { imageName = (string)data; });

                                    if (!string.IsNullOrEmpty(imageName) && villagerVarietyMod.HasAsset(imageName))
                                    {
                                        // Get texture and create material
                                        Texture2D texture  = villagerVarietyMod.GetAsset <Texture2D>(imageName);
                                        Material  material = MaterialReader.CreateStandardMaterial(MaterialReader.CustomBlendMode.Cutout);
                                        material.mainTexture = texture;

                                        // Apply material to mesh renderer
                                        MeshRenderer meshRenderer = billboard.GetComponent <MeshRenderer>();
                                        meshRenderer.sharedMaterial = material;

                                        // Create mesh and setup UV map for mesh filter
                                        Vector2 size;
                                        Mesh    mesh = DaggerfallUnity.Instance.MeshReader.GetBillboardMesh(new Rect(0, 0, 1, 1), archive, record, out size);
                                        mesh.uv = new Vector2[] { new Vector2(0, 1), new Vector2(1, 1), new Vector2(0, 0), new Vector2(1, 0) };
                                        MeshFilter meshFilter = billboard.GetComponent <MeshFilter>();
                                        Destroy(meshFilter.sharedMesh);
                                        meshFilter.sharedMesh = mesh;
                                        materialSet           = true;
                                    }
                                }
                                if (!materialSet)
                                {
                                    billboard.SetMaterial(archive, record);
                                    billboard.FramesPerSecond = 1;
                                }
                                GameObjectHelper.AlignBillboardToGround(billboard.gameObject, billboard.Summary.Size);

                                Dictionary <int, FlatsFile.FlatData> flatsDict = DaggerfallUnity.Instance.ContentReader.FlatsFileReader.FlatsDict;
                                int flatId = FlatsFile.GetFlatID(npc.Data.billboardArchiveIndex, npc.Data.billboardRecordIndex);
#if UNITY_EDITOR
                                Debug.LogFormat("Replacing face dict for {0} with {1} (for {2}.{3} / {4}.{5})", flatsDict[flatId].faceIndex, faceRecord, npc.Data.billboardArchiveIndex, npc.Data.billboardRecordIndex, billboard.Summary.Archive, billboard.Summary.Record);
#endif
                                flatsDict[flatId] = new FlatsFile.FlatData()
                                {
                                    archive   = billboard.Summary.Archive,
                                    record    = billboard.Summary.Record,
                                    faceIndex = faceRecord,
                                };
                            }
                        }
                    }
                }
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Add misc block flats.
        /// Batching is conditionally supported.
        /// </summary>
        public static void AddMiscBlockFlats(
            ref DFBlock blockData,
            Transform flatsParent,
            DaggerfallBillboardBatch animalsBillboardBatch = null,
            TextureAtlasBuilder miscBillboardsAtlas        = null,
            DaggerfallBillboardBatch miscBillboardsBatch   = null)
        {
            DaggerfallUnity dfUnity = DaggerfallUnity.Instance;

            if (!dfUnity.IsReady)
            {
                return;
            }

            // Add block flats
            foreach (DFBlock.RmbBlockFlatObjectRecord obj in blockData.RmbBlock.MiscFlatObjectRecords)
            {
                // Ignore lights as they are handled by AddLights()
                if (obj.TextureArchive == TextureReader.LightsTextureArchive)
                {
                    continue;
                }

                // Calculate position
                Vector3 billboardPosition = new Vector3(
                    obj.XPos,
                    -obj.YPos + blockFlatsOffsetY,
                    obj.ZPos + BlocksFile.RMBDimension) * MeshReader.GlobalScale;

                // Import custom 3d gameobject instead of flat
                if (MeshReplacement.ImportCustomFlatGameobject(obj.TextureArchive, obj.TextureRecord, billboardPosition, flatsParent) != null)
                {
                    continue;
                }

                //// Use misc billboard atlas where available
                //if (miscBillboardsAtlas != null && miscBillboardsBatch != null)
                //{
                //    TextureAtlasBuilder.AtlasItem item = miscBillboardsAtlas.GetAtlasItem(obj.TextureArchive, obj.TextureRecord);
                //    if (item.key != -1)
                //    {
                //        miscBillboardsBatch.AddItem(item.rect, item.textureItem.size, item.textureItem.scale, billboardPosition);
                //        continue;
                //    }
                //}

                // Add to batch where available
                //if (obj.TextureArchive == TextureReader.AnimalsTextureArchive && animalsBillboardBatch != null)
                //{
                //    animalsBillboardBatch.AddItem(obj.TextureRecord, billboardPosition);
                //    continue;
                //}

                // Add standalone billboard gameobject
                GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(obj.TextureArchive, obj.TextureRecord, flatsParent);
                go.transform.position = billboardPosition;
                AlignBillboardToBase(go);

                // Add animal sound
                if (obj.TextureArchive == TextureReader.AnimalsTextureArchive)
                {
                    AddAnimalAudioSource(go);
                }

                // If flat record has a non-zero faction id, then it's an exterior NPC
                if (obj.FactionID != 0)
                {
                    // Add RMB data to billboard
                    DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>();
                    dfBillboard.SetRMBPeopleData(obj.FactionID, obj.Flags, obj.Position);

                    // Add StaticNPC behaviour
                    StaticNPC npc = go.AddComponent <StaticNPC>();
                    npc.SetLayoutData(obj);
                }
            }
        }
Esempio n. 29
0
 public TavernWindow(IUserInterfaceManager uiManager, StaticNPC npc)
     : base(uiManager, npc)
 {
 }
Esempio n. 30
0
        const string baseTextureName = "LGS_Invest_Popup_Services_Replacer";      // Talk / Invest / Sell

        #endregion

        #region Constructors

        public LGSMerchantTradeServicePopupWindowReplace(IUserInterfaceManager uiManager, StaticNPC npc, Services service)
            : base(uiManager, npc, service)
        {
        }