public void AppendToStream(BinaryStream stream) { stream.AppendInt(Id); stream.AppendInt((int)Type); stream.AppendLong(Owner.Eid); var sourceEid = Source?.Eid ?? 0L; stream.AppendLong(sourceEid); var timer = Timer; if (timer != null) { stream.AppendInt((int)timer.Interval.TotalMilliseconds); stream.AppendInt((int)timer.Elapsed.TotalMilliseconds); } else { stream.AppendInt(0); stream.AppendInt(0); } stream.AppendInt(PropertyModifiers.Count()); foreach (var property in PropertyModifiers) { property.AppendToPacket(stream); } }
public override void VisitLock(Lock @lock) { _stream.AppendLong(@lock.Id); _stream.AppendByte((byte)_lockType); _stream.AppendByte((byte)@lock.State); _stream.AppendByte((byte)(@lock.Primary ? 1 : 0)); _stream.AppendLong((long)@lock.Timer.Duration.TotalMilliseconds); _stream.AppendLong((long)@lock.Timer.Elapsed.TotalMilliseconds); _stream.AppendLong(@lock.Owner.Eid); _stream.AppendStream(_target); }
private Packet BuildReinforcePacket() { var units = _zone.Units.WithinRange(_player.CurrentPosition, REINFORCE_SCAN_RANGE).ToArray(); var stream = new BinaryStream(); var counter = 0; foreach (var unit in units) { var pbsObject = unit as IPBSObject; if (pbsObject == null) { continue; } stream.AppendInt(unit.Definition); stream.AppendLong(unit.Eid); stream.AppendInt(pbsObject.ReinforceHandler.ReinforceCounter); var inReinforce = 0; var reinforceTime = TimeSpan.Zero; var reinforceEnd = pbsObject.ReinforceHandler.ReinforceEnd; if (reinforceEnd != null) { inReinforce = 1; reinforceTime = CalculateTime((DateTime)reinforceEnd); } stream.AppendInt(inReinforce); stream.AppendInt((int)reinforceTime.TotalSeconds); counter++; } var reinforcePacket = new Packet(ZoneCommand.ScanReinforceResult); reinforcePacket.AppendInt(counter); reinforcePacket.AppendStream(stream); return(reinforcePacket); }
public override void VisitUnitLock(UnitLock unitLock) { _lockType = LockType.Unit; _target.AppendLong(unitLock.Target.Eid); base.VisitUnitLock(unitLock); }