private List <string> GenerateGameData(bool FullPackageData) { List <string> ReturnList; if (FullPackageData) { ReturnList = new List <string> { GameMode, isGameJoltPlayer.Tobool().ToString(), isGameJoltPlayer ? GameJoltID.ToString() : "", DecimalSeparator, Name, LevelFile, Position.ConvertStringCulture(this), Facing.ToString(), Moving.Tobool().ToString(), Skin, BusyType.ToString(), PokemonVisible.Tobool().ToString(), PokemonPosition.ConvertStringCulture(this), PokemonSkin, PokemonFacing.ToString() }; } else { ReturnList = new List <string> { "", "", "", "", "", LastValidGameData[0] == LevelFile ? "" : LevelFile, LastValidGameData[1] == Position ? "" : Position.ConvertStringCulture(this), LastValidGameData[2] == Facing.ToString() ? "" : Facing.ToString(), LastValidGameData[3] == Moving.Tobool().ToString() ? "" : Moving.Tobool().ToString(), LastValidGameData[4] == Skin ? "" : Skin, LastValidGameData[5] == BusyType.ToString() ? "" : BusyType.ToString(), LastValidGameData[6] == PokemonVisible.Tobool().ToString() ? "" : PokemonVisible.Tobool().ToString(), LastValidGameData[7] == PokemonPosition ? "" : PokemonPosition.ConvertStringCulture(this), LastValidGameData[8] == PokemonSkin ? "" : PokemonSkin, LastValidGameData[9] == PokemonFacing.ToString() ? "" : PokemonFacing.ToString() }; } return(ReturnList); }
private DataItems GenerateDataItems() { return(new DataItems( GameMode, IsGameJoltPlayer ? "1" : "0", GameJoltID.ToString(CultureInfo), DecimalSeparator.ToString(), Name, LevelFile, Position.ToP3DString(DecimalSeparator, CultureInfo), Facing.ToString(CultureInfo), Moving ? "1" : "0", Skin, BusyType, PokemonVisible ? "1" : "0", PokemonPosition.ToP3DString(DecimalSeparator, CultureInfo), PokemonSkin, PokemonFacing.ToString(CultureInfo))); }
/// <summary> /// Update Player Objects /// </summary> /// <param name="p">Package Data</param> /// <param name="SentToServer">Sent data to server?</param> public void Update(Package p, bool SentToServer) { if (Network != null) { Network.LastValidMovement = DateTime.Now; } if (p.IsFullPackageData()) { GameMode = p.DataItems[0]; isGameJoltPlayer = p.DataItems[1].ToInt().Tobool(); GameJoltID = isGameJoltPlayer ? p.DataItems[2].ToInt() : -1; DecimalSeparator = p.DataItems[3]; Name = p.DataItems[4]; LevelFile = p.DataItems[5]; Position = p.DataItems[6]; Facing = p.DataItems[7].ToInt(); Moving = p.DataItems[8].ToInt().Tobool(); Skin = p.DataItems[9]; BusyType = p.DataItems[10].ToInt(); PokemonVisible = p.DataItems[11].ToInt().Tobool(); PokemonPosition = p.DataItems[12]; PokemonSkin = p.DataItems[13]; PokemonFacing = p.DataItems[14].ToInt(); LastValidGameData = new List <string> { LevelFile, Position, Facing.ToString(), Moving.ToString(), Skin, BusyType.ToString(), PokemonVisible.ToString(), PokemonPosition, PokemonSkin, PokemonFacing.ToString() }; } else { LastValidGameData = new List <string> { LevelFile, Position, Facing.ToString(), Moving.ToString(), Skin, BusyType.ToString(), PokemonVisible.ToString(), PokemonPosition, PokemonSkin, PokemonFacing.ToString() }; if (!string.IsNullOrWhiteSpace(p.DataItems[5]) && p.DataItems[5].SplitCount() == 1) { LevelFile = p.DataItems[5]; } if (!string.IsNullOrWhiteSpace(p.DataItems[6]) && p.DataItems[6].SplitCount() == 3) { Position = p.DataItems[6]; } if (!string.IsNullOrWhiteSpace(p.DataItems[7]) && p.DataItems[7].SplitCount() == 1) { Facing = p.DataItems[7].ToInt(); } if (!string.IsNullOrWhiteSpace(p.DataItems[8]) && p.DataItems[8].SplitCount() == 1) { Moving = p.DataItems[8].ToInt().Tobool(); } if (!string.IsNullOrWhiteSpace(p.DataItems[9]) && p.DataItems[9].SplitCount() <= 2) { Skin = p.DataItems[9]; } if (!string.IsNullOrWhiteSpace(p.DataItems[10]) && p.DataItems[10].SplitCount() == 1) { BusyType = p.DataItems[10].ToInt(); } if (!string.IsNullOrWhiteSpace(p.DataItems[11]) && p.DataItems[11].SplitCount() == 1) { PokemonVisible = p.DataItems[11].ToInt().Tobool(); } if (!string.IsNullOrWhiteSpace(p.DataItems[12]) && p.DataItems[12].SplitCount() == 3) { PokemonPosition = p.DataItems[12]; } if (!string.IsNullOrWhiteSpace(p.DataItems[13]) && p.DataItems[13].SplitCount() <= 2) { PokemonSkin = p.DataItems[13]; } if (!string.IsNullOrWhiteSpace(p.DataItems[14]) && p.DataItems[14].SplitCount() == 1) { PokemonFacing = p.DataItems[14].ToInt(); } } // Sent To Server if (SentToServer) { Core.RCONPlayer.SendToAllPlayer(new RCON_Client_Listener.Packages.Package(RCON_Client_Listener.Packages.Package.PackageTypes.UpdatePlayer, $"{ID},{ToString()}", null)); PlayerEvent.Invoke(PlayerEvent.Types.Update, $"{ID},{ToString()}"); if (p.IsFullPackageData()) { Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.GameData, ID, GenerateGameData(true), null)); } else { Core.Player.SendToAllPlayer(new Package(Package.PackageTypes.GameData, ID, GenerateGameData(false), null)); } } }
public void Update(Package.Package package, bool sentToAllPlayer) { LastValidMovement = DateTime.Now; if (package.IsFullPackageData()) { GameMode = package.DataItems[0]; IsGameJoltPlayer = package.DataItems[1].ToInt().ToBool(); GameJoltID = IsGameJoltPlayer ? package.DataItems[2] : "-1"; DecimalSeparator = package.DataItems[3]; Name = package.DataItems[4]; LevelFile = package.DataItems[5]; Position = package.DataItems[6]; Facing = package.DataItems[7].ToInt(); Moving = package.DataItems[8].ToBool(); Skin = package.DataItems[9]; BusyType = package.DataItems[10].ToInt(); PokemonVisible = package.DataItems[11].ToBool(); PokemonPosition = package.DataItems[12]; PokemonSkin = package.DataItems[13]; PokemonFacing = package.DataItems[14].ToInt(); LastValidGameData = new List <string> { LevelFile, Position, Facing.ToString(), Moving.ToString(), Skin, BusyType.ToString(), PokemonVisible.ToString(), PokemonPosition, PokemonSkin, PokemonFacing.ToString() }; } else { LastValidGameData = new List <string> { LevelFile, Position, Facing.ToString(), Moving.ToString(), Skin, BusyType.ToString(), PokemonVisible.ToString(), PokemonPosition, PokemonSkin, PokemonFacing.ToString() }; if (!string.IsNullOrWhiteSpace(package.DataItems[5]) && package.DataItems[5].SplitCount() == 1) { LevelFile = package.DataItems[5]; } if (!string.IsNullOrWhiteSpace(package.DataItems[6]) && package.DataItems[6].SplitCount() == 3) { Position = package.DataItems[6]; } if (!string.IsNullOrWhiteSpace(package.DataItems[7]) && package.DataItems[7].SplitCount() == 1) { Facing = package.DataItems[7].ToInt(); } if (!string.IsNullOrWhiteSpace(package.DataItems[8]) && package.DataItems[8].SplitCount() == 1) { Moving = package.DataItems[8].ToBool(); } if (!string.IsNullOrWhiteSpace(package.DataItems[9]) && package.DataItems[9].SplitCount() <= 2) { Skin = package.DataItems[9]; } if (!string.IsNullOrWhiteSpace(package.DataItems[10]) && package.DataItems[10].SplitCount() == 1) { BusyType = package.DataItems[10].ToInt(); } if (!string.IsNullOrWhiteSpace(package.DataItems[11]) && package.DataItems[11].SplitCount() == 1) { PokemonVisible = package.DataItems[11].ToBool(); } if (!string.IsNullOrWhiteSpace(package.DataItems[12]) && package.DataItems[12].SplitCount() == 3) { PokemonPosition = package.DataItems[12]; } if (!string.IsNullOrWhiteSpace(package.DataItems[13]) && package.DataItems[13].SplitCount() <= 2) { PokemonSkin = package.DataItems[13]; } if (!string.IsNullOrWhiteSpace(package.DataItems[14]) && package.DataItems[14].SplitCount() == 1) { PokemonFacing = package.DataItems[14].ToInt(); } } if (sentToAllPlayer) { Core.TcpClientCollection.SendToAllPlayer(new Package.Package(Core, PackageTypes.GameData, ID, GenerateGameData(package.IsFullPackageData()), Network)); } }