Exemplo n.º 1
0
        /// <summary>
        /// Selects all actives site links matching parameters.
        /// Very little information is needed to determine if player is in Town, Dungeon, or Building.
        /// This information is intended to be easily reached by scene builders at layout time.
        /// </summary>
        /// <param name="siteType">Type of sites to select.</param>
        /// <param name="mapId">MapID in world.</param>
        /// <param name="buildingKey">Building key for buidings. Not used if left at default 0.</param>
        /// <returns>SiteLink[] array of found links. Check for null or empty on return.</returns>
        public SiteLink[] GetSiteLinks(SiteTypes siteType, int mapId, int buildingKey = 0)
        {
            // Collect a copy of all site links matching params
            List <SiteLink> foundSiteLinks = new List <SiteLink>();

            foreach (SiteLink link in siteLinks)
            {
                // Match site type
                if (link.siteType == siteType && link.mapId == mapId)
                {
                    if (buildingKey != 0)
                    {
                        // Match building key if specified
                        if (buildingKey == link.buildingKey)
                        {
                            foundSiteLinks.Add(link);
                        }
                    }
                    else
                    {
                        // Otherwise just add link
                        foundSiteLinks.Add(link);
                    }
                }
            }

            return(foundSiteLinks.ToArray());
        }
Exemplo n.º 2
0
        private static void CMInvoke()
        {
            if (VoteSites.Count != 0)
            {
                return;
            }

            var sites = new List <IVoteSite>();

            SiteTypes.ForEach(
                type =>
            {
                var site = type.CreateInstanceSafe <IVoteSite>();

                if (site == null)
                {
                    return;
                }

                if (site.Name == "Vita-Nex")
                {
                    site.Enabled = true;
                }

                sites.Add(site);
                CMOptions.ToConsole(
                    "Created site ({0}) '{1}', '{2}'", site.GetType().Name, site.Name, site.Enabled ? "Enabled" : "Disabled");
            });

            sites.ForEach(s => VoteSites.AddOrReplace(s.UID, s));

            InternalSiteSort();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get the list of users to process
        /// </summary>
        /// <returns></returns>
        public async Task <IEnumerable <StagedUser> > GetAllByStageAndSiteType(string stage, string type)
        {
            LoadStageEnum loadStage = (LoadStageEnum)Enum.Parse(typeof(LoadStageEnum), stage);
            SiteTypes     siteType  = (SiteTypes)Enum.Parse(typeof(SiteTypes), type);

            var res = await StagedUserUtil.GetAllByStageAndSiteType(loadStage, siteType);

            return(res.ToList());
        }
Exemplo n.º 4
0
        /// <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;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Adds a quest item to marker position.
        /// </summary>
        static void AddQuestItem(SiteTypes siteType, Quest quest, QuestMarker marker, Item item, Transform parent = null)
        {
            // Texture indices for quest items are from world texture record
            int textureArchive = item.DaggerfallUnityItem.WorldTextureArchive;
            int textureRecord  = item.DaggerfallUnityItem.WorldTextureRecord;

            // Create billboard
            GameObject          go          = CreateDaggerfallBillboardGameObject(textureArchive, textureRecord, parent);
            DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>();

            // Set name
            go.name = string.Format("Quest Item [{0} | {1}]", item.Symbol.Original, item.DaggerfallUnityItem.LongName);

            // Setup custom material if available
            if (AssetInjection.TextureReplacement.CustomTextureExist(textureArchive, textureRecord))
            {
                AssetInjection.TextureReplacement.SetBillboardCustomMaterial(go, textureArchive, textureRecord);
            }

            // Marker position
            Vector3 position;
            Vector3 dungeonBlockPosition = new Vector3(marker.dungeonX * RDBLayout.RDBSide, 0, marker.dungeonZ * RDBLayout.RDBSide);

            position = dungeonBlockPosition + marker.flatPosition;

            // Dungeon flats have a different origin (centre point) than elsewhere (base point)
            // Find bottom of marker in world space as it should be aligned to placement surface (e.g. ground, table, shelf, etc.)
            if (siteType == SiteTypes.Dungeon)
            {
                position.y += (-DaggerfallLoot.randomTreasureMarkerDim / 2 * MeshReader.GlobalScale);
            }

            // Now move up item icon by half own size and assign position
            position.y += (dfBillboard.Summary.Size.y / 2f);
            go.transform.localPosition = position;

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

            questResourceBehaviour.AssignResource(item);

            // Set QuestResourceBehaviour in Item object
            item.QuestResourceBehaviour = questResourceBehaviour;

            // Assign a trigger collider for clicks
            SphereCollider collider = go.AddComponent <SphereCollider>();

            collider.isTrigger = true;
        }
Exemplo n.º 6
0
        private static void CMInvoke()
        {
            if (VoteSites.Count != 0)
            {
                return;
            }

            var sites = new List <IVoteSite>();

            SiteTypes.ForEach(
                type => VitaNexCore.TryCatch(
                    () =>
            {
                var site = type.CreateInstance <IVoteSite>();

                if (site == null)
                {
                    return;
                }

                if (site.Name == "Vita-Nex")
                {
                    site.Enabled = true;
                }

                sites.Add(site);
                CMOptions.ToConsole(
                    "Created site ({0}) '{1}', '{2}'", site.GetType().Name, site.Name, site.Enabled ? "Enabled" : "Disabled");
            },
                    CMOptions.ToConsole));

            sites.ForEach(
                s =>
            {
                if (!VoteSites.ContainsKey(s.UID))
                {
                    VoteSites.Add(s.UID, s);
                }
                else
                {
                    VoteSites[s.UID] = s;
                }
            });

            InternalSiteSort();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Adds a single quest foe to marker position.
        /// </summary>
        static void AddQuestFoe(SiteTypes siteType, Quest quest, QuestMarker marker, Foe foe, Transform parent)
        {
            // Create enemy GameObject
            Vector3    dungeonBlockPosition = new Vector3(marker.dungeonX * RDBLayout.RDBSide, 0, marker.dungeonZ * RDBLayout.RDBSide);
            GameObject go = CreateEnemy("Quest Foe", foe.FoeType, dungeonBlockPosition + marker.flatPosition, parent);

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

            questResourceBehaviour.AssignResource(foe);

            // Set QuestResourceBehaviour in this particular instantiated Foe object
            // Each GameObject placed in world for this Foe will reference same Foe quest resource
            // Keep this one-to-many relationship in mind for Foe handling
            foe.QuestResourceBehaviour = questResourceBehaviour;

            // Rearm injured trigger at time of placement
            // Notes for later:
            //  * This should be rearmed at the beginning of each wave
            //  * Only first wounding of a wave will trigger "injured aFoe" until rearmed on next wave
            foe.RearmInjured();
        }
Exemplo n.º 8
0
        /// <summary>
        /// 获取影片信息
        /// </summary>
        /// <param name="num">番号</param>
        /// <param name="config">用户配置</param>
        /// <returns></returns>
        private static MovieInfo GetMovieInfo(string num, Config config, SiteTypes userSite = SiteTypes.Auto)
        {
            MovieInfo info = null;
            var       site = userSite != SiteTypes.Auto ? userSite : (SiteTypes)Enum.Parse(typeof(SiteTypes), config.Site.ToString());

            switch (site)
            {
            case SiteTypes.All:
                Log.Save($"使用系统默认采集顺序");
                if (NumberTools.IsUncensored(num))     //无码处理
                {
                    if (num.StartsWith("fc2", StringComparison.CurrentCultureIgnoreCase))
                    {
                        Log.Save($"使用 Fc2Club 影片采集");
                        //fc2 单独处理
                        info = new Fc2Club().GetInfoAsync(num);
                        if (info == null)
                        {
                            Log.Save($"Fc2Club 采集失败,使用 Javdb 采集");
                            //未找到再 Javdb
                            info = new Javdb().GetInfoAsync(num);
                        }
                    }
                    else
                    {
                        // 先 Avsox
                        Log.Save($"使用 Avsox 影片采集");
                        info = Avsox.Instance.GetInfoAsync(num);
                        if (info == null)
                        {
                            //未找到再 JavBus
                            Log.Save($"Avsox 采集失败,使用 JavBus 采集");
                            info = JavBus.Instance.GetInfoAsync(num);
                            if (info == null)
                            {
                                Log.Save($"JavBus 采集失败,使用 Javdb 采集");
                                //未找到再 Javdb
                                info = new Javdb().GetInfoAsync(num);
                            }
                        }
                    }
                }
                else
                {
                    //先 Avmoo
                    Log.Save($"使用 Avmoo 影片采集");
                    info = new Avmoo().GetInfoAsync(num);
                    if (info == null)
                    {
                        //未找到再 avBus
                        Log.Save($"Avmoo 采集失败,使用 JavBus 采集");
                        info = JavBus.Instance.GetInfoAsync(num);
                        if (info == null)
                        {
                            //未找到再 Javdb
                            Log.Save($"JavBus 采集失败,使用 Javdb 采集");
                            info = new Javdb().GetInfoAsync(num);

                            /*if (info == null)
                             * {
                             *  //未找到再 JavLibrary
                             *  info = new JavLibrary().GetInfoAsync(num);
                             * }*/
                        }
                    }
                    else
                    {
                        if (info.Star == null)
                        {
                            //未找到再 avBus
                            Log.Save($"Avmoo 未采集到演员,使用 JavBus 采集");
                            info = JavBus.Instance.GetInfoAsync(num);
                        }
                    }
                }
                break;

            case SiteTypes.javbus:
                Log.Save($"使用 JavBus 采集");
                info = JavBus.Instance.GetInfoAsync(num);
                break;

            case SiteTypes.avsox:
                Log.Save($"使用 Avsox 采集");
                info = Avsox.Instance.GetInfoAsync(num);
                break;

            case SiteTypes.javlibrary:
                Log.Save($"使用 JavLibrary 采集");
                info = new JavLibrary().GetInfoAsync(num);
                break;

            case SiteTypes.fc2club:
                Log.Save($"使用 Fc2Club 采集");
                info = new Fc2Club().GetInfoAsync(num);
                break;

            case SiteTypes.avmoo:
                Log.Save($"使用 Avmoo 采集");
                info = new Avmoo().GetInfoAsync(num);
                break;

            case SiteTypes.javdb:
                Log.Save($"使用 Javdb 采集");
                info = new Javdb().GetInfoAsync(num);
                break;
            }
            if (info != null)
            {
                info.Number = num;
                Log.Save($"获取影片信息完成 <= [{info.Generate}]");
                OnLog?.Invoke($"获取影片信息完成 <= [{info.Generate}]", LogLevels.Success);
                return(info);
            }
            else
            {
                Log.Save($"未获取到影片信息");
                throw new Exception($"未获取到影片信息 {num}");
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Finds SiteLinks matching this interior and walks Place markers to inject quest resources.
        /// Some of this handling will be split and relocated for other builders.
        /// Just working through the steps in buildings interiors for now.
        /// This will be moved to a different setup class later.
        /// </summary>
        public static void AddQuestResourceObjects(SiteTypes siteType, Transform parent, int buildingKey = 0)
        {
            // Collect any SiteLinks associdated with this site
            SiteLink[] siteLinks = QuestMachine.Instance.GetSiteLinks(siteType, GameManager.Instance.PlayerGPS.CurrentMapID, buildingKey);
            if (siteLinks == null || siteLinks.Length == 0)
            {
                return;
            }

            // Walk through all found SiteLinks
            foreach (SiteLink link in siteLinks)
            {
                // Get the Quest object referenced by this link
                Quest quest = QuestMachine.Instance.GetActiveQuest(link.questUID);
                if (quest == null)
                {
                    throw new Exception(string.Format("Could not find active quest for UID {0}", link.questUID));
                }

                // Get the Place resource referenced by this link
                Place place = quest.GetPlace(link.placeSymbol);
                if (place == null)
                {
                    throw new Exception(string.Format("Could not find Place symbol {0} in quest UID {1}", link.placeSymbol, link.questUID));
                }

                // Get selected spawn QuestMarker for this Place
                QuestMarker spawnMarker = place.SiteDetails.questSpawnMarkers[place.SiteDetails.selectedQuestSpawnMarker];
                if (spawnMarker.targetResources != null)
                {
                    foreach (Symbol target in spawnMarker.targetResources)
                    {
                        // Get target resource
                        QuestResource resource = quest.GetResource(target);
                        if (resource == null)
                        {
                            continue;
                        }

                        // Inject to scene based on resource type
                        if (resource is Person)
                        {
                            AddQuestNPC(siteType, quest, spawnMarker, (Person)resource, parent);
                        }
                        else if (resource is Foe)
                        {
                            AddQuestFoe(siteType, quest, spawnMarker, (Foe)resource, parent);
                        }
                    }
                }

                // Get selected item QuestMarker for this Place
                QuestMarker itemMarker = place.SiteDetails.questItemMarkers[place.SiteDetails.selectedQuestItemMarker];
                if (itemMarker.targetResources != null)
                {
                    foreach (Symbol target in itemMarker.targetResources)
                    {
                        // Get target resource
                        QuestResource resource = quest.GetResource(target);
                        if (resource == null)
                        {
                            continue;
                        }

                        // Inject into scene
                        if (resource is Item)
                        {
                            AddQuestItem(siteType, quest, itemMarker, (Item)resource, parent);
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        public static async Task <IEnumerable <StagedUser> > GetAllByStageAndSiteType(LoadStageEnum state, SiteTypes type)
        {
            var res = await DocDBRepo.DB <StagedUser> .GetItemsAsync(u => u.LoadState == state && u.SiteType == type);

            return(res.ToList());
        }