diff --git a/OgtDgLib.Ext/src/SyncedGun.cs b/OgtDgLib.Ext/src/SyncedGun.cs index 5a753b7..98a0aa5 100644 --- a/OgtDgLib.Ext/src/SyncedGun.cs +++ b/OgtDgLib.Ext/src/SyncedGun.cs @@ -10,8 +10,8 @@ public abstract class SyncedGun:TypedGun [UsedImplicitly] public BitBuffer AmmoTypeSerialized { - get => BaseAmmoType.SerializeAt(ammoType).Serialize(); - set => BaseAmmoType.DeserializeAt(BinaryClassChunk.FromData(value), ammoType); + get => BaseAmmoType.SerializeAt(ammoType); + set => BaseAmmoType.DeserializeAt(value, ammoType); } [UsedImplicitly] public StateBinding AtsBinding = new StateBinding(nameof(AmmoTypeSerialized)); diff --git a/OgtDgLib/src/AmmoTypes/BaseAmmoType.cs b/OgtDgLib/src/AmmoTypes/BaseAmmoType.cs index 5d6d6d5..cd490b3 100644 --- a/OgtDgLib/src/AmmoTypes/BaseAmmoType.cs +++ b/OgtDgLib/src/AmmoTypes/BaseAmmoType.cs @@ -25,50 +25,49 @@ protected string GetPath(string asset) [PublicAPI] public abstract class BaseAmmoType: AmmoType { - public static BinaryClassChunk SerializeAt(AmmoType at) + public static BitBuffer SerializeAt(AmmoType at) { - var binaryClassChunk = new BinaryClassChunk(); - binaryClassChunk.AddProperty("bulletSpeed", at.bulletSpeed); - binaryClassChunk.AddProperty("speedVariation", at.speedVariation); - binaryClassChunk.AddProperty("bulletLength", at.bulletLength); - binaryClassChunk.AddProperty("bulletThickness", at.bulletThickness); - binaryClassChunk.AddProperty("deadly", at.deadly); - binaryClassChunk.AddProperty("impactPower", at.impactPower); - // binaryClassChunk.AddProperty("bulletType", at.bulletType); - binaryClassChunk.AddProperty("accuracy", at.accuracy); - binaryClassChunk.AddProperty("range", at.range); - binaryClassChunk.AddProperty("rangeVariation", at.rangeVariation); - binaryClassChunk.AddProperty("penetration", at.penetration); - binaryClassChunk.AddProperty("rebound", at.rebound); - binaryClassChunk.AddProperty("affectedByGravity", at.affectedByGravity); - binaryClassChunk.AddProperty("barrelAngleDegrees", at.barrelAngleDegrees); - binaryClassChunk.AddProperty("immediatelyDeadly", at.immediatelyDeadly); - binaryClassChunk.AddProperty("weight", at.weight); - binaryClassChunk.AddProperty("combustable", at.combustable); + var b = new BitBuffer(); + b.Write(at.bulletSpeed); + b.Write(at.speedVariation); + b.Write(at.bulletLength); + b.Write(at.bulletThickness); + b.Write(at.deadly); + b.Write(at.impactPower); + b.Write(at.accuracy); + b.Write(at.range); + b.Write(at.rangeVariation); + b.Write(at.penetration); + b.Write(at.rebound); + b.Write(at.affectedByGravity); + b.Write(at.barrelAngleDegrees); + b.Write(at.immediatelyDeadly); + b.Write(at.weight); + b.Write(at.combustable); + // TODO: bullettype // TODO: COLOR // binaryClassChunk.AddProperty("", ); - return binaryClassChunk; + return new BitBuffer(b.GetBytes());; } - public static bool DeserializeAt(BinaryClassChunk node, AmmoType at) + public static bool DeserializeAt(BitBuffer b, AmmoType at) { - at.bulletSpeed = node.GetProperty("bulletSpeed"); - at.speedVariation = node.GetProperty("speedVariation"); - at.bulletLength = node.GetProperty("bulletLength"); - at.bulletThickness = node.GetProperty("bulletThickness"); - at.deadly = node.GetProperty("deadly"); - at.impactPower = node.GetProperty("impactPower"); - // at.bulletType = node.GetProperty("bulletType"); - at.accuracy = node.GetProperty("accuracy"); - at.range = node.GetProperty("range"); - at.rangeVariation = node.GetProperty("rangeVariation"); - at.penetration = node.GetProperty("penetration"); - at.rebound = node.GetProperty("rebound"); - at.affectedByGravity = node.GetProperty("affectedByGravity"); - at.barrelAngleDegrees = node.GetProperty("barrelAngleDegrees"); - at.immediatelyDeadly = node.GetProperty("immediatelyDeadly"); - at.weight = node.GetProperty("weight"); - at.combustable = node.GetProperty("combustable"); + at.bulletSpeed = b.ReadFloat(); + at.speedVariation = b.ReadFloat(); + at.bulletLength = b.ReadFloat(); + at.bulletThickness = b.ReadFloat(); + at.deadly = b.ReadBool(); + at.impactPower = b.ReadFloat(); + at.accuracy = b.ReadFloat(); + at.range = b.ReadFloat(); + at.rangeVariation = b.ReadFloat(); + at.penetration = b.ReadFloat(); + at.rebound = b.ReadBool(); + at.affectedByGravity = b.ReadBool(); + at.barrelAngleDegrees = b.ReadFloat(); + at.immediatelyDeadly = b.ReadBool(); + at.weight = b.ReadFloat(); + at.combustable = b.ReadBool(); // TODO: COLOR // = node.GetProperty<>(""); return true;