protected virtual void HandleChangeGroupsOperation( PlayerPeer peer, ChangeGroups changeGroupsRequest, SendParameters sendParameters) { // get the actor who send the operation request var actor = GetActorByPeer(peer); if (actor == null) { return; } actor.RemoveGroups(changeGroupsRequest.Remove); if (changeGroupsRequest.Add != null) { if (changeGroupsRequest.Add.Length > 0) { foreach (var groupId in changeGroupsRequest.Add) { ActorGroup group; if (!ActorGroups.TryGetValue(groupId, out group)) { group = new ActorGroup(groupId); ActorGroups.Add(groupId, group); } actor.AddGroup(group); } } else { foreach (var group in ActorGroups.Values) { actor.AddGroup(group); } } } }
public void AddGroup(ActorGroup group) { _groups.Add(group); group.Add(this); }