public override IPacket GetEnterFieldPacket() { using (var p = new Packet(SendPacketOperations.UserEnterField)) { p.Encode <int>(ID); p.Encode <byte>(Character.Level); p.Encode <string>(Character.Name); // Guild p.Encode <string>(""); p.Encode <short>(0); p.Encode <byte>(0); p.Encode <short>(0); p.Encode <byte>(0); TemporaryStat.EncodeForRemote(p, TemporaryStat.Entries.Values); p.Encode <short>(Character.Job); Character.EncodeLook(p); p.Encode <int>(0); p.Encode <int>(0); p.Encode <int>(0); p.Encode <int>(0); p.Encode <int>(0); p.Encode <int>(0); p.Encode <Point>(Position); p.Encode <byte>(MoveAction); p.Encode <short>(Foothold); p.Encode <byte>(0); p.Encode <byte>(0); p.Encode <int>(0); p.Encode <int>(0); p.Encode <int>(0); p.Encode <byte>(0); p.Encode <bool>(false); EncodeRecord(p); p.Encode <byte>(0); p.Encode <byte>(0); p.Encode <int>(0); return(p); } }
public Task ModifyTemporaryStat(Action <ModifyTemporaryStatContext> action = null) { var context = new ModifyTemporaryStatContext(this); action?.Invoke(context); if (context.ResetOperations.Count > 0) { using (var p = new Packet(SendPacketOperations.TemporaryStatReset)) { TemporaryStat.EncodeMask(p, context.ResetOperations); p.Encode <byte>(0); // IsMovementAffectingStat SendPacket(p); } using (var p = new Packet(SendPacketOperations.UserTemporaryStatReset)) { p.Encode <int>(ID); TemporaryStat.EncodeMask(p, context.ResetOperations); Field.BroadcastPacket(this, p); } } if (context.SetOperations.Count > 0) { using (var p = new Packet(SendPacketOperations.TemporaryStatSet)) { TemporaryStat.EncodeForLocal(p, context.SetOperations); p.Encode <short>(0); // tDelay p.Encode <byte>(0); // IsMovementAffectingStat SendPacket(p); } using (var p = new Packet(SendPacketOperations.UserTemporaryStatSet)) { p.Encode <int>(ID); TemporaryStat.EncodeForRemote(p, context.SetOperations); p.Encode <short>(0); // tDelay Field.BroadcastPacket(this, p); } } if (context.ResetOperations.Count > 0 || context.SetOperations.Count > 0) { ValidateStat(); } return(Task.CompletedTask); }
public Task ModifyTemporaryStat(Action <ModifyTemporaryStatContext> action = null) { var context = new ModifyTemporaryStatContext(this); action?.Invoke(context); if (context.ResetOperations.Count > 0) { context.ResetOperations.ForEach(s => { if (!TemporaryStatTimers.ContainsKey(s.Type)) { return; } TemporaryStatTimers[s.Type].Stop(); TemporaryStatTimers.Remove(s.Type); }); using (var p = new OutPacket(GameSendOperations.TemporaryStatReset)) { TemporaryStat.EncodeMask(p, context.ResetOperations); p.Encode <byte>(0); // IsMovementAffectingStat SendPacket(p); } using (var p = new OutPacket(GameSendOperations.UserTemporaryStatReset)) { p.Encode <int>(ID); TemporaryStat.EncodeMask(p, context.ResetOperations); Field.BroadcastPacket(this, p); } } if (context.SetOperations.Count > 0) { context.SetOperations .Where(s => !s.Permanent) .GroupBy(s => s.DateExpire.Millisecond) .ForEach(g => { var expire = g.First().DateExpire; var timer = new Timer((expire - DateTime.Now).TotalMilliseconds) { AutoReset = false }; timer.Elapsed += (sender, args) => { ModifyTemporaryStat(ts => { g.ForEach(s => { ts.Reset(s.Type); }); }); }; timer.Start(); g.ForEach(s => { TemporaryStatTimers[s.Type] = timer; }); }); using (var p = new OutPacket(GameSendOperations.TemporaryStatSet)) { TemporaryStat.EncodeForLocal(p, context.SetOperations); p.Encode <short>(0); // tDelay p.Encode <byte>(0); // IsMovementAffectingStat SendPacket(p); } using (var p = new OutPacket(GameSendOperations.UserTemporaryStatSet)) { p.Encode <int>(ID); TemporaryStat.EncodeForRemote(p, context.SetOperations); p.Encode <short>(0); // tDelay Field.BroadcastPacket(this, p); } } if (context.ResetOperations.Count > 0 || context.SetOperations.Count > 0) { ValidateStat(); } return(Task.CompletedTask); }