/** * Gets all the objects in the game that are associated with that team, * except for subs. * * @param team * The team to get the objects of * * @return * All the non-sub objects on the team. */ public static List <GameObject> GetNonSubsOnTeam(int team) { HashSet <GameObject> objs = new HashSet <GameObject> (GuidList.GetObjectsOnTeam(team)); objs.ExceptWith(GameObject.FindGameObjectsWithTag("Subsurface")); return(objs.ToList()); }
/** * Gets a list of all objects visible to this unit without duplicates. * * @return * A list of all game objects visible to the team */ public List <GameObject> GetVisibleToTeam() { // Initialize a list for storing all visible objects, with duplicates HashSet <GameObject> visibleObjects = new HashSet <GameObject>(); ////Debug.Log("Team.GetVisibleToTeam: At start of foreach loop. # of Loops: " + GuidList.GetObjectsOnTeam(this.MyKey).Count ); // Iterate over all objects associated with the team foreach (GameObject obj in GuidList.GetObjectsOnTeam(this.MyKey)) { // Determines all objects visible to this object and add them to the list List <GameObject> visibletothisone = obj.GetComponent <DetectorController>().Ping(); ////Debug.Log("Team.GetVisibleToTeam: Inside of foreach loop. # of Units found by ping: " + visibletothisone.Count ); ////Debug.Log(visibletothisone.Count); visibleObjects.UnionWith(visibletothisone); } ////Debug.Log("Team.GetVisibleToTeam: At end of foreach loop. # of unique Units found: " + visibleObjects.Count ); // Check if friendly subs should be visible if (GlobalSettings.GetSubmarineSensorLinkState()) { // If friendly subs should be visible // Add all objects on the team visibleObjects.UnionWith(GuidList.GetObjectsOnTeam(MyKey)); } else { // If friendly subs should not be visible // Add all non-sub objects visibleObjects.UnionWith(GuidList.GetNonSubsOnTeam(MyKey)); } // Add all omnipresent objects visibleObjects.UnionWith(GuidList.GetOmnipresentObjects()); // Remove all invisible objects visibleObjects.ExceptWith(GuidList.GetInvisibleObjects()); // Convert back to a list and return. return(visibleObjects.ToList <GameObject>()); }