public void AddTargetIndex(int count) { if (_missionTargetIndex < MissionTargetList.Length - count) { _missionTargetIndex += count; } if (OnDescriptionChange != null) { OnDescriptionChange.Invoke(this); } }
internal void PushCommand(Command cmd) { if (cmd.Source == CommandSource.Client) { return; } switch (cmd.Token) { case "JCH": { var jch = cmd as Server_JCH_ChannelJoin; var character = Connection.GetOrCreateCharacter(jch.Character.Identity); if (!_Characters.Contains(character)) { _Characters.Add(character); } if (!string.IsNullOrEmpty(jch.Title)) { _Title = jch.Title; Joined = true; } else { OnUserJoin?.Invoke(this, new ChannelUserEntryEventArgs(this, character, jch)); } } return; case "LCH": { var lch = cmd as Server_LCH_ChannelLeave; var character = GetCharacter(lch.Character); _Characters.Remove(character); if (character.Name == Connection.LocalCharacter.Name) { Dispose(); } else { OnUserLeave?.Invoke(this, new ChannelUserEntryEventArgs(this, character, lch)); } } return; case "ICH": { var ich = cmd as Server_ICH_ChannelInitialData; _ChannelMode = ich.Mode; Joined = true; foreach (var user in ich.Users) { var ch = GetCharacter(user.Identity); if (!_Characters.Contains(ch)) { _Characters.Add(ch); } } } return; case "COL": { var col = cmd as Server_COL_ChannelGetOPs; foreach (var op in col.OPs) { if (!string.IsNullOrWhiteSpace(op)) { _OPs.Add(GetCharacter(op)); } } } return; case "CDS": { var cds = cmd as Server_CDS_ChannelChangeDescription; OnDescriptionChange?.Invoke(this, new ChannelEntryEventArgs <string>(this, cds.Description, cds)); _Description = cds.Description; } return; case "RMO": { var rmo = cmd as Server_RMO_ChannelSetMode; OnModeChange?.Invoke(this, new ChannelEntryEventArgs <ChannelMode>(this, rmo.Mode, rmo)); _ChannelMode = rmo.Mode; } return; case "CSO": { var cso = cmd as Server_CSO_ChannelSetOwner; OnOwnerChange?.Invoke(this, new ChannelEntryEventArgs <Character>(this, GetCharacter(cso.Character), cso)); _OwnerName = cso.Character; } return; case "RST": { var rst = cmd as Server_RST_ChannelSetStatus; OnStatusChange?.Invoke(this, new ChannelEntryEventArgs <ChannelStatus>(this, rst.Status, rst)); _Status = rst.Status; } return; case "COA": { var coa = cmd as Server_COA_ChannelMakeOP; var character = GetCharacter(coa.Character); _OPs.Add(character); OnOPAdded?.Invoke(this, new ChannelUserEntryEventArgs(this, character, coa)); } return; case "COR": { var cor = cmd as Server_COR_ChannelRemoveOP; var character = GetCharacter(cor.Character); _OPs.Remove(character); OnOPRemoved?.Invoke(this, new ChannelUserEntryEventArgs(this, character, cor)); } return; case "CKU": { var cku = cmd as Server_CKU_ChannelKickCharacter; var character = GetCharacter(cku.Character); _Characters.Remove(character); OnUserKicked?.Invoke(this, new ChannelAdminActionEventArgs(this, character, GetCharacter(cku.OP), cku)); } return; case "CBU": { var cbu = cmd as Server_CBU_ChannelBanCharacter; var character = GetCharacter(cbu.Character); _Characters.Remove(character); _Banlist.Add(character); OnUserBanned?.Invoke(this, new ChannelAdminActionEventArgs(this, character, GetCharacter(cbu.OP), cbu)); } return; case "CUB": { var cub = cmd as Server_CUB_ChannelUnbanCharacter; var character = GetCharacter(cub.Character); _Banlist.Remove(character); OnUserUnbanned?.Invoke(this, new ChannelAdminActionEventArgs(this, character, GetCharacter(cub.OP), cub)); } return; case "CTU": { var ctu = cmd as Server_CTU_ChannelTimeoutCharacter; var character = GetCharacter(ctu.Character); _Characters.Remove(character); OnUserTimedout?.Invoke(this, new ChannelAdminActionEventArgs(this, character, GetCharacter(ctu.OP), ctu)); } return; case "MSG": { var msg = cmd as Server_MSG_ChannelChatMessage; OnChatMessage?.Invoke(this, new ChannelUserMessageEventArgs(this, GetCharacter(msg.Character), msg.Message, msg)); } return; case "LRP": { var lrp = cmd as Server_LRP_ChannelLFRPMessage; OnLFRPMessage?.Invoke(this, new ChannelUserMessageEventArgs(this, GetCharacter(lrp.Character), lrp.AD, lrp)); } return; case "RLL": { var rll = cmd as Server_RLL_ChannelRollMessage; OnRollMessage?.Invoke(this, new ChannelUserMessageEventArgs(this, GetCharacter(rll.Character), rll.Message, rll)); } return; case "SYS": { var sys = cmd as Server_SYS_ChatSYSMessage; OnSYSMessage?.Invoke(this, new ChannelEntryEventArgs <string>(this, sys.Message, sys)); } return; } }