public void WriteUpdatePositionPayload(BinaryWriter writer) { writer.WriteGuid(Guid); Position.Serialize(writer, PositionFlag); var player = Guid.IsPlayer() ? this as Player : null; writer.Write((ushort)(player?.TotalLogins ?? 1)); // instance sequence writer.Write((ushort)++MovementIndex); writer.Write((ushort)TeleportIndex); writer.Write((ushort)ForcePositionIndex); }
public void WriteUpdatePositionPayload(BinaryWriter writer) { var updatePositionFlags = UpdatePositionFlag.Contact; writer.WriteGuid(Guid); writer.Write((uint)updatePositionFlags); Position.Serialize(writer, false); if ((updatePositionFlags & UpdatePositionFlag.NoQuaternionW) == 0) { writer.Write(Position.Facing.W); } if ((updatePositionFlags & UpdatePositionFlag.NoQuaternionW) == 0) { writer.Write(Position.Facing.X); } if ((updatePositionFlags & UpdatePositionFlag.NoQuaternionW) == 0) { writer.Write(Position.Facing.Y); } if ((updatePositionFlags & UpdatePositionFlag.NoQuaternionW) == 0) { writer.Write(Position.Facing.Z); } if ((updatePositionFlags & UpdatePositionFlag.Velocity) != 0) { // velocity would go here } var player = Guid.IsPlayer() ? this as Player : null; writer.Write((ushort)(player?.TotalLogins ?? 0)); writer.Write((ushort)++MovementIndex); writer.Write((ushort)TeleportIndex); writer.Write((ushort)0); }
// todo: return bytes of data for network write ? ? public void Serialize(WorldObject wo, BinaryWriter writer) { if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Velocity) > 0 && this.Velocity == null) { // velocity is null, but the flag wants to include it. unset the flag. PhysicsDescriptionFlag ^= PhysicsDescriptionFlag.Velocity; } writer.Write((uint)PhysicsDescriptionFlag); writer.Write((uint)PhysicsState); if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Movement) != 0) { if (currentMotionState != null) { var movementData = currentMotionState.GetPayload(wo.Guid, wo.Sequences); writer.Write(movementData.Length); // number of bytes in movement object writer.Write(movementData); uint autonomous = currentMotionState.IsAutonomous ? (ushort)1 : (ushort)0; writer.Write(autonomous); } else // create a new current motion state and send it. { currentMotionState = new UniversalMotion(MotionStance.Standing); var movementData = currentMotionState.GetPayload(wo.Guid, wo.Sequences); writer.Write(movementData.Length); writer.Write(movementData); uint autonomous = currentMotionState.IsAutonomous ? (ushort)1 : (ushort)0; writer.Write(autonomous); } } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.AnimationFrame) != 0) { writer.Write((uint)AnimationFrame); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Position) != 0) { Position.Serialize(writer); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.MTable) != 0) { writer.Write((uint)MTableResourceId); } // stable_id = BYTE1(v12) & 8 ) = 8 if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Stable) != 0) { writer.Write((uint)Stable); } // setup id if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Petable) != 0) { writer.Write((uint)Petable); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.CSetup) != 0) { writer.Write((uint)CSetup); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Children) != 0) { writer.Write((uint)ItemsEquipedCount); foreach (EquippedItem child in children) { writer.Write((uint)child.Guid); writer.Write((uint)child.EquipMask); } } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.ObjScale) != 0) { writer.Write(ObjScale); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Friction) != 0) { writer.Write(Friction); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Elasticity) != 0) { writer.Write(Elastcity); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Translucency) != 0) { writer.Write(Translucency); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Velocity) != 0) { Velocity.Serialize(writer); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Acceleration) != 0) { Acceleration.Serialize(writer); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Omega) != 0) { Omega.Serialize(writer); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.DefaultScript) != 0) { writer.Write((uint)DefaultScript); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.DefaultScriptIntensity) != 0) { writer.Write((float)DefaultScriptIntensity); } // TODO: There are 9 of these - but we need to research the correct sequence. I know that the last one is instance (totalLogins) Og II writer.Write(sequences.GetCurrentSequence(SequenceType.ObjectPosition)); writer.Write(sequences.GetCurrentSequence(SequenceType.ObjectMovement)); writer.Write(sequences.GetCurrentSequence(SequenceType.ObjectState)); writer.Write(sequences.GetCurrentSequence(SequenceType.ObjectVector)); writer.Write(sequences.GetCurrentSequence(SequenceType.ObjectTeleport)); writer.Write(sequences.GetCurrentSequence(SequenceType.ObjectServerControl)); writer.Write(sequences.GetCurrentSequence(SequenceType.ObjectForcePosition)); writer.Write(sequences.GetCurrentSequence(SequenceType.ObjectVisualDesc)); writer.Write(sequences.GetCurrentSequence(SequenceType.ObjectInstance)); writer.Align(); }
//todo: return bytes of data for network write ? ? public void Serialize(BinaryWriter writer) { writer.Write((uint)PhysicsDescriptionFlag); writer.Write((uint)PhysicsState); //if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Movement) != 0) //{ //} //if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.AnimationFrame) != 0) //{ //} if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Position) != 0) { Position.Serialize(writer); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.MTable) != 0) { writer.Write((uint)MTableResourceId); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Stable) != 0) { writer.Write((uint)Stable); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Petable) != 0) { writer.Write((uint)Petable); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.CSetup) != 0) { writer.Write((uint)CSetup); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Children) != 0) { writer.Write((uint)CSetup); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Children) != 0) { writer.Write((uint)ItemsEquipedCount); foreach (EquippedItem child in children) { writer.Write((uint)child.Guid); writer.Write((uint)child.EquipMask); } } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.ObjScale) != 0) { writer.Write(ObjScale); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Friction) != 0) { writer.Write(Friction); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Elastcity) != 0) { writer.Write(Elastcity); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Translucency) != 0) { writer.Write(Translucency); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Velocity) != 0) { Velocity.Serialize(writer); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Acceleration) != 0) { Acceleration.Serialize(writer); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Omega) != 0) { Omega.Serialize(writer); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.DefaultScript) != 0) { writer.Write((uint)DefaultScript); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.DefaultScriptIntensity) != 0) { writer.Write((float)DefaultScriptIntensity); } writer.Write((ushort)PositionSequence); writer.Write((ushort)unknownseq0); writer.Write((ushort)(PhysicsSequence)); writer.Write((ushort)JumpSequence); writer.Write((ushort)PortalSequence); writer.Write((ushort)unknownseq1); writer.Write((ushort)0); writer.Write((ushort)0); writer.Write((ushort)(SpawnSequence)); writer.Align(); }
// todo: return bytes of data for network write ? ? public void Serialize(BinaryWriter writer) { writer.Write((uint)PhysicsDescriptionFlag); writer.Write((uint)PhysicsState); if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Movement) != 0) { // TODO: Implement properly writer.Write(0u); // number of bytes in movement object // autonomous flag goes here, but is omitted if the movement bytes is 0 } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.AnimationFrame) != 0) { writer.Write((uint)AnimationFrame); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Position) != 0) { Position.Serialize(writer); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.MTable) != 0) { writer.Write((uint)MTableResourceId); } // stable_id = BYTE1(v12) & 8 ) = 8 if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Stable) != 0) { writer.Write((uint)Stable); } // setup id if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Petable) != 0) { writer.Write((uint)Petable); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.CSetup) != 0) { writer.Write((uint)CSetup); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Children) != 0) { writer.Write((uint)ItemsEquipedCount); foreach (EquippedItem child in children) { writer.Write((uint)child.Guid); writer.Write((uint)child.EquipMask); } } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.ObjScale) != 0) { writer.Write(ObjScale); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Friction) != 0) { writer.Write(Friction); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Elastcity) != 0) { writer.Write(Elastcity); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Translucency) != 0) { writer.Write(Translucency); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Velocity) != 0) { Velocity.Serialize(writer); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Acceleration) != 0) { Acceleration.Serialize(writer); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.Omega) != 0) { Omega.Serialize(writer); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.DefaultScript) != 0) { writer.Write((uint)DefaultScript); } if ((PhysicsDescriptionFlag & PhysicsDescriptionFlag.DefaultScriptIntensity) != 0) { writer.Write((float)DefaultScriptIntensity); } writer.Write((ushort)PositionSequence); writer.Write((ushort)InstanceSequence); writer.Write((ushort)(PhysicsSequence)); writer.Write((ushort)JumpSequence); writer.Write((ushort)PortalSequence); writer.Write((ushort)ForcePositionSequence); writer.Write((ushort)0); writer.Write((ushort)0); writer.Write((ushort)(SpawnSequence)); writer.Align(); }