public ZoneMgr(RegionMgr Region, Zone_Info Info) { this.Region = Region; this.ZoneId = Info.ZoneId; this.Info = Info; this.Running = true; this.ClientInfo = ClientFileMgr.GetZoneInfo(Info.ZoneId); }
public void WriteMovementState(PacketOut Out) { if (_unit.Zone == null) { Log.Error("WriteMovementState", $"{_unit.Name} with no Zone - pendingDisposal:{_unit.PendingDisposal} isDisposed:{_unit.IsDisposed}"); return; } Out.WriteUInt16(_unit.Oid); Out.WriteUInt16((ushort)_unit.X); Out.WriteUInt16((ushort)_unit.Y); Out.WriteUInt16((ushort)_unit.Z); Out.WriteByte(_unit.PctHealth); byte flags = 0; if ((IsMoving && MovementSpeed > 0) || _forcePositionUpdate) { flags |= (byte)EObjectState.Moving; } if (MoveState == EMoveState.Recall) { flags |= (byte)EObjectState.Recall; } else if (FollowTarget != null) { flags |= (byte)EObjectState.LookingAt; } //TODO buggy movement in zones > 255 ? if (_unit.Zone.ZoneId > 255) { flags = (byte)Utils.setBit(flags, 2, true); } // flying if (_unit.IsCreature()) { if ((Utils.getBit(_unit.Faction, 5) || (Utils.getBit(_unit.GetCreature().Spawn.Proto.Faction, 5) && Utils.HasFlag(flags, (int)EObjectState.Moving))) && _unit.Z - ClientFileMgr.GetHeight(_unit.Zone.ZoneId, _unit.X, _unit.Y) > 50) { flags = (byte)Utils.setBit(flags, 5, true); } } Out.WriteByte(flags); Out.WriteByte((byte)_unit.Zone.ZoneId); if (_unit is BuffHostObject) { Out.WriteByte(4); // Unk1 Out.WriteUInt32(3); // Unk2 } else { Out.WriteByte(_forcePositionUpdate? (byte)6 : (byte)0); Out.WriteUInt32(0); } if (Utils.HasFlag(flags, (int)EObjectState.Moving)) { Out.WriteUInt16R((ushort)_totalSpeed); Out.WriteByte(0); // DestUnk Out.WriteUInt16R(_unit.Zone.CalculPin((uint)_destWorldPos.X, true)); Out.WriteUInt16R(_unit.Zone.CalculPin((uint)_destWorldPos.Y, false)); Out.WriteUInt16R((ushort)_destWorldPos.Z); Out.WriteByte((byte)_destZoneId); } else { Out.WriteUInt16R(_unit.Heading); } if (Utils.HasFlag(flags, (int)EObjectState.LookingAt)) { Out.WriteUInt16R(FollowTarget.Oid); } }