public static HashSet <Entity> GetEntitiesOnVisionOfTeamHashSet(int[] teams) { List <int> alreadyCheckedTeams = new List <int>(teams.Length); HashSet <Entity> entitiesOnVisionOfSelectedTeam = new HashSet <Entity>(); for (int i = 0; i < teams.Length; i++) { int team = teams[i]; if (alreadyCheckedTeams.Contains(team)) { throw new System.ArgumentException($"You are giving a list that contains duplicates of the team: {team}"); } if (team < 0 || team > 7) { throw new System.ArgumentException("Currently only supporting 8 teams. 0-7 are the supported teams"); } if (EntitiesOnVisionRangeOfTeamsHashset.ContainsKey(team)) { entitiesOnVisionOfSelectedTeam.AddRange(EntitiesOnVisionRangeOfTeamsHashset[team]); } alreadyCheckedTeams.Add(team); } return(entitiesOnVisionOfSelectedTeam); }
public static HashSet <Entity> GetEntitiesOnVisionOfTeamHashSet(int team) { if (team < 0 || team > 7) { throw new System.NotImplementedException("Currently only supporting 8 teams. 0-7 are the supported teams"); } if (EntitiesOnVisionRangeOfTeamsHashset.ContainsKey(team)) { return(EntitiesOnVisionRangeOfTeamsHashset[team]); } else { return(new HashSet <Entity>()); //throw new System.Exception($"the team selected: {team} doesn't have any entityon sight. Is there any entity of the team with SightRange component?"); } }