private void S2SSendGroupUpdate(NebulaCommon.Group.Group group) { UpdateZoneForGroupMembers(group); S2SGroupUpdateEvent evt = new S2SGroupUpdateEvent { group = group.GetInfo() }; EventData evtData = new EventData((byte)S2SEventCode.GroupUpdate, evt); mApplication.MasterPeer.SendEvent(evtData, new SendParameters()); }
private void CheckForRemoving(NebulaCommon.Group.Group group) { if (group.memberCount < 2) { mCache.TryRemoveGroup(group.groupID); foreach (var mem in group.members) { SendGroupRemovedToCharacter(mem.Value.characterID, group.groupID); } S2SSendGroupRemoved(group.groupID); } }
private void SendGroupUpdateToClients(NebulaCommon.Group.Group group) { foreach (var member in group.members) { SelectCharacterClientPeer peer; if (mApplication.Clients.TryGetPeerForCharacterId(member.Value.characterID, out peer)) { GroupUpdateEvent evt = new GroupUpdateEvent { groupHash = group.GetInfo() }; EventData evtData = new EventData((byte)SelectCharacterEventCode.GroupUpdateEvent, evt); peer.SendEvent(evtData, new SendParameters()); } } }
private bool CreateGroupFromNotification(string gameRefID, string characterID, string login, Hashtable data) { string sourceGameRefID = data.Value <string>((int)SPC.GameRefId); string sourceCharacterID = data.Value <string>((int)SPC.CharacterId); string sourceLogin = data.Value <string>((int)SPC.Login); NebulaCommon.Group.Group group = null; if (mCache.TryGetGroupForCharacter(sourceCharacterID, out group)) { if (group.IsLeader(sourceCharacterID)) { if (AddCharacterToGroup(group, gameRefID, characterID, login, false)) { SendGroupUpdate(group.groupID); SetGroupOnPeer(characterID, group.groupID); return(true); } } } else { var newGroup = new NebulaCommon.Group.Group { groupID = Guid.NewGuid().ToString() }; bool leaderAdded = AddCharacterToGroup(newGroup, sourceGameRefID, sourceCharacterID, sourceLogin, true); bool otherAdded = AddCharacterToGroup(newGroup, gameRefID, characterID, login, false); mCache.TryAddGroup(newGroup); if (leaderAdded) { SetGroupOnPeer(sourceCharacterID, newGroup.groupID); } if (otherAdded) { SetGroupOnPeer(characterID, newGroup.groupID); } if (leaderAdded && otherAdded) { SendGroupUpdate(newGroup.groupID); return(true); } } return(false); }
private void UpdateZoneForGroupMembers(NebulaCommon.Group.Group group) { foreach (var member in group.members) { DbPlayerCharactersObject player; if (!mApplication.Players.TryGetPlayer(member.Value.gameRefID, out player)) { log.InfoFormat("UpdateZoneForGroupMembers(): player not found = {0}", member.Value.gameRefID); continue; } var character = player.GetCharacter(member.Value.characterID); if (character == null) { log.InfoFormat("UpdateZoneForGroupMembers(): character not found = {0}", member.Value.characterID); continue; } member.Value.worldID = character.WorldId; } }
private bool AddCharacterToGroupNotification(string gameRefID, string characterID, string login, Hashtable data) { string sourceGameRefID = data.Value <string>((int)SPC.GameRefId); string sourceCharacterID = data.Value <string>((int)SPC.CharacterId); string sourceLogin = data.Value <string>((int)SPC.Login); NebulaCommon.Group.Group group = null; if (mCache.TryGetGroupForCharacter(sourceCharacterID, out group)) { if (group.IsLeader(sourceCharacterID)) { if (AddCharacterToGroup(group, gameRefID, characterID, login, false)) { SendGroupUpdate(group.groupID); SetGroupOnPeer(characterID, group.groupID); return(true); } } } return(false); }
private bool AddCharacterToGroup(NebulaCommon.Group.Group group, string gameRefID, string characterID, string login, bool asLeader) { if (group.allowNewMembers) { DbPlayerCharactersObject player; if (!mApplication.Players.TryGetPlayer(gameRefID, out player)) { log.InfoFormat("player not found = {0}", gameRefID); return(false); } var character = player.GetCharacter(characterID); if (character == null) { log.InfoFormat("character not found = {0}", characterID); return(false); } bool result = group.AddMember(new GroupMember { characterID = characterID, gameRefID = gameRefID, isLeader = asLeader, login = login, worldID = character.WorldId, exp = character.Exp, workshop = character.Workshop, characterName = character.Name, characterIcon = character.characterIcon }); if (result) { SetGroupOnPeer(characterID, group.groupID); } return(result); //SendGroupUpdate(group.groupID); } return(false); }
public bool TryGetGroup(string groupID, out NebulaCommon.Group.Group group) { return(mCache.TryGetGroup(groupID, out group)); }