// TODO Fix ctor public Entity(Coob coob, Client owner) { Client = owner; Position = new QVector3(); Rotation = new Vector3(); Velocity = new Vector3(); Acceleration = new Vector3(); ExtraVelocity = new Vector3(); Appearance = new Appearance(); RayHit = new Vector3(); ItemData = new Item(); Equipment = new Item[EquipmentCount]; for (int i = 0; i < EquipmentCount; i++) { Equipment[i] = new Item(); } Skills = new uint[SkillCount]; }
public Entity() { Position = new QVector3(); Rotation = new Vector3(); Velocity = new Vector3(); Acceleration = new Vector3(); ExtraVelocity = new Vector3(); Appearance = new Appearance(); RayHit = new Vector3(); ItemData = new Item(); Equipment = new Item[13]; for (int i = 0; i < 13; i++) Equipment[i] = new Item(); Skills = new uint[11]; }
public void ReadByMask(BinaryReader reader) { LastBitmask = reader.ReadBytes(8); BitArray bitArray = new BitArray(LastBitmask); if (bitArray.Get(0)) { Position = new QVector3 { X = reader.ReadInt64(), Y = reader.ReadInt64(), Z = reader.ReadInt64() }; } if (bitArray.Get(1)) { Rotation = new Vector3 { Pitch = reader.ReadSingle(), Roll = reader.ReadSingle(), Yaw = reader.ReadSingle() }; } if (bitArray.Get(2)) { Velocity = new Vector3 { X = reader.ReadSingle(), Y = reader.ReadSingle(), Z = reader.ReadSingle() }; } if (bitArray.Get(3)) { Acceleration = new Vector3 { X = reader.ReadSingle(), Y = reader.ReadSingle(), Z = reader.ReadSingle() }; } if (bitArray.Get(4)) { ExtraVelocity = new Vector3 { X = reader.ReadSingle(), Y = reader.ReadSingle(), Z = reader.ReadSingle() }; } if (bitArray.Get(5)) { LookPitch = reader.ReadSingle(); } if (bitArray.Get(6)) { PhysicsFlags = reader.ReadUInt32(); } if (bitArray.Get(7)) { SpeedFlags = reader.ReadByte(); } if (bitArray.Get(8)) { EntityType = reader.ReadUInt32(); } if (bitArray.Get(9)) { CurrentMode = reader.ReadByte(); } if (bitArray.Get(10)) { LastShootTime = reader.ReadUInt32(); } if (bitArray.Get(11)) { HitCounter = reader.ReadUInt32(); } if (bitArray.Get(12)) { LastHitTime = reader.ReadUInt32(); } if (bitArray.Get(13)) { Appearance.Read(reader); } if (bitArray.Get(14)) { Flags1 = reader.ReadByte(); Flags2 = reader.ReadByte(); } if (bitArray.Get(15)) { RollTime = reader.ReadUInt32(); } if (bitArray.Get(16)) { StunTime = reader.ReadInt32(); } if (bitArray.Get(17)) { SlowedTime = reader.ReadUInt32(); } if (bitArray.Get(18)) { MakeBlueTime = reader.ReadUInt32(); } if (bitArray.Get(19)) { SpeedUpTime = reader.ReadUInt32(); } if (bitArray.Get(20)) { ShowPatchTime = reader.ReadSingle(); } if (bitArray.Get(21)) { ClassType = reader.ReadByte(); } if (bitArray.Get(22)) { Specialization = reader.ReadByte(); } if (bitArray.Get(23)) { ChargedMP = reader.ReadSingle(); } if (bitArray.Get(24)) { not_used1 = reader.ReadUInt32(); not_used2 = reader.ReadUInt32(); not_used3 = reader.ReadUInt32(); } if (bitArray.Get(25)) { not_used4 = reader.ReadUInt32(); not_used5 = reader.ReadUInt32(); not_used6 = reader.ReadUInt32(); } if (bitArray.Get(26)) { RayHit = new Vector3 { X = reader.ReadSingle(), Y = reader.ReadSingle(), Z = reader.ReadSingle() }; } if (bitArray.Get(27)) { HP = reader.ReadSingle(); } if (bitArray.Get(28)) { MP = reader.ReadSingle(); } if (bitArray.Get(29)) { BlockPower = reader.ReadSingle(); } if (bitArray.Get(30)) { MaxHPMultiplier = reader.ReadSingle(); ShootSpeed = reader.ReadSingle(); DamageMultiplier = reader.ReadSingle(); ArmorMultiplier = reader.ReadSingle(); ResistanceMultiplier = reader.ReadSingle(); } if (bitArray.Get(31)) { not_used7 = reader.ReadByte(); } if (bitArray.Get(32)) { not_used8 = reader.ReadByte(); } if (bitArray.Get(33)) { Level = reader.ReadUInt32(); } if (bitArray.Get(34)) { CurrentXP = reader.ReadUInt32(); } if (bitArray.Get(35)) { ParentOwner = reader.ReadUInt64(); } if (bitArray.Get(36)) { unknown_or_not_used1 = reader.ReadUInt32(); unknown_or_not_used2 = reader.ReadUInt32(); } if (bitArray.Get(37)) { unknown_or_not_used3 = reader.ReadByte(); } if (bitArray.Get(38)) { unknown_or_not_used4 = reader.ReadUInt32(); } if (bitArray.Get(39)) { unknown_or_not_used5 = reader.ReadUInt32(); not_used11 = reader.ReadUInt32(); not_used12 = reader.ReadUInt32(); } if (bitArray.Get(40)) { not_used13 = reader.ReadUInt32(); not_used14 = reader.ReadUInt32(); not_used15 = reader.ReadUInt32(); not_used16 = reader.ReadUInt32(); not_used17 = reader.ReadUInt32(); not_used18 = reader.ReadUInt32(); } if (bitArray.Get(41)) { not_used20 = reader.ReadUInt32(); not_used21 = reader.ReadUInt32(); not_used22 = reader.ReadUInt32(); } if (bitArray.Get(42)) { not_used19 = reader.ReadByte(); } if (bitArray.Get(43)) { ItemData.Read(reader); } if (bitArray.Get(44)) { for (int i = 0; i < 13; i++) { Item item = new Item(); item.Read(reader); Equipment[i] = item; } } if (bitArray.Get(45)) { Name = Encoding.ASCII.GetString(reader.ReadBytes(16)); Name = Name.TrimEnd(' ', '\0'); } if (bitArray.Get(46)) { Skills = new uint[11]; for (int i = 0; i < 11; i++) { Skills[i] = reader.ReadUInt32(); } } if (bitArray.Get(47)) { IceBlockFour = reader.ReadUInt32(); } }
public void CopyByMask(Entity from) { LastBitmask = from.LastBitmask; BitArray bitArray = new BitArray(LastBitmask); if (bitArray.Get(0)) { Position = from.Position.Clone(); } if (bitArray.Get(1)) { Rotation = from.Rotation.Clone(); } if (bitArray.Get(2)) { Velocity = from.Velocity.Clone(); } if (bitArray.Get(3)) { Acceleration = from.Acceleration.Clone(); } if (bitArray.Get(4)) { ExtraVelocity = from.ExtraVelocity.Clone(); } if (bitArray.Get(5)) { LookPitch = from.LookPitch; } if (bitArray.Get(6)) { PhysicsFlags = from.PhysicsFlags; } if (bitArray.Get(7)) { SpeedFlags = from.SpeedFlags; } if (bitArray.Get(8)) { EntityType = from.EntityType; } if (bitArray.Get(9)) { CurrentMode = from.CurrentMode; } if (bitArray.Get(10)) { LastShootTime = from.LastShootTime; } if (bitArray.Get(11)) { HitCounter = from.HitCounter; } if (bitArray.Get(12)) { LastHitTime = from.LastHitTime; } if (bitArray.Get(13)) { Appearance.CopyFrom(from.Appearance); } if (bitArray.Get(14)) { Flags1 = from.Flags1; Flags2 = from.Flags2; } if (bitArray.Get(15)) { RollTime = from.RollTime; } if (bitArray.Get(16)) { StunTime = from.StunTime; } if (bitArray.Get(17)) { SlowedTime = from.SlowedTime; } if (bitArray.Get(18)) { MakeBlueTime = from.MakeBlueTime; } if (bitArray.Get(19)) { SpeedUpTime = from.SpeedUpTime; } if (bitArray.Get(20)) { ShowPatchTime = from.ShowPatchTime; } if (bitArray.Get(21)) { ClassType = from.ClassType; } if (bitArray.Get(22)) { Specialization = from.Specialization; } if (bitArray.Get(23)) { ChargedMP = from.ChargedMP; } if (bitArray.Get(24)) { not_used1 = from.not_used1; not_used2 = from.not_used2; not_used3 = from.not_used3; } if (bitArray.Get(25)) { not_used4 = from.not_used4; not_used5 = from.not_used5; not_used6 = from.not_used6; } if (bitArray.Get(26)) { RayHit = from.RayHit.Clone(); } if (bitArray.Get(27)) { HP = from.HP; } if (bitArray.Get(28)) { MP = from.MP; } if (bitArray.Get(29)) { BlockPower = from.BlockPower; } if (bitArray.Get(30)) { MaxHPMultiplier = from.MaxHPMultiplier; ShootSpeed = from.ShootSpeed; DamageMultiplier = from.DamageMultiplier; ArmorMultiplier = from.ArmorMultiplier; ResistanceMultiplier = from.ResistanceMultiplier; } if (bitArray.Get(31)) { not_used7 = from.not_used7; } if (bitArray.Get(32)) { not_used8 = from.not_used8; } if (bitArray.Get(33)) { Level = from.Level; } if (bitArray.Get(34)) { CurrentXP = from.CurrentXP; } if (bitArray.Get(35)) { ParentOwner = from.ParentOwner; } if (bitArray.Get(36)) { unknown_or_not_used1 = from.unknown_or_not_used1; unknown_or_not_used2 = from.unknown_or_not_used2; } if (bitArray.Get(37)) { unknown_or_not_used3 = from.unknown_or_not_used3; } if (bitArray.Get(38)) { unknown_or_not_used4 = from.unknown_or_not_used4; } if (bitArray.Get(39)) { unknown_or_not_used5 = from.unknown_or_not_used5; not_used11 = from.not_used11; not_used12 = from.not_used12; } if (bitArray.Get(40)) { not_used13 = from.not_used13; not_used14 = from.not_used14; not_used15 = from.not_used15; not_used16 = from.not_used16; not_used17 = from.not_used17; not_used18 = from.not_used18; } if (bitArray.Get(41)) { not_used20 = from.not_used20; not_used21 = from.not_used21; not_used22 = from.not_used22; } if (bitArray.Get(42)) { not_used19 = from.not_used19; } if (bitArray.Get(43)) { ItemData.CopyFrom(from.ItemData); } if (bitArray.Get(44)) { for (int i = 0; i < 13; i++) { Item item = new Item(); item.CopyFrom(from.Equipment[i]); Equipment[i] = item; } } if (bitArray.Get(45)) { Name = from.Name; } if (bitArray.Get(46)) { Skills = new uint[11]; for (int i = 0; i < 11; i++) { Skills[i] = from.Skills[i]; } } if (bitArray.Get(47)) { IceBlockFour = from.IceBlockFour; } }
static void Main(string[] args) { Console.OutputEncoding = System.Text.Encoding.Unicode; QVector3<Distance> pos = new QVector3<Distance>( SI<Distance>.Kilo * 2, SI<Distance>.Kilo * 1.2, Distance.Meter * 750); Console.WriteLine(pos.FormatAuto()); Console.WriteLine(pos.FormatAs(Distance.Meter)); Console.WriteLine("Magnitude: " + pos.Magnitude.FormatAuto()); pos /= 10000; Console.WriteLine(pos.FormatAuto()); Console.WriteLine("Magnitude: " + pos.Magnitude.FormatAuto()); pos = pos.Normalized; Console.WriteLine(pos.FormatAuto()); Console.WriteLine("Magnitude: " + pos.Magnitude.FormatAuto()); //Temperature t = Temperature.Celsius * 20; //Console.WriteLine(t.FormatAs(Temperature.Celsius, "#.##")); //Console.WriteLine(t.FormatAs(Temperature.Kelvin, "#.##")); //Console.WriteLine(t.FormatAs(Temperature.Fahrenheit, "#.##")); //t = Temperature.Kelvin * 0; //Console.WriteLine(t.FormatAs(Temperature.Celsius, "#.##")); //Console.WriteLine(t.FormatAs(Temperature.Kelvin, "#.##")); //Console.WriteLine(t.FormatAs(Temperature.Fahrenheit, "#.##")); //Length l = SI<Length>.Kilo * 10; //try //{ // Console.WriteLine(l.FormatAs("km")); // Console.WriteLine(l.FormatAs("trm")); //} //catch(UnitNameNotFoundException uex) //{ // Console.WriteLine(uex.ToString()); //} //for (; ; ) //{ // Voltage v; // Current i; // bool okay = false; // do // { // Console.Write("Enter Voltage: "); // okay = Unit<Voltage>.TryParse(Console.ReadLine(), out v); // if(!okay) // Console.WriteLine("Invalid!"); // } while (!okay); // do // { // Console.Write("Enter Current: "); // okay = Unit<Current>.TryParse(Console.ReadLine(), out i); // if(!okay) // Console.WriteLine("Invalid!"); // } while (!okay); // Resistance r = v/i; // Console.Write("Resistance: "); // Console.WriteLine(r.FormatAuto("#.###")); // Console.WriteLine("--------------------"); //} //Length l = Length.Angstrom * 0.25; //StringBuilder str = new StringBuilder(); //for (int i = 0; i < 30; i++) //{ // string line = l.FormatAs(Length.Meter, "e1") // + " \t| " + l.FormatAuto("0.##", false, UnitGroup.MetricThousands) // + " \t| " + l.FormatAuto("0.##", false, UnitGroup.Common) // + " \t| " + l.FormatAuto("0.##", false, UnitGroup.Imperial); // str.AppendLine(line); // Console.WriteLine(line); // l *= 10; //} //System.IO.File.WriteAllText("TestOutput.txt", str.ToString()); //for (; ; ) //{ // Length length; // if (Unit<Length>.TryParse(Console.ReadLine(), out length)) // Console.WriteLine(length.FormatAuto("0.###", true, UnitGroup.Metric)); // else // Console.WriteLine("Invalid"); //} Console.Read(); }
public void CopyByMask(Entity from) { LastBitmask = from.LastBitmask; BitArray bitArray = new BitArray(LastBitmask); if (bitArray.Get(0)) { Position = from.Position.Clone(); } if (bitArray.Get(1)) { Rotation = from.Rotation.Clone(); } if (bitArray.Get(2)) { Velocity = from.Velocity.Clone(); } if (bitArray.Get(3)) { Acceleration = from.Acceleration.Clone(); } if (bitArray.Get(4)) { ExtraVelocity = from.ExtraVelocity.Clone(); } if (bitArray.Get(5)) { LookPitch = from.LookPitch; } if (bitArray.Get(6)) { PhysicsFlags = from.PhysicsFlags; } if (bitArray.Get(7)) { SpeedFlags = from.SpeedFlags; } if (bitArray.Get(8)) { EntityType = from.EntityType; } if (bitArray.Get(9)) { CurrentMode = from.CurrentMode; } if (bitArray.Get(10)) { LastShootTime = from.LastShootTime; } if (bitArray.Get(11)) { HitCounter = from.HitCounter; } if (bitArray.Get(12)) { LastHitTime = from.LastHitTime; } if (bitArray.Get(13)) { Appearance.CopyFrom(from.Appearance); } if (bitArray.Get(14)) { Flags1 = from.Flags1; Flags2 = from.Flags2; } if (bitArray.Get(15)) { RollTime = from.RollTime; } if (bitArray.Get(16)) { StunTime = from.StunTime; } if (bitArray.Get(17)) { SlowedTime = from.SlowedTime; } if (bitArray.Get(18)) { MakeBlueTime = from.MakeBlueTime; } if (bitArray.Get(19)) { SpeedUpTime = from.SpeedUpTime; } if (bitArray.Get(20)) { ShowPatchTime = from.ShowPatchTime; } if (bitArray.Get(21)) { ClassType = from.ClassType; } if (bitArray.Get(22)) { Specialization = from.Specialization; } if (bitArray.Get(23)) { ChargedMp = from.ChargedMp; } if (bitArray.Get(24)) { notUsed1 = from.notUsed1; notUsed2 = from.notUsed2; notUsed3 = from.notUsed3; } if (bitArray.Get(25)) { notUsed4 = from.notUsed4; notUsed5 = from.notUsed5; notUsed6 = from.notUsed6; } if (bitArray.Get(26)) { RayHit = from.RayHit.Clone(); } if (bitArray.Get(27)) { HP = from.HP; } if (bitArray.Get(28)) { MP = from.MP; } if (bitArray.Get(29)) { BlockPower = from.BlockPower; } if (bitArray.Get(30)) { MaxHpMultiplier = from.MaxHpMultiplier; ShootSpeed = from.ShootSpeed; DamageMultiplier = from.DamageMultiplier; ArmorMultiplier = from.ArmorMultiplier; ResistanceMultiplier = from.ResistanceMultiplier; } if (bitArray.Get(31)) { notUsed7 = from.notUsed7; } if (bitArray.Get(32)) { notUsed8 = from.notUsed8; } if (bitArray.Get(33)) { Level = from.Level; } if (bitArray.Get(34)) { CurrentXp = from.CurrentXp; } if (bitArray.Get(35)) { ParentOwner = from.ParentOwner; } if (bitArray.Get(36)) { unknownOrNotUsed1 = from.unknownOrNotUsed1; unknownOrNotUsed2 = from.unknownOrNotUsed2; } if (bitArray.Get(37)) { unknownOrNotUsed3 = from.unknownOrNotUsed3; } if (bitArray.Get(38)) { unknownOrNotUsed4 = from.unknownOrNotUsed4; } if (bitArray.Get(39)) { unknownOrNotUsed5 = from.unknownOrNotUsed5; notUsed11 = from.notUsed11; notUsed12 = from.notUsed12; } if (bitArray.Get(40)) { notUsed13 = from.notUsed13; notUsed14 = from.notUsed14; notUsed15 = from.notUsed15; notUsed16 = from.notUsed16; notUsed17 = from.notUsed17; notUsed18 = from.notUsed18; } if (bitArray.Get(41)) { notUsed20 = from.notUsed20; notUsed21 = from.notUsed21; notUsed22 = from.notUsed22; } if (bitArray.Get(42)) { notUsed19 = from.notUsed19; } if (bitArray.Get(43)) { ItemData.CopyFrom(from.ItemData); } if (bitArray.Get(44)) { for (int i = 0; i < 13; i++) { Item item = new Item(); item.CopyFrom(from.Equipment[i]); Equipment[i] = item; } } if (bitArray.Get(45)) { Name = from.Name; } if (bitArray.Get(46)) { Skills = new uint[11]; for (int i = 0; i < 11; i++) { Skills[i] = from.Skills[i]; } } if (bitArray.Get(47)) { IceBlockFour = from.IceBlockFour; } }
public void ReadByMask(BinaryReader reader) { List <Action> maskActions = new List <Action> { () => Position = new QVector3(reader.ReadInt64(), reader.ReadInt64(), reader.ReadInt64()), () => Rotation = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()), () => Velocity = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()), () => Acceleration = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()), () => ExtraVelocity = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()), () => LookPitch = reader.ReadSingle(), () => PhysicsFlags = reader.ReadUInt32(), () => SpeedFlags = reader.ReadByte(), () => EntityType = reader.ReadUInt32(), () => CurrentMode = reader.ReadByte(), () => LastShootTime = reader.ReadUInt32(), () => HitCounter = reader.ReadUInt32(), () => LastHitTime = reader.ReadUInt32(), () => Appearance.Read(reader), () => { Flags1 = reader.ReadByte(); // Not sure how necessary this is. if (Client != null && Client.Pvp) { if (Flags1 == 0x40) // Non-hostile { Flags1 = 0x20; } } else if (Client != null && !Client.Pvp) { if (Flags1 == 0x20) // Hostile { Flags1 = 0x40; } } Flags2 = reader.ReadByte(); }, () => RollTime = reader.ReadUInt32(), () => StunTime = reader.ReadInt32(), () => SlowedTime = reader.ReadUInt32(), () => MakeBlueTime = reader.ReadUInt32(), () => SpeedUpTime = reader.ReadUInt32(), () => ShowPatchTime = reader.ReadSingle(), () => ClassType = reader.ReadByte(), () => Specialization = reader.ReadByte(), () => ChargedMp = reader.ReadSingle(), () => { notUsed1 = reader.ReadUInt32(); notUsed2 = reader.ReadUInt32(); notUsed3 = reader.ReadUInt32(); }, () => { notUsed4 = reader.ReadUInt32(); notUsed5 = reader.ReadUInt32(); notUsed6 = reader.ReadUInt32(); }, () => RayHit = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()), () => HP = reader.ReadSingle(), () => MP = reader.ReadSingle(), () => BlockPower = reader.ReadSingle(), () => { MaxHpMultiplier = reader.ReadSingle(); ShootSpeed = reader.ReadSingle(); DamageMultiplier = reader.ReadSingle(); ArmorMultiplier = reader.ReadSingle(); ResistanceMultiplier = reader.ReadSingle(); }, () => notUsed7 = reader.ReadByte(), () => notUsed8 = reader.ReadByte(), () => Level = reader.ReadUInt32(), () => CurrentXp = reader.ReadUInt32(), () => ParentOwner = reader.ReadUInt64(), () => { unknownOrNotUsed1 = reader.ReadUInt32(); unknownOrNotUsed2 = reader.ReadUInt32(); }, () => unknownOrNotUsed3 = reader.ReadByte(), () => unknownOrNotUsed4 = reader.ReadUInt32(), () => { unknownOrNotUsed5 = reader.ReadUInt32(); notUsed11 = reader.ReadUInt32(); notUsed12 = reader.ReadUInt32(); }, () => { notUsed13 = reader.ReadUInt32(); notUsed14 = reader.ReadUInt32(); notUsed15 = reader.ReadUInt32(); notUsed16 = reader.ReadUInt32(); notUsed17 = reader.ReadUInt32(); notUsed18 = reader.ReadUInt32(); }, () => { notUsed20 = reader.ReadUInt32(); notUsed21 = reader.ReadUInt32(); notUsed22 = reader.ReadUInt32(); }, () => notUsed19 = reader.ReadByte(), () => ItemData.Read(reader), () => { for (int i = 0; i < EquipmentCount; ++i) { Item item = new Item(); item.Read(reader); Equipment[i] = item; } }, () => Name = Encoding.ASCII.GetString(reader.ReadBytes(16)).TrimEnd(' ', '\0'), () => { Skills = new uint[SkillCount]; for (int i = 0; i < SkillCount; ++i) { Skills[i] = reader.ReadUInt32(); } }, () => IceBlockFour = reader.ReadUInt32() }; LastBitmask = reader.ReadBytes(8); BitArray bitArray = new BitArray(LastBitmask); for (int i = 0; i < maskActions.Count; ++i) { if (!bitArray.Get(i)) { continue; } maskActions[i](); } }