public virtual void Deserialize(GenericReader reader) { int version = reader.GetVersion(); if (version > 5) { reader.ReadBlock( r => { if (version > 6) { Serial = new PvPSerial(r); } else { Serial = r.ReadTypeCreate<PvPSerial>(r) ?? new PvPSerial(r); } }); } switch (version) { case 7: case 6: case 5: Hidden = reader.ReadBool(); goto case 4; case 4: FloorItemDelete = reader.ReadBool(); goto case 3; case 3: case 2: { Gate = reader.ReadItem<PvPSpectatorGate>(); if (Gate != null) { Gate.Battle = this; } } goto case 1; case 1: { Category = reader.ReadString(); Ranked = reader.ReadBool(); InviteWhileRunning = reader.ReadBool(); } goto case 0; case 0: { if (version < 6) { reader.ReadBlock(r => Serial = r.ReadTypeCreate<PvPSerial>(r) ?? new PvPSerial(r)); } DebugMode = reader.ReadBool(); State = reader.ReadFlag<PvPBattleState>(); Name = reader.ReadString(); Description = reader.ReadString(); AutoAssign = reader.ReadBool(); UseTeamColors = reader.ReadBool(); IgnoreCapacity = reader.ReadBool(); SubCommandPrefix = reader.ReadChar(); QueueAllowed = reader.ReadBool(); SpectateAllowed = reader.ReadBool(); KillPoints = version < 3 ? (reader.ReadBool() ? 1 : 0) : reader.ReadInt(); PointsBase = reader.ReadInt(); PointsRankFactor = reader.ReadDouble(); IdleKick = reader.ReadBool(); IdleThreshold = reader.ReadTimeSpan(); LastState = reader.ReadFlag<PvPBattleState>(); LastStateChange = reader.ReadDateTime(); LightLevel = reader.ReadInt(); LogoutDelay = reader.ReadTimeSpan(); Doors.AddRange(reader.ReadStrongItemList<BaseDoor>()); reader.ReadBlock(r => Options = r.ReadTypeCreate<PvPBattleOptions>(r) ?? new PvPBattleOptions(r)); if (Schedule != null && Schedule.Running) { Schedule.Stop(); } reader.ReadBlock(r => Schedule = r.ReadTypeCreate<Schedule>(r) ?? new Schedule("Battle " + Serial.Value, false)); reader.ReadBlock(r => BattleRegion = r.ReadTypeCreate<PvPBattleRegion>(this, r) ?? new PvPBattleRegion(this, r)); reader.ReadBlock( r => SpectateRegion = r.ReadTypeCreate<PvPSpectateRegion>(this, r) ?? new PvPSpectateRegion(this, r)); reader.ReadBlockList(r => r.ReadTypeCreate<PvPTeam>(this, r) ?? new PvPTeam(this, r), Teams); } break; } }
private static bool SerializeBattle(GenericWriter writer, PvPSerial key, PvPBattle val) { int version = writer.SetVersion(0); switch (version) { case 0: { writer.WriteBlock(w => w.WriteType(key, t => key.Serialize(w))); writer.WriteBlock(w => w.WriteType(val, t => val.Serialize(w))); } break; } return true; }
public static IPvPBattle FindBattleIByID(PvPSerial serial) { return(Battles.Where(kvp => kvp.Key.Equals(serial)).Select(kvp => kvp.Value).FirstOrDefault()); }
public virtual void Deserialize(GenericReader reader) { var version = reader.GetVersion(); if (version > 5) { reader.ReadBlock( r => { if (version > 6) { Serial = new PvPSerial(r); } else { Serial = r.ReadTypeCreate <PvPSerial>(r); Serial = new PvPSerial(); } }); } switch (version) { case 7: case 6: case 5: Hidden = reader.ReadBool(); goto case 4; case 4: _FloorItemDelete = reader.ReadBool(); goto case 3; case 3: case 2: { Gate = reader.ReadItem <PvPSpectatorGate>(); if (Gate != null) { Gate.Battle = this; } } goto case 1; case 1: { Category = reader.ReadString(); Ranked = reader.ReadBool(); InviteWhileRunning = reader.ReadBool(); } goto case 0; case 0: { if (version < 6) { reader.ReadBlock(r => Serial = r.ReadTypeCreate <PvPSerial>(r) ?? new PvPSerial(r)); } DebugMode = reader.ReadBool(); _State = reader.ReadFlag <PvPBattleState>(); _Name = reader.ReadString(); Description = reader.ReadString(); AutoAssign = reader.ReadBool(); UseTeamColors = reader.ReadBool(); IgnoreCapacity = reader.ReadBool(); _SubCommandPrefix = reader.ReadChar(); QueueAllowed = reader.ReadBool(); SpectateAllowed = reader.ReadBool(); KillPoints = version < 3 ? (reader.ReadBool() ? 1 : 0) : reader.ReadInt(); PointsBase = reader.ReadInt(); PointsRankFactor = reader.ReadDouble(); IdleKick = reader.ReadBool(); IdleThreshold = reader.ReadTimeSpan(); LastState = reader.ReadFlag <PvPBattleState>(); LastStateChange = reader.ReadDateTime(); _LightLevel = reader.ReadInt(); LogoutDelay = reader.ReadTimeSpan(); Doors.AddRange(reader.ReadStrongItemList <BaseDoor>()); reader.ReadBlock(r => Options = r.ReadTypeCreate <PvPBattleOptions>(r) ?? new PvPBattleOptions()); if (Schedule != null && Schedule.Running) { Schedule.Stop(); } reader.ReadBlock(r => Schedule = r.ReadTypeCreate <Schedule>(r) ?? new Schedule("Battle " + Serial.Value, false)); reader.ReadBlock(r => _BattleRegion = r.ReadTypeCreate <PvPBattleRegion>(this, r) ?? new PvPBattleRegion(this)); reader.ReadBlock( r => _SpectateRegion = r.ReadTypeCreate <PvPSpectateRegion>(this, r) ?? new PvPSpectateRegion(this)); reader.ReadBlockList(r => r.ReadTypeCreate <PvPTeam>(this, r) ?? new PvPTeam(this), Teams); } break; } }
public PvPProfileHistoryEntry(int season) { UID = new PvPSerial(TimeStamp.UtcNow + "~" + Utility.RandomMinMax(0, Int32.MaxValue)); Season = season; }
public virtual void Deserialize(GenericReader reader) { var version = reader.GetVersion(); if (version > 4) { reader.ReadBlock( r => { if (version > 5) { Serial = new PvPSerial(r); } else { Serial = r.ReadTypeCreate <PvPSerial>(r); Serial = new PvPSerial(); } }); } else { Serial = new PvPSerial(); } switch (version) { case 8: case 7: { RespawnRangeMin = reader.ReadInt(); RespawnRangeMax = reader.ReadInt(); } goto case 6; case 6: case 5: case 4: case 3: RespawnOnStart = reader.ReadBool(); goto case 2; case 2: KickOnDeath = reader.ReadBool(); goto case 1; case 1: { GateLocation = new MapPoint(reader); Gate = reader.ReadItem <PvPTeamGate>(); } goto case 0; case 0: { _Name = reader.ReadString(); _MinCapacity = reader.ReadInt(); _MaxCapacity = reader.ReadInt(); _Color = reader.ReadInt(); _HomeBase = reader.ReadPoint3D(); _SpawnPoint = reader.ReadPoint3D(); RespawnOnDeath = reader.ReadBool(); RespawnDelay = reader.ReadTimeSpan(); if (version < 8) { reader.ReadBlock(r => r.ReadType()); // Statistics } } break; } if (version < 4) { RespawnOnStart = true; } if (version < 1) { GateLocation = MapPoint.Empty; } if (Gate != null) { Gate.Team = this; } if (Battle == null) { Timer.DelayCall(Delete); } }
public virtual void Deserialize(GenericReader reader) { int version = reader.GetVersion(); if (version > 4) { reader.ReadBlock( r => { if (version > 5) { Serial = new PvPSerial(r); } else { Serial = r.ReadTypeCreate<PvPSerial>(r) ?? new PvPSerial(r); Serial = new PvPSerial(); } }); } else { Serial = new PvPSerial(); } switch (version) { case 6: case 5: case 4: case 3: RespawnOnStart = reader.ReadBool(); goto case 2; case 2: KickOnDeath = reader.ReadBool(); goto case 1; case 1: { GateLocation = new MapPoint(reader); Gate = reader.ReadItem<PvPTeamGate>(); } goto case 0; case 0: { Name = reader.ReadString(); MinCapacity = reader.ReadInt(); MaxCapacity = reader.ReadInt(); Color = reader.ReadInt(); HomeBase = reader.ReadPoint3D(); SpawnPoint = reader.ReadPoint3D(); RespawnOnDeath = reader.ReadBool(); RespawnDelay = reader.ReadTimeSpan(); reader.ReadBlock(r => Statistics = r.ReadTypeCreate<PvPTeamStatistics>(this) ?? new PvPTeamStatistics(this)); } break; } if (version < 4) { RespawnOnStart = true; } if (version < 1) { GateLocation = MapPoint.Empty; } if (Gate != null) { Gate.Team = this; } if (Battle == null) { Delete(); } }