Skip to content

Commit

Permalink
Some extra overloads for API methods
Browse files Browse the repository at this point in the history
  • Loading branch information
andybak committed Oct 10, 2023
1 parent 5a7b0b3 commit f500784
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
19 changes: 18 additions & 1 deletion Assets/Scripts/API/Lua/Wrappers/Path2dApiWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,24 @@ public void TransformBy(TrTransform transform)
public void RotateBy(Quaternion amount) => TransformBy(TrTransform.R(amount));

[LuaDocsDescription("Scales the path")]
[LuaDocsExample("myPath:ScaleBy(Vector2:New(2, 1)")]
[LuaDocsExample("myPath:ScaleBy(2)")]
[LuaDocsParameter("scale", "The scaling factor to apply to the path")]
public void ScaleBy(float scale)
{
ScaleBy(new Vector2(scale, scale));
}

[LuaDocsDescription("Scales the path")]
[LuaDocsExample("myPath:ScaleBy(2, 1)")]
[LuaDocsParameter("x", "The x scaling factor to apply to the path")]
[LuaDocsParameter("y", "The y scaling factor to apply to the path")]
public void ScaleBy(float x, float y)
{
ScaleBy(new Vector2(x, y));
}

[LuaDocsDescription("Scales the path")]
[LuaDocsExample("myPath:ScaleBy(myVector2")]
[LuaDocsParameter("scale", "The scaling factor to apply to the path")]
public void ScaleBy(Vector2 scale)
{
Expand Down
18 changes: 16 additions & 2 deletions Assets/Scripts/API/Lua/Wrappers/TransformApiWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,29 @@ public TransformApiWrapper(Vector3 translation, float scale = 1)
public TrTransform TransformBy(TrTransform transform) => _TrTransform * transform;

[LuaDocsDescription("Applies a translation to this transform")]
[LuaDocsExample("newTransform = myTransform:TranslateBy(Vector3(1, 2, 3))")]
[LuaDocsExample("newTransform = myTransform:TranslateBy(Vector3.up * 3)")]
[LuaDocsParameter("translation", "The translation to apply")]
public TrTransform TranslateBy(Vector3 translation) => _TrTransform * TrTransform.T(translation);

[LuaDocsDescription("Applies a translation to this transform")]
[LuaDocsExample("newTransform = myTransform:TranslateBy(1, 2, 3)")]
[LuaDocsParameter("x", "The x translation to apply")]
[LuaDocsParameter("y", "The y translation to apply")]
[LuaDocsParameter("z", "The z translation to apply")]
public TrTransform TranslateBy(float x, float y, float z) => TranslateBy(new Vector3(x, y, z));

[LuaDocsDescription("Applies a rotation to this transform")]
[LuaDocsExample("newTransform = myTransform:RotateBy(Rotation.New(0, 45, 0))")]
[LuaDocsExample("newTransform = myTransform:RotateBy(Rotation.left)")]
[LuaDocsParameter("rotation", "The rotation to apply")]
public TrTransform RotateBy(Quaternion rotation) => _TrTransform * TrTransform.R(rotation);

[LuaDocsDescription("Applies a rotation to this transform")]
[LuaDocsExample("newTransform = myTransform:RotateBy(45, 0, 0)")]
[LuaDocsParameter("x", "The x rotation to apply")]
[LuaDocsParameter("y", "The y rotation to apply")]
[LuaDocsParameter("z", "The z rotation to apply")]
public TrTransform RotateBy(float x, float y, float z) => RotateBy(Quaternion.Euler(x, y, z));

[LuaDocsDescription("Applies a scale to this transform")]
[LuaDocsExample("newTransform = myTransform:ScaleBy(2)")]
[LuaDocsParameter("scale", "The scale value to apply")]
Expand Down

0 comments on commit f500784

Please sign in to comment.