Fixed circle rendering and added 2D circle collider

This commit is contained in:
Simon Lübeß
2022-11-26 12:17:31 +01:00
parent 0155a38ae6
commit 8f22cbb8bc
7 changed files with 240 additions and 17 deletions
@@ -88,6 +88,7 @@ namespace GlitchyEngine.World
Serialize.Value(writer, "Color", component.Color);
Serialize.Value(writer, "UvTransform", component.UvTransform);
Serialize.Value(writer, "IsCircle", component.IsCircle);
});
SerializeComponent<TransformComponent>(writer, entity, "TransformComponent", scope (component) =>
@@ -156,6 +157,17 @@ namespace GlitchyEngine.World
Serialize.Value(writer, "Restitution", component.Restitution);
Serialize.Value(writer, "RestitutionThreshold", component.RestitutionThreshold);
});
SerializeComponent<CircleCollider2DComponent>(writer, entity, "CircleCollider2D", scope (component) =>
{
Serialize.Value(writer, "Offset", component.Offset);
Serialize.Value(writer, "Radius", component.Radius);
Serialize.Value(writer, "Density", component.Density);
Serialize.Value(writer, "Friction", component.Friction);
Serialize.Value(writer, "Restitution", component.Restitution);
Serialize.Value(writer, "RestitutionThreshold", component.RestitutionThreshold);
});
}
writer.EntryEnd();
@@ -297,6 +309,8 @@ namespace GlitchyEngine.World
Try!(Deserialize.Value(reader, "Color", out component.Color));
reader.EntryEnd();
Try!(Deserialize.Value(reader, "UvTransform", out component.UvTransform));
reader.EntryEnd();
Try!(Deserialize.Value(reader, "IsCircle", out component.IsCircle));
return .Ok;
}));
@@ -419,6 +433,24 @@ namespace GlitchyEngine.World
reader.EntryEnd();
Deserialize.Value(reader, "RestitutionThreshold", out component.RestitutionThreshold);
return .Ok;
}));
case "CircleCollider2D":
Try!(DeserializeComponent<CircleCollider2DComponent>(reader, entity, scope (component) =>
{
Deserialize.Value(reader, "Offset", out component.Offset);
reader.EntryEnd();
Deserialize.Value(reader, "Radius", out component.Radius);
reader.EntryEnd();
Deserialize.Value(reader, "Density", out component.Density);
reader.EntryEnd();
Deserialize.Value(reader, "Friction", out component.Friction);
reader.EntryEnd();
Deserialize.Value(reader, "Restitution", out component.Restitution);
reader.EntryEnd();
Deserialize.Value(reader, "RestitutionThreshold", out component.RestitutionThreshold);
return .Ok;
}));