public static void Postfix(MapDisplay __instance, CharacterUI _owner)
            {
                var self = __instance;

                Instance.m_mapID = (int)At.GetValue(typeof(MapDisplay), self, "m_currentMapSceneID");

                if (!(bool)At.GetValue(typeof(MapDisplay), self, "m_currentAreaHasMap"))
                {
                    return;
                }

                //Debug.LogWarning("Current map ID: " + Instance.m_mapID);

                if (MapConfigs.ContainsKey(Instance.m_mapID))
                {
                    self.CurrentMapScene.MarkerOffset = MapConfigs[Instance.m_mapID].MarkerOffset;
                    self.CurrentMapScene.Rotation     = MapConfigs[Instance.m_mapID].Rotation;
                    self.CurrentMapScene.MarkerScale  = MapConfigs[Instance.m_mapID].MarkerScale;
                }

                // caldera node finder

                //var nodes = Resources.FindObjectsOfTypeAll<Gatherable>()
                //                     .Where(it => it.gameObject.scene.name == SceneManagerHelper.ActiveSceneName
                //                               && it.Name.Contains("Unidentified")
                //                               && !it.gameObject.GetComponent<MapWorldMarker>());

                //foreach (var node in nodes)
                //{
                //    var parent = node.transform.parent.parent;
                //    foreach (Transform child in parent)
                //    {
                //        if (child.name.Contains("Pos"))
                //        {
                //            string s;
                //            if (node.Name.Contains("Molepig"))
                //                s = "M";
                //            else if (node.Name.Contains("Ore"))
                //                s = "O";
                //            else
                //                s = "P";
                //            var id = parent.name.Substring(parent.name.Length - 1, 1);
                //            Instance.AddEnemyWorldMarker(child.gameObject, $"{s}{id}");
                //        }
                //    }
                //}

                var list = CharacterManager.Instance.Characters.Values
                           .Where(x =>
                                  !x.GetComponentInChildren <MapWorldMarker>() &&
                                  !x.IsDead &&
                                  x.gameObject.activeSelf);

                foreach (Character c in list)
                {
                    // player markers
                    if ((bool)config.GetValue("ShowPlayerMarkers") && !c.IsAI)
                    {
                        Instance.AddWorldMarker(c.gameObject, c.Name);
                    }
                    // enemy markers
                    if ((bool)config.GetValue("ShowEnemyMarkers") && c.IsAI)
                    {
                        Instance.AddEnemyWorldMarker(c.gameObject, c.Name);
                    }
                }
                // caravanner
                if ((bool)config.GetValue("ShowSoroboreanCaravanner"))
                {
                    var caravanner = GameObject.Find("HumanSNPC_CaravanTrader");

                    if (!caravanner)
                    {
                        caravanner = GameObject.Find("UNPC_CaravanTraderA");
                    }

                    if (caravanner && !caravanner.GetComponentInChildren <MapWorldMarker>())
                    {
                        Instance.AddWorldMarker(caravanner, "Soroborean Caravanner");
                    }
                }
                // player bags
                if ((bool)config.GetValue("ShowPlayerBagMarkers"))
                {
                    foreach (PlayerSystem ps in Global.Lobby.PlayersInLobby)
                    {
                        var c = ps.ControlledCharacter;
                        if (c.Inventory.Equipment.LastOwnedBag != null && c.Inventory.Equipment.LastOwnedBag.OwnerCharacter == null)
                        {
                            var tempObject = new GameObject("TempBagHolder");
                            tempObject.transform.position = c.Inventory.Equipment.LastOwnedBag.transform.position;
                            var marker = Instance.AddWorldMarker(tempObject, c.Name + "'s Bag");
                            Instance.m_bagMarkers.Add(marker);
                        }
                    }
                }

                ////unmarked dungeons
                //if (ModBase.settings.Show_Unmarked_Dungeons && MapConfigs.ContainsKey(m_mapID))
                //{
                //    var disabledObjects = FindDisabledGameObjectsByName(MapConfigs[m_mapID].UnmarkedDungeonObjects.Keys.ToList());

                //    for (int i = 0; i < MapConfigs[m_mapID].UnmarkedDungeonObjects.Count; i++)
                //    {
                //        var entry = MapConfigs[m_mapID].UnmarkedDungeonObjects.ElementAt(i);
                //        var go = disabledObjects[i];

                //        AddIconMarker(go, entry.Value);
                //    }
                //}

                return;
            }
예제 #2
0
            public static void Postfix(MapDisplay __instance, CharacterUI _owner)
            {
                var self = __instance;

                Instance.m_mapID = (int)At.GetValue(typeof(MapDisplay), self, "m_currentMapSceneID");

                if (!(bool)At.GetValue(typeof(MapDisplay), self, "m_currentAreaHasMap"))
                {
                    return;
                }

                if (MapConfigs.ContainsKey(Instance.m_mapID))
                {
                    self.CurrentMapScene.MarkerOffset = MapConfigs[Instance.m_mapID].MarkerOffset;
                    self.CurrentMapScene.Rotation     = MapConfigs[Instance.m_mapID].Rotation;
                    self.CurrentMapScene.MarkerScale  = MapConfigs[Instance.m_mapID].MarkerScale;
                }

                var list = CharacterManager.Instance.Characters.Values
                           .Where(x =>
                                  !x.GetComponentInChildren <MapWorldMarker>() &&
                                  !x.IsDead &&
                                  x.gameObject.activeSelf);

                foreach (Character c in list)
                {
                    // player markers
                    if ((bool)config.GetValue("ShowPlayerMarkers") && !c.IsAI)
                    {
                        Instance.AddWorldMarker(c.gameObject, c.Name);
                    }
                    // enemy markers
                    if ((bool)config.GetValue("ShowEnemyMarkers") && c.IsAI)
                    {
                        Instance.AddEnemyWorldMarker(c.gameObject, c.Name);
                    }
                }
                // caravanner
                if ((bool)config.GetValue("ShowSoroboreanCaravanner"))
                {
                    if (GameObject.Find("HumanSNPC_CaravanTrader") is GameObject merchant && !merchant.GetComponentInChildren <MapWorldMarker>())
                    {
                        Instance.AddWorldMarker(merchant, "Soroborean Caravanner");
                    }
                }
                // player bags
                if ((bool)config.GetValue("ShowPlayerBagMarkers"))
                {
                    foreach (PlayerSystem ps in Global.Lobby.PlayersInLobby)
                    {
                        var c = ps.ControlledCharacter;
                        if (c.Inventory.Equipment.LastOwnedBag != null && c.Inventory.Equipment.LastOwnedBag.OwnerCharacter == null)
                        {
                            var tempObject = new GameObject("TempBagHolder");
                            tempObject.transform.position = c.Inventory.Equipment.LastOwnedBag.transform.position;
                            var marker = Instance.AddWorldMarker(tempObject, c.Name + "'s Bag");
                            Instance.m_bagMarkers.Add(marker);
                        }
                    }
                }

                ////unmarked dungeons
                //if (ModBase.settings.Show_Unmarked_Dungeons && MapConfigs.ContainsKey(m_mapID))
                //{
                //    var disabledObjects = FindDisabledGameObjectsByName(MapConfigs[m_mapID].UnmarkedDungeonObjects.Keys.ToList());

                //    for (int i = 0; i < MapConfigs[m_mapID].UnmarkedDungeonObjects.Count; i++)
                //    {
                //        var entry = MapConfigs[m_mapID].UnmarkedDungeonObjects.ElementAt(i);
                //        var go = disabledObjects[i];

                //        AddIconMarker(go, entry.Value);
                //    }
                //}

                return;
            }