public void UpdateTeams(string oldName, string oldTeam) { if (Team == oldTeam && Name == oldName) { return; } //Debug.Log("Call; oldName: '" + oldName + "' Name: '" + Name + "' oldTeam: '" + oldTeam + "' Team: " + Team); // Updates team and player data for the local Teams system. Teams t = Teams.I; if (Name != oldName) { if (string.IsNullOrEmpty(oldName)) { // We did not have an old name... // Check to see if we are on the system (we should not be!) and add the player if (!t.PlayerInSystem(Name)) { t.EnsureTeam(Team); t.AddPlayer(this, Team); Debug.Log("Added player to system. Name: " + Name + ", Team: " + Team); } } else { // We have an old name, lets change names! if (t.PlayerInSystem(oldName)) { t.ChangePlayerName(oldName, Name); Debug.Log("Changed player name from '" + oldName + "' to '" + Name + "'"); } else { t.EnsureTeam(Team); t.AddPlayer(this, Team); } } } if (Team != oldTeam) { if (string.IsNullOrEmpty(oldTeam)) { // Means that this must be first time commit, meaning that we have already been added to team! } else { // Old team is not null, lets swap teams! if (t.PlayerInSystem(Name)) { t.EnsureTeam(Team); t.ChangePlayerTeam(Name, Team); Debug.Log("Changed team of player '" + Name + "' from team '" + oldTeam + "' to '" + Team + "'"); } else { t.EnsureTeam(Team); t.AddPlayer(this, Team); Debug.Log("Added player WHILE changing team: '" + Name + "' from team '" + oldTeam + "' to '" + Team + "'"); } } } }