Skip to content

Commit 59bb60e

Browse files
committed
Updated AdvancedMath and added Ship.cs for CCSharp
1 parent 44d8cf0 commit 59bb60e

File tree

3 files changed

+265
-1
lines changed

3 files changed

+265
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ quaternion.lua
2323
matrix.txt
2424
quaternion.txt
2525
pid.lua
26+
mmath.lua
2627

2728
docs/

CCSharp/src/CCSharp/CCVS/Ship.cs

Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
using CCSharp.Attributes;
2+
using CCSharp.ComputerCraft;
3+
using CCSharp.AdvancedMath;
4+
5+
namespace CCSharp.CCVS;
6+
7+
public class Ship
8+
{
9+
public Long Id {
10+
[LuaMethod("ship.getId")] get;
11+
}
12+
13+
public string Slug {
14+
[LuaMethod("ship.getSlug")] get;
15+
[LuaMethod("ship.setSlug")] set;
16+
}
17+
18+
public double Mass {
19+
[LuaMethod("ship.getMass")] get;
20+
}
21+
22+
public bool Static {
23+
[LuaMethod("ship.isStatic")] get;
24+
[LuaMethod("ship.setStatic")] set;
25+
}
26+
27+
public Dictionary<Long, Constraint> Constraints {
28+
[LuaMethod("ship.getConstraints")] get;
29+
}
30+
31+
public Vector3 ShipyardPosition {
32+
[LuaMethod("ship.getShipyardPosition")] get;
33+
}
34+
35+
public Vector3 WorldspacePosition {
36+
[LuaMethod("ship.getWorldspacePosition")] get;
37+
}
38+
39+
public Vector3 LinearVelocity {
40+
[LuaMethod("ship.getVelocity")] get;
41+
}
42+
43+
public Vector3 AngularVelocity {
44+
[LuaMethod("ship.getOmega")] get;
45+
}
46+
47+
public Vector3 Scale {
48+
[LuaMethod("ship.getScale")] get;
49+
}
50+
51+
public Quaternion Quaternion {
52+
[LuaMethod("ship.getQuaternion")] get;
53+
}
54+
55+
public Matrix TransformationMatrix {
56+
[LuaMethod("ship.getTransformationMatrix")] get;
57+
}
58+
59+
public Matrix MomentOfInertiaTensorToSave {
60+
[LuaMethod("ship.getMomentOfInertiaTensorToSave")] get;
61+
}
62+
63+
public Matrix MomentOfInertiaTensor {
64+
[LuaMethod("ship.getMomentOfInertiaTensor")] get;
65+
}
66+
67+
[LuaMethod("ship.transformPositionToWorld")]
68+
public static Vector3 transformPositionToWorld(Vector3 pos) => default;
69+
70+
[LuaMethod("ship.pullPhysicsTicks")]
71+
public static (string name, PhysicsTick[] ticks) PullPhysicsTicks() => default;
72+
73+
[LuaTableTypeCheck(TableAccessor = "getBuoyantFactor"), LuaTableTypeCheck(TableAccessor = "isStatic"), LuaTableTypeCheck(TableAccessor = "doFluidDrag"), LuaTableTypeCheck(TableAccessor = "getInertia"), LuaTableTypeCheck(TableAccessor = "getPoseVel"), LuaTableTypeCheck(TableAccessor = "getForceInducers")]
74+
class PhysicsTick
75+
{
76+
public double BuoyantFactor {
77+
[LuaMethod("getBuoyantFactor")] get;
78+
}
79+
80+
public bool Static {
81+
[LuaMethod("isStatic")] get;
82+
}
83+
84+
public bool FluidDrag {
85+
[LuaMethod("doFluidDrag")] get;
86+
}
87+
88+
public Inertia Inertia {
89+
[LuaMethod("getInertia")] get;
90+
}
91+
92+
public PoseVel PoseVel {
93+
[LuaMethod("getPoseVel")] get;
94+
}
95+
96+
public string[] ForceInducers {
97+
[LuaMethod("getForceInducers")] get;
98+
}
99+
100+
[LuaTableTypeCheck(TableAccessor = "momentOfInertiaTensor"), LuaTableTypeCheck(TableAccessor = "mass")]
101+
class Inertia
102+
{
103+
[LuaProperty("momentOfInertiaTensor")] public Matrix MomentOfInertiaTensor { get; set; }
104+
[LuaProperty("mass")] public double Mass { get; set; }
105+
}
106+
107+
[LuaTableTypeCheck(TableAccessor = "vel"), LuaTableTypeCheck(TableAccessor = "omega"), LuaTableTypeCheck(TableAccessor = "pos"), LuaTableTypeCheck(TableAccessor = "rot")]
108+
class PoseVel
109+
{
110+
[LuaProperty("vel")] public Vector3 LinearVelocity { get; set; }
111+
[LuaProperty("omega")] public Vector3 AngularVelocity { get; set; }
112+
[LuaProperty("pos")] public Vector3 CenterOfMass { get; set; }
113+
[LuaProperty("rot")] public Quaternion Rotation { get; set; }
114+
}
115+
116+
}
117+
118+
[LuaMethod("ship.setScale")]
119+
public static void SetScale(double scale) => default;
120+
121+
[LuaMethod("ship.teleport")]
122+
public static void Teleport(object data) => default;
123+
124+
[LuaMethod("ship.applyInvariantForce")]
125+
public static void ApplyInvariantForce(Vector3 force) => default;
126+
[LuaMethod("ship.applyInvariantForce")]
127+
public static void ApplyInvariantForce(double forceX, double forceY, double forceZ) => default;
128+
129+
[LuaMethod("ship.applyInvariantTorque")]
130+
public static void ApplyInvariantTorque(Vector3 torque) => default;
131+
[LuaMethod("ship.applyInvariantTorque")]
132+
public static void ApplyInvariantTorque(double torqueX, double torqueY, double torqueZ) => default;
133+
134+
[LuaMethod("ship.applyInvariantForceToPos")]
135+
public static void ApplyInvariantForceToPosition(Vector3 force, Vector3 pos) => default;
136+
[LuaMethod("ship.applyInvariantForceToPos")]
137+
public static void ApplyInvariantForceToPosition(double forceX, double forceY, double forceZ, double posX, double posY, double posZ) => default;
138+
139+
[LuaMethod("ship.applyRotDependentForce")]
140+
public static void ApplyRotDependentForce(Vector3 force) => default;
141+
[LuaMethod("ship.applyRotDependentForce")]
142+
public static void ApplyRotDependentForce(double forceX, double forceY, double forceZ) => default;
143+
144+
[LuaMethod("ship.applyRotDependentTorque")]
145+
public static void ApplyRotDependentTorque(Vector3 torque) => default;
146+
[LuaMethod("ship.applyRotDependentTorque")]
147+
public static void ApplyRotDependentTorque(double torqueX, double torqueY, double torqueZ) => default;
148+
149+
[LuaMethod("ship.applyRotDependentForceToPos")]
150+
public static void ApplyRotDependentForceToPosition(Vector3 force, Vector3 pos) => default;
151+
[LuaMethod("ship.applyRotDependentForceToPos")]
152+
public static void ApplyRotDependentForceToPosition(double forceX, double forceY, double forceZ, double posX, double posY, double posZ) => default;
153+
154+
[LuaTableTypeCheck(TableAccessor = "shipId0"), LuaTableTypeCheck(TableAccessor = "shipId1"), LuaTableTypeCheck(TableAccessor = "type"), LuaTableTypeCheck(TableAccessor = "compliance")]
155+
class Constraint
156+
{
157+
[LuaEnum(typeof(ConstraintType))]
158+
public enum ConstraintType
159+
{
160+
[LuaEnumValue("attachment")] Attachment,
161+
[LuaEnumValue("fixed_attachment_orientation")] FixedAttachmentOrientation,
162+
[LuaEnumValue("fixed_orientation")] FixedOrientation,
163+
[LuaEnumValue("hinge_orientation")] HingeOrientation,
164+
[LuaEnumValue("hinge_swing_limits")] HingeSwingLimits,
165+
[LuaEnumValue("hinge_target_angle")] HingeTargetAngle,
166+
[LuaEnumValue("pos_damping")] PosDamping,
167+
[LuaEnumValue("rope")] Rope,
168+
[LuaEnumValue("rot_damping")] RotDamping,
169+
[LuaEnumValue("Slide")] Slide,
170+
[LuaEnumValue("spherical_swing_limits")] SphericalSwingLimits,
171+
[LuaEnumValue("spherical_twist_limits")] SphericalTwistLimits
172+
}
173+
174+
[LuaProperty("shipId0")] public Long FirstShipID { get; set; }
175+
[LuaProperty("shipId1")] public Long SecondShipID { get; set; }
176+
[LuaProperty("type")] public ConstraintType Type { get; set; }
177+
[LuaProperty("compliance")] public double Compliance { get; set; }
178+
}
179+
180+
[LuaTableTypeCheck(TableAccessor = "localPos0"), LuaTableTypeCheck(TableAccessor = "localPos1"), LuaTableTypeCheck(TableAccessor = "maxForce")]
181+
interface IForce
182+
{
183+
[LuaProperty("localPos0")] public Vector3 FirstPosition { get; set; }
184+
[LuaProperty("localPos1")] public Vector3 SecondPosition { get; set; }
185+
[LuaProperty("maxForce")] public double MaxForce { get; set; }
186+
}
187+
188+
[LuaTableTypeCheck(TableAccessor = "localPos0"), LuaTableTypeCheck(TableAccessor = "localPos1"), LuaTableTypeCheck(TableAccessor = "maxForce")]
189+
interface ITorque
190+
{
191+
[LuaProperty("localRot0")] public Quaternion FirstPosition { get; set; }
192+
[LuaProperty("localRot1")] public Quaternion SecondPosition { get; set; }
193+
[LuaProperty("maxTorque")] public double MaxTorque { get; set; }
194+
}
195+
196+
[LuaTableTypeCheck(TableAccessor = "fixedDistance")]
197+
class AttachmentConstraint : Constraint, IForce
198+
{
199+
[LuaProperty("fixedDistance")] public double FixedDistance { get; set; }
200+
}
201+
202+
[LuaTableTypeCheck(TableAccessor = "minSwingAngle"), LuaTableTypeCheck(TableAccessor = "maxSwingAngle")]
203+
class HingeSwingLimitsConstraint : Constraint, ITorque
204+
{
205+
[LuaProperty("minSwingAngle")] public double MinSwingAngle { get; set; }
206+
[LuaProperty("maxSwingAngle")] public double MaxSwingAngle { get; set; }
207+
}
208+
209+
[LuaTableTypeCheck(TableAccessor = "targetAngle"), LuaTableTypeCheck(TableAccessor = "nextTickTargetAngle")]
210+
class HingeTargetAngleConstraint : Constraint, ITorque
211+
{
212+
[LuaProperty("targetAngle")] public double TargetAngle { get; set; }
213+
[LuaProperty("nextTickTargetAngle")] public double NextTickTargetAngle { get; set; }
214+
}
215+
216+
[LuaTableTypeCheck(TableAccessor = "posDamping")]
217+
class PosDampingConstraint : Constraint, IForce
218+
{
219+
[LuaProperty("posDamping")] public double PosDamping { get; set; }
220+
}
221+
222+
[LuaTableTypeCheck(TableAccessor = "ropeLength")]
223+
class RopeConstraint : Constraint, IForce
224+
{
225+
[LuaProperty("ropeLength")] public double RopeLength { get; set; }
226+
}
227+
228+
[LuaTableTypeCheck(TableAccessor = "rotDamping"), LuaTableTypeCheck(TableAccessor = "rotDampingAxes")]
229+
class RotDampingConstraint : Constraint, IForce
230+
{
231+
[LuaEnum(typeof(RotDampingAxes))]
232+
public enum RotDampingAxes
233+
{
234+
[LuaEnumValue("parallel")] Parallel,
235+
[LuaEnumValue("perpendicular")] Perpendicular,
236+
[LuaEnumValue("all_axes")] AllAxes
237+
}
238+
239+
[LuaProperty("rotDamping")] public double RotDamping { get; set; }
240+
[LuaProperty("rotDampingAxes")] public RotDampingAxes RotDampingAxis { get; set; }
241+
}
242+
243+
[LuaTableTypeCheck(TableAccessor = "localSlideAxis0"), LuaTableTypeCheck(TableAccessor = "maxDistBetweenPoints")]
244+
class RotDampingConstraint : Constraint, IForce
245+
{
246+
[LuaProperty("localSlideAxis0")] public Vector3 LocalSlideAxis { get; set; }
247+
[LuaProperty("maxDistBetweenPoints")] public double MaxDistanceBetweenPoints { get; set; }
248+
}
249+
250+
[LuaTableTypeCheck(TableAccessor = "minSwingAngle"), LuaTableTypeCheck(TableAccessor = "maxSwingAngle")]
251+
class SphericalSwingLimitsConstraint : Constraint, ITorque
252+
{
253+
[LuaProperty("minSwingAngle")] public double MinSwingAngle { get; set; }
254+
[LuaProperty("maxSwingAngle")] public double MaxSwingAngle { get; set; }
255+
}
256+
257+
[LuaTableTypeCheck(TableAccessor = "minTwistAngle"), LuaTableTypeCheck(TableAccessor = "maxTwistAngle")]
258+
class SphericalTwistLimitsConstraint : Constraint, ITorque
259+
{
260+
[LuaProperty("minTwistAngle")] public double MinTwistAngle { get; set; }
261+
[LuaProperty("maxTwistAngle")] public double MaxTwistAngle { get; set; }
262+
}
263+
}

0 commit comments

Comments
 (0)