Example #1
0
 public static void ParseStationaryObjectOnTransport(this MovementBlock block)
 {
     block.TransporterId         = block.Update.ReadPackedEntityId();
     block.Position              = block.Update.ReadVector4NoO();
     block.TransporterPosition   = block.Update.ReadVector4NoO();
     block.Position.W            = block.Update.ReadFloat();
     block.TransporterPosition.W = block.Update.ReadFloat();
 }
Example #2
0
        public UpdateBlock(ParsedUpdatePacket parser, int index)
        {
            this.index = index;
            packet = parser;
            //Offset = parser.index;

            Type = (UpdateType)ReadByte();

            if (!Enum.IsDefined(typeof(UpdateType), (byte)Type))
            {
                throw new Exception("Invalid UpdateType '" + Type + "' in Block " + this);
            }

            // Console.WriteLine("Reading {0}-Block...", Type);

            if (Type == UpdateType.OutOfRange ||
                Type == UpdateType.Near)
            {
                var count = ReadUInt();
                EntityIds = new EntityId[count];
                for (var i = 0; i < count; i++)
                {
                    EntityIds[i] = ReadPackedEntityId();
                }
            }
            else
            {
                EntityId = ReadPackedEntityId();

                if (Type == UpdateType.Create ||
                    Type == UpdateType.CreateSelf)
                {
                    ObjectType = (ObjectTypeId)ReadByte();
                }

                if (Type == UpdateType.Create ||
                    Type == UpdateType.CreateSelf ||
                    Type == UpdateType.Movement)
                {
                    m_movement = ReadMovementBlock();
                }

                if (Type != UpdateType.Movement)
                {
                    Values = ReadValues();
                }
            }

            if (Type != UpdateType.Create && Type != UpdateType.CreateSelf)
            {
                ObjectType = EntityId.ObjectType;
            }
        }
Example #3
0
        public UpdateBlock(ParsedUpdatePacket parser, int index)
        {
            this.index = index;
            packet     = parser;
            //Offset = parser.index;

            Type = (UpdateType)ReadByte();

            if (!Enum.IsDefined(typeof(UpdateType), (byte)Type))
            {
                throw new Exception("Invalid UpdateType '" + Type + "' in Block " + this);
            }

            // Console.WriteLine("Reading {0}-Block...", Type);

            if (Type == UpdateType.OutOfRange ||
                Type == UpdateType.Near)
            {
                var count = ReadUInt();
                EntityIds = new EntityId[count];
                for (var i = 0; i < count; i++)
                {
                    EntityIds[i] = ReadPackedEntityId();
                }
            }
            else
            {
                EntityId = ReadPackedEntityId();

                if (Type == UpdateType.Create ||
                    Type == UpdateType.CreateSelf)
                {
                    ObjectType = (ObjectTypeId)ReadByte();
                }

                if (Type == UpdateType.Create ||
                    Type == UpdateType.CreateSelf ||
                    Type == UpdateType.Movement)
                {
                    m_movement = ReadMovementBlock();
                }

                if (Type != UpdateType.Movement)
                {
                    Values = ReadValues();
                }
            }

            if (Type != UpdateType.Create && Type != UpdateType.CreateSelf)
            {
                ObjectType = EntityId.ObjectType;
            }
        }
Example #4
0
        public static void Parse(this MovementBlock block)
        {
            // a world object will always be one of these.
            if (block.UpdateFlags.HasFlag(UpdateFlags.Living))
            {
                ParseLiving(block);
            }
            else if (block.UpdateFlags.HasFlag(UpdateFlags.StationaryObjectOnTransport))
            {
                ParseStationaryObjectOnTransport(block);
            }
            else if (block.UpdateFlags.HasFlag(UpdateFlags.StationaryObject))
            {
                ParseStationaryObject(block);
            }

            if (block.UpdateFlags.HasFlag(UpdateFlags.Flag_0x8))
            {
                block.Flag0x8 = block.Update.ReadUInt();
            }

            if (block.UpdateFlags.HasFlag(UpdateFlags.Flag_0x10))
            {
                block.Flag0x10             = block.Update.ReadUInt();
                block.Update.packet.index -= 4;
                block.Flag0x10F            = block.Update.ReadFloat();
            }

            if (block.UpdateFlags.HasFlag(UpdateFlags.AttackingTarget))
            {
                block.AttackingTarget = block.Update.ReadPackedEntityId();
            }

            if (block.UpdateFlags.HasFlag(UpdateFlags.Transport))
            {
                block.TransportTimeSync = block.Update.ReadUInt();
            }

            if (block.UpdateFlags.HasFlag(UpdateFlags.Vehicle))
            {
                block.VehicleId            = block.Update.ReadUInt();
                block.VehicleAimAdjustment = block.Update.ReadFloat();
            }
            if (block.UpdateFlags.HasFlag(UpdateFlags.HasRotation))
            {
                block.Flag0x200 = block.Update.ReadUInt64();
            }
        }
Example #5
0
 /// <summary>
 /// Removes circular references
 /// </summary>
 public void Dispose()
 {
     m_movement = null;
 }
Example #6
0
 public static void ParseStationaryObject(this MovementBlock block)
 {
     block.Position = block.Update.ReadVector4();
 }
Example #7
0
        public static void ParseLiving(this MovementBlock block)
        {
            block.MovementFlags  = (MovementFlags)block.Update.ReadUInt();
            block.MovementFlags2 = (MovementFlags2)block.Update.ReadUShort();
            block.Timestamp      = block.Update.ReadUInt();

            block.ParseStationaryObject();

            // Console.WriteLine("\tParsing Movement for {0}", block.UpdateFlags);

            // Client checks for 0x200
            if (block.MovementFlags.HasFlag(MovementFlags.OnTransport))
            {
                block.TransporterId         = block.Update.ReadPackedEntityId();
                block.TransporterPosition   = block.Update.ReadVector4();
                block.TransporterTime       = block.Update.ReadUInt();
                block.TransportSeatPosition = block.Update.ReadByte();
            }

            // Client checks for 0x2200000
            if (block.MovementFlags.HasAnyFlag(MovementFlags.Swimming | MovementFlags.Flying) ||
                block.MovementFlags2.HasFlag(MovementFlags2.AlwaysAllowPitching))
            {
                block.Pitch = block.Update.ReadFloat();
            }

            block.FallTime = block.Update.ReadUInt();

            // Client checks for 0x1000
            if (block.MovementFlags.HasFlag(MovementFlags.Falling))
            {
                // no idea
                block.FallFloat1 = block.Update.ReadFloat();
                block.FallFloat2 = block.Update.ReadFloat();
                block.FallFloat3 = block.Update.ReadFloat();
                block.FallFloat4 = block.Update.ReadFloat();
            }

            // Client checks for 0x4000000
            if (block.MovementFlags.HasFlag(MovementFlags.SplineElevation))
            {
                block.Spline0x4000000 = block.Update.ReadFloat();
            }

            // read speeds
            block.Speeds = new Speeds
            {
                Walk     = block.Update.ReadFloat(),
                Run      = block.Update.ReadFloat(),
                RunBack  = block.Update.ReadFloat(),
                Swim     = block.Update.ReadFloat(),
                SwimBack = block.Update.ReadFloat(),
                Fly      = block.Update.ReadFloat(),
                FlyBack  = block.Update.ReadFloat(),
                Turn     = block.Update.ReadFloat(),
                Pitch    = block.Update.ReadFloat()
            };


            if (block.MovementFlags.HasFlag(MovementFlags.SplineEnabled))
            {
                block.SplineFlags = (SplineFlags)block.Update.ReadUInt();

                if (block.SplineFlags.HasFlag(SplineFlags.FinalFaceAngle))
                {
                    block.SplinePosition.W = block.Update.ReadFloat();
                }
                else if (block.SplineFlags.HasFlag(SplineFlags.FinalFaceTarget))
                {
                    block.SplineId = block.Update.ReadEntityId();
                }
                else if (block.SplineFlags.HasFlag(SplineFlags.FinalFacePoint))
                {
                    block.SplinePosition = block.Update.ReadVector4NoO();
                }

                block.SplineMsTimeUnk = block.Update.ReadUInt();
                block.SplineUnkInt1   = block.Update.ReadUInt();
                block.SplineUnkInt2   = block.Update.ReadUInt();

                block.SplineVectorUnk = block.Update.ReadVector3();
                block.SplineUnkInt3   = block.Update.ReadUInt();

                block.SplineCount = block.Update.ReadUInt();
                if (block.SplineCount > 0)
                {
                    block.SplineNodes = new Vector3[block.SplineCount];
                    for (int i = 0; i < block.SplineCount; i++)
                    {
                        block.SplineNodes[i] = block.Update.ReadVector3();
                    }
                }
                block.SplineUnkByte = block.Update.ReadByte();

                block.SplineFinalNode = block.Update.ReadVector3();
            }
        }
Example #8
0
 /// <summary>
 /// Removes circular references
 /// </summary>
 public void Dispose()
 {
     m_movement = null;
 }