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;
            }
            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"))
                {
                    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;
            }
Esempio n. 3
0
            public static void Postfix(MapDisplay __instance, CharacterUI _owner)
            {
                var self = __instance;

                Instance.currentMapID = self.m_currentMapSceneID;

                if (!self.m_currentAreaHasMap)
                {
                    return;
                }

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

                if (MapConfig.ConfigDict.ContainsKey(Instance.currentMapID))
                {
                    self.CurrentMapScene.MarkerOffset = MapConfig.ConfigDict[Instance.currentMapID].MarkerOffset;
                    self.CurrentMapScene.Rotation     = MapConfig.ConfigDict[Instance.currentMapID].Rotation;
                    self.CurrentMapScene.MarkerScale  = MapConfig.ConfigDict[Instance.currentMapID].MarkerScale;
                }

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

                foreach (Character c in list)
                {
                    var markerComp = c.GetComponentInChildren <MapWorldMarker>();

                    if (!c.IsAI)
                    {
                        // player markers
                        if (ShowPlayerMarkers.Value && !markerComp)
                        {
                            Instance.AddWorldMarker(c.gameObject, c.Name);
                        }
                        else if (!ShowPlayerMarkers.Value && markerComp)
                        {
                            GameObject.Destroy(markerComp);
                        }
                    }
                    else
                    {
                        // enemy markers
                        if (ShowEnemyMarkers.Value && !markerComp &&
                            (!OnlyShowEnemiesAboveThreshold.Value || c.ActiveMaxHealth >= LargeMarkerHealthThreshold.Value))
                        {
                            Instance.AddEnemyWorldMarker(c.gameObject, c.Name, Color.white);
                        }
                        else if (markerComp &&
                                 (!ShowEnemyMarkers.Value ||
                                  (OnlyShowEnemiesAboveThreshold.Value && c.ActiveMaxHealth < LargeMarkerHealthThreshold.Value)))
                        {
                            GameObject.Destroy(markerComp);
                        }
                    }
                }


                // caravanner
                var caravanner = GameObject.Find("HumanSNPC_CaravanTrader");

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

                if (caravanner)
                {
                    var comp = caravanner.GetComponentInChildren <MapWorldMarker>();
                    if (ShowSoroborean.Value && !comp)
                    {
                        Instance.AddWorldMarker(caravanner, "Soroborean Caravanner");
                    }
                    else if (!ShowSoroborean.Value && comp)
                    {
                        GameObject.Destroy(comp);
                    }
                }

                // player bags
                if (ShowPlayerBagMarkers.Value)
                {
                    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");
                            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;
            }