From 76f0e0379840354ead03a92093b5fdc47e42958d Mon Sep 17 00:00:00 2001 From: Li Jin Date: Mon, 30 Dec 2024 00:54:45 +0800 Subject: [PATCH] Added more WA bindings. --- Source/Wasm/Dora/BodyDefWasm.hpp | 10 +- Tools/{RustWasmGen => WasmGen}/Dora.h | 14 +- Tools/{RustWasmGen => WasmGen}/LICENSE-lulpeg | 0 Tools/{RustWasmGen => WasmGen}/gen.yue | 55 ++++++- Tools/{RustWasmGen => WasmGen}/lulpeg.lua | 0 Tools/dora-rust/dora/src/dora.rs | 25 +-- Tools/dora-rust/dora/src/dora/body_def.rs | 22 ++- Tools/dora-wa/vendor/dora/action.wa | 2 +- Tools/dora-wa/vendor/dora/array.wa | 2 +- Tools/dora-wa/vendor/dora/body.wa | 119 +++++++++++++- Tools/dora-wa/vendor/dora/body_def.wa | 148 +++++++++++++++++- Tools/dora-wa/vendor/dora/buffer.wa | 31 +++- Tools/dora-wa/vendor/dora/c_45.wa | 15 +- Tools/dora-wa/vendor/dora/cache.wa | 33 +++- Tools/dora-wa/vendor/dora/camera.wa | 2 +- Tools/dora-wa/vendor/dora/dictionary.wa | 2 +- Tools/dora-wa/vendor/dora/dora.wa | 103 ++++++++---- Tools/dora-wa/vendor/dora/effect.wa | 2 +- Tools/dora-wa/vendor/dora/fixture_def.wa | 16 +- Tools/dora-wa/vendor/dora/grabber.wa | 2 +- Tools/dora-wa/vendor/dora/node.wa | 2 +- Tools/dora-wa/vendor/dora/pass.wa | 2 +- Tools/dora-wa/vendor/dora/physics_world.wa | 58 ++++++- Tools/dora-wa/vendor/dora/scheduler.wa | 2 +- Tools/dora-wa/vendor/dora/sensor.wa | 37 ++++- Tools/dora-wa/vendor/dora/sprite.wa | 2 +- Tools/dora-wa/vendor/dora/sprite_effect.wa | 2 +- Tools/dora-wa/vendor/dora/texture_2d.wa | 2 +- 28 files changed, 615 insertions(+), 95 deletions(-) rename Tools/{RustWasmGen => WasmGen}/Dora.h (99%) rename Tools/{RustWasmGen => WasmGen}/LICENSE-lulpeg (100%) rename Tools/{RustWasmGen => WasmGen}/gen.yue (97%) rename Tools/{RustWasmGen => WasmGen}/lulpeg.lua (100%) diff --git a/Source/Wasm/Dora/BodyDefWasm.hpp b/Source/Wasm/Dora/BodyDefWasm.hpp index 7da1470f2..211253a49 100644 --- a/Source/Wasm/Dora/BodyDefWasm.hpp +++ b/Source/Wasm/Dora/BodyDefWasm.hpp @@ -11,10 +11,10 @@ using namespace Dora; int32_t bodydef_type() { return DoraType(); } -void bodydef__set_type(int64_t self, int32_t val) { - BodyDef_SetTypeEnum(r_cast(self), s_cast(val)); +void bodydef_set_type(int64_t self, int32_t body_type) { + BodyDef_SetTypeEnum(r_cast(self), body_type); } -int32_t bodydef__get_type(int64_t self) { +int32_t bodydef_get_type(int64_t self) { return BodyDef_GetTypeEnum(r_cast(self)); } void bodydef_set_position(int64_t self, int64_t val) { @@ -135,8 +135,8 @@ int64_t bodydef_new() { static void linkBodyDef(wasm3::module3& mod) { mod.link_optional("*", "bodydef_type", bodydef_type); - mod.link_optional("*", "bodydef__set_type", bodydef__set_type); - mod.link_optional("*", "bodydef__get_type", bodydef__get_type); + mod.link_optional("*", "bodydef_set_type", bodydef_set_type); + mod.link_optional("*", "bodydef_get_type", bodydef_get_type); mod.link_optional("*", "bodydef_set_position", bodydef_set_position); mod.link_optional("*", "bodydef_get_position", bodydef_get_position); mod.link_optional("*", "bodydef_set_angle", bodydef_set_angle); diff --git a/Tools/RustWasmGen/Dora.h b/Tools/WasmGen/Dora.h similarity index 99% rename from Tools/RustWasmGen/Dora.h rename to Tools/WasmGen/Dora.h index baff71cdd..aa29ba746 100644 --- a/Tools/RustWasmGen/Dora.h +++ b/Tools/WasmGen/Dora.h @@ -2576,8 +2576,18 @@ object class FixtureDef { }; /// A struct to describe the properties of a physics body. object class BodyDef { - outside void BodyDef_SetTypeEnum @ _set_type(int val); - outside int32_t BodyDef_GetTypeEnum @ _get_type() const; + /// Sets the define for the type of the body. + /// + /// # Arguments + /// + /// * `body_type` - The type of the body. + outside void BodyDef_SetTypeEnum @ set_type(BodyType body_type); + /// Gets the define for the type of the body. + /// + /// # Returns + /// + /// * `BodyType` - The type of the body. + outside BodyType BodyDef_GetTypeEnum @ get_type() const; /// define for the position of the body. Vec2 offset @ position; /// define for the angle of the body. diff --git a/Tools/RustWasmGen/LICENSE-lulpeg b/Tools/WasmGen/LICENSE-lulpeg similarity index 100% rename from Tools/RustWasmGen/LICENSE-lulpeg rename to Tools/WasmGen/LICENSE-lulpeg diff --git a/Tools/RustWasmGen/gen.yue b/Tools/WasmGen/gen.yue similarity index 97% rename from Tools/RustWasmGen/gen.yue rename to Tools/WasmGen/gen.yue index 4400a601d..cafdc7569 100755 --- a/Tools/RustWasmGen/gen.yue +++ b/Tools/WasmGen/gen.yue @@ -411,6 +411,10 @@ basicTypes = * --[[10: wa type]] { convertFrom: (name)-> name convertTo: (name)-> name + argType: "DBRecord" + returnType: "DBRecord" + creturn: (name, fnArgId)-> "#{name}, _ := DBRecordFrom(stack#{fnArgId}.PopI64())" + cpass: -> error "unsupported" } DBQuery: * "i64" @@ -425,6 +429,10 @@ basicTypes = * --[[10: wa type]] { convertFrom: (name)-> name convertTo: (name)-> name + argType: "DBQuery" + returnType: "DBQuery" + creturn: -> error "unsupported" + cpass: -> error "unsupported" } WorkBook: * "i64" @@ -657,6 +665,10 @@ basicTypes = * --[[10: wa type]] { convertFrom: (name)-> name convertTo: (name)-> name + argType: "i64" + returnType: "i64" + creturn: (name, fnArgId)-> "#{name}, _ := stack#{fnArgId}.PopI64()" + cpass: -> error "unsupported" } MLQAction: * "i32" @@ -671,6 +683,10 @@ basicTypes = * --[[10: wa type]] { convertFrom: (name)-> name convertTo: (name)-> name + argType: "i32" + returnType: "i32" + creturn: (name, fnArgId)-> "#{name}, _ := stack#{fnArgId}.PopI32()" + cpass: -> error "unsupported" } "Platformer::TargetAllow": * "i64" @@ -782,6 +798,22 @@ basicTypes = convertFrom: (name)-> name convertTo: (name)-> name } + BodyType: + * "i32" + * (name)-> name + * (name)-> name + * "crate::dora::BodyType" + * "crate::dora::BodyType" + * (name)-> "#{name} as i32" + * (name)-> "core::mem::transmute(#{name})" + * -> error "unsupported" + * -> error "unsupported" + * --[[10: wa type]] { + convertFrom: (name)-> "BodyType{value: #{name}}" + convertTo: (name)-> "#{name}.ToValue()" + argType: "BodyType" + returnType: "BodyType" + } "Platformer::Relation": * "i32" * (name)-> "s_cast(#{name})" @@ -807,8 +839,12 @@ basicTypes = * (fnArgId)-> "&crate::dora::platformer::behavior::Blackboard::from(stack#{fnArgId}.pop_i64().unwrap()).unwrap()" * -> error "unsupported" * --[[10: wa type]] { - convertFrom: (name)-> name - convertTo: (name)-> name + convertFrom: (name)-> "*BlackboardFrom(#{name})" + convertTo: (name)-> "#{name}.GetRaw()" + argType: "Blackboard" + returnType: "Blackboard" + creturn: (name, fnArgId)-> "#{name}, _ := stack#{fnArgId}.PopI64()" + cpass: -> error "unsupported" } "Platformer::UnitAction": * "i64" @@ -1077,7 +1113,7 @@ func #{clsNewName}From(raw: i64) => *#{clsNewName} { result := &object return result } -func #{clsNewName}.GetType() => i32 { +func #{clsNewName}.GetTypeId() => i32 { return #{namespace}#{clsNewNameL}_type() }" else @@ -1228,6 +1264,8 @@ func #{clsNewName}From(raw: i64) => *#{clsNewName} { waType = getWaType dataType, rustName waBinding[] = if isSingleton "func _#{clsNewName}.#{waSetterName}(val: #{waType.argType}) {\n\t#{cppSetterName}(#{waType.convertTo 'val'})\n}" + elseif isStatic + "func #{clsNewName}#{waSetterName}(val: #{waType.argType}) {\n\t#{cppSetterName}(#{waType.convertTo 'val'})\n}" else "func #{clsNewName}.#{waSetterName}(val: #{waType.argType}) {\n\t#{cppSetterName}(*this.raw, #{waType.convertTo 'val'})\n}" docText = if #docs > 0 @@ -1290,6 +1328,9 @@ func #{clsNewName}From(raw: i64) => *#{clsNewName} { waBinding[] = if isSingleton item = "#{cppGetterName}()" "func _#{clsNewName}.#{waGetterName}() => #{waReturnType} {\n#{waReturn item}\n}" + elseif isStatic + item = "#{cppGetterName}()" + "func #{clsNewName}#{waGetterName}() => #{waReturnType} {\n#{waReturn item}\n}" else item = "#{cppGetterName}(*this.raw)" "func #{clsNewName}.#{waGetterName}() => #{waReturnType} {\n#{waReturn item}\n}" @@ -1728,6 +1769,14 @@ func #{clsNewName}From(raw: i64) => *#{clsNewName} { "content" "work_book" "work_sheet" + "body_def" + "body" + "physics_world" + "sensor" + "fixture_def" + "buffer" + "c_45" + "cache" ] \write "\n" \write table.concat waBinding, "\n" diff --git a/Tools/RustWasmGen/lulpeg.lua b/Tools/WasmGen/lulpeg.lua similarity index 100% rename from Tools/RustWasmGen/lulpeg.lua rename to Tools/WasmGen/lulpeg.lua diff --git a/Tools/dora-rust/dora/src/dora.rs b/Tools/dora-rust/dora/src/dora.rs index e743fb485..c35f8b5b6 100644 --- a/Tools/dora-rust/dora/src/dora.rs +++ b/Tools/dora-rust/dora/src/dora.rs @@ -3280,6 +3280,7 @@ pub enum TextAlign { // BodyDef +#[repr(i32)] #[derive(Copy, Clone, Debug, PartialEq)] pub enum BodyType { Dynamic = 0, @@ -3287,30 +3288,6 @@ pub enum BodyType { Kinematic = 2, } -impl BodyDef { - /// Sets the define for the type of the body. - /// - /// # Arguments - /// - /// * `body_type` - The type of the body. - pub fn set_type(&mut self, body_type: BodyType) { - self._set_type(body_type as i32); - } - /// Gets the define for the type of the body. - /// - /// # Returns - /// - /// * `BodyType` - The type of the body. - pub fn get_type(&self) -> BodyType { - match self._get_type() { - 0 => BodyType::Dynamic, - 1 => BodyType::Static, - 2 => BodyType::Kinematic, - _ => panic!("Invalid body type.") - } - } -} - // Keyboard #[derive(Copy, Clone, Debug, PartialEq)] diff --git a/Tools/dora-rust/dora/src/dora/body_def.rs b/Tools/dora-rust/dora/src/dora/body_def.rs index fef96de83..1a1aa2a62 100644 --- a/Tools/dora-rust/dora/src/dora/body_def.rs +++ b/Tools/dora-rust/dora/src/dora/body_def.rs @@ -8,8 +8,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI extern "C" { fn bodydef_type() -> i32; - fn bodydef__set_type(slf: i64, val: i32); - fn bodydef__get_type(slf: i64) -> i32; + fn bodydef_set_type(slf: i64, body_type: i32); + fn bodydef_get_type(slf: i64) -> i32; fn bodydef_set_position(slf: i64, val: i64); fn bodydef_get_position(slf: i64) -> i64; fn bodydef_set_angle(slf: i64, val: f32); @@ -62,11 +62,21 @@ impl BodyDef { } }) } - pub(crate) fn _set_type(&mut self, val: i32) { - unsafe { bodydef__set_type(self.raw(), val); } + /// Sets the define for the type of the body. + /// + /// # Arguments + /// + /// * `body_type` - The type of the body. + pub fn set_type(&mut self, body_type: crate::dora::BodyType) { + unsafe { bodydef_set_type(self.raw(), body_type as i32); } } - pub(crate) fn _get_type(&self) -> i32 { - unsafe { return bodydef__get_type(self.raw()); } + /// Gets the define for the type of the body. + /// + /// # Returns + /// + /// * `BodyType` - The type of the body. + pub fn get_type(&self) -> crate::dora::BodyType { + unsafe { return core::mem::transmute(bodydef_get_type(self.raw())); } } /// Sets define for the position of the body. pub fn set_position(&mut self, val: &crate::dora::Vec2) { diff --git a/Tools/dora-wa/vendor/dora/action.wa b/Tools/dora-wa/vendor/dora/action.wa index 9f3ac8af6..98587b4ae 100644 --- a/Tools/dora-wa/vendor/dora/action.wa +++ b/Tools/dora-wa/vendor/dora/action.wa @@ -41,7 +41,7 @@ func ActionFrom(raw: i64) => *Action { result := &object return result } -func Action.GetType() => i32 { +func Action.GetTypeId() => i32 { return action_type() } func Action.GetDuration() => f32 { diff --git a/Tools/dora-wa/vendor/dora/array.wa b/Tools/dora-wa/vendor/dora/array.wa index 415e25c5c..59212ad61 100644 --- a/Tools/dora-wa/vendor/dora/array.wa +++ b/Tools/dora-wa/vendor/dora/array.wa @@ -41,7 +41,7 @@ func ArrayFrom(raw: i64) => *Array { result := &object return result } -func Array.GetType() => i32 { +func Array.GetTypeId() => i32 { return array_type() } func Array.GetCount() => i64 { diff --git a/Tools/dora-wa/vendor/dora/body.wa b/Tools/dora-wa/vendor/dora/body.wa index 6348c3527..667bde412 100644 --- a/Tools/dora-wa/vendor/dora/body.wa +++ b/Tools/dora-wa/vendor/dora/body.wa @@ -69,4 +69,121 @@ func body_attach_sensor(slf: i64, tag: i32, fixture_def: i64) => i64 #wa:import dora body_on_contact_filter func body_on_contact_filter(slf: i64, func0: i32, stack0: i64) #wa:import dora body_new -func body_new(def: i64, world: i64, pos: i64, rot: f32) => i64 \ No newline at end of file +func body_new(def: i64, world: i64, pos: i64, rot: f32) => i64 +type Body struct { Node } +func BodyFrom(raw: i64) => *Body { + if raw == 0 { + return nil + } + object := Body{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func Body.GetTypeId() => i32 { + return body_type() +} +func Body.GetWorld() => PhysicsWorld { + return *PhysicsWorldFrom(body_get_world(*this.raw)) +} +func Body.GetBodyDef() => BodyDef { + return *BodyDefFrom(body_get_body_def(*this.raw)) +} +func Body.GetMass() => f32 { + return body_get_mass(*this.raw) +} +func Body.IsSensor() => bool { + return body_is_sensor(*this.raw) != 0 +} +func Body.SetVelocityX(val: f32) { + body_set_velocity_x(*this.raw, val) +} +func Body.GetVelocityX() => f32 { + return body_get_velocity_x(*this.raw) +} +func Body.SetVelocityY(val: f32) { + body_set_velocity_y(*this.raw, val) +} +func Body.GetVelocityY() => f32 { + return body_get_velocity_y(*this.raw) +} +func Body.SetVelocity(val: Vec2) { + body_set_velocity(*this.raw, val.ToValue()) +} +func Body.GetVelocity() => Vec2 { + return Vec2FromValue(body_get_velocity(*this.raw)) +} +func Body.SetAngularRate(val: f32) { + body_set_angular_rate(*this.raw, val) +} +func Body.GetAngularRate() => f32 { + return body_get_angular_rate(*this.raw) +} +func Body.SetGroup(val: i32) { + body_set_group(*this.raw, val) +} +func Body.GetGroup() => i32 { + return body_get_group(*this.raw) +} +func Body.SetLinearDamping(val: f32) { + body_set_linear_damping(*this.raw, val) +} +func Body.GetLinearDamping() => f32 { + return body_get_linear_damping(*this.raw) +} +func Body.SetAngularDamping(val: f32) { + body_set_angular_damping(*this.raw, val) +} +func Body.GetAngularDamping() => f32 { + return body_get_angular_damping(*this.raw) +} +func Body.SetOwner(val: Object) { + body_set_owner(*this.raw, val.GetRaw()) +} +func Body.GetOwner() => Object { + return *ObjectFrom(body_get_owner(*this.raw)) +} +func Body.SetReceivingContact(val: bool) { + body_set_receiving_contact(*this.raw, ToDoraBool(val)) +} +func Body.IsReceivingContact() => bool { + return body_is_receiving_contact(*this.raw) != 0 +} +func Body.ApplyLinearImpulse(impulse: Vec2, pos: Vec2) { + body_apply_linear_impulse(*this.raw, impulse.ToValue(), pos.ToValue()) +} +func Body.ApplyAngularImpulse(impulse: f32) { + body_apply_angular_impulse(*this.raw, impulse) +} +func Body.GetSensorByTag(tag: i32) => Sensor { + return *SensorFrom(body_get_sensor_by_tag(*this.raw, tag)) +} +func Body.RemoveSensorByTag(tag: i32) => bool { + return body_remove_sensor_by_tag(*this.raw, tag) != 0 +} +func Body.RemoveSensor(sensor: Sensor) => bool { + return body_remove_sensor(*this.raw, sensor.GetRaw()) != 0 +} +func Body.Attach(fixture_def: FixtureDef) { + body_attach(*this.raw, fixture_def.GetRaw()) +} +func Body.AttachSensor(tag: i32, fixture_def: FixtureDef) => Sensor { + return *SensorFrom(body_attach_sensor(*this.raw, tag, fixture_def.GetRaw())) +} +func Body.OnContactFilter(filter: func(body: Body) => bool) { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + body := *BodyFrom(stack0.PopObject().GetRaw()) + result_ := filter(body) + stack0.Push(result_) + }) + body_on_contact_filter(*this.raw, func_id0, *stack0.raw) +} +func NewBody(def: BodyDef, world: PhysicsWorld, pos: Vec2, rot: f32) => Body { + object := Body{} + raw := body_new(def.GetRaw(), world.GetRaw(), pos.ToValue(), rot) + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/body_def.wa b/Tools/dora-wa/vendor/dora/body_def.wa index 4a13a10ad..b86c7fb39 100644 --- a/Tools/dora-wa/vendor/dora/body_def.wa +++ b/Tools/dora-wa/vendor/dora/body_def.wa @@ -8,10 +8,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #wa:import dora bodydef_type func bodydef_type() => i32 -#wa:import dora bodydef__set_type -func bodydef__set_type(slf: i64, val: i32) -#wa:import dora bodydef__get_type -func bodydef__get_type(slf: i64) => i32 +#wa:import dora bodydef_set_type +func bodydef_set_type(slf: i64, body_type: i32) +#wa:import dora bodydef_get_type +func bodydef_get_type(slf: i64) => i32 #wa:import dora bodydef_set_position func bodydef_set_position(slf: i64, val: i64); #wa:import dora bodydef_get_position @@ -87,4 +87,142 @@ func bodydef_attach_disk_sensor_with_center(slf: i64, tag: i32, center: i64, rad #wa:import dora bodydef_attach_disk_sensor func bodydef_attach_disk_sensor(slf: i64, tag: i32, radius: f32) #wa:import dora bodydef_new -func bodydef_new() => i64 \ No newline at end of file +func bodydef_new() => i64 +type BodyDef struct { Object } +func BodyDefFrom(raw: i64) => *BodyDef { + if raw == 0 { + return nil + } + object := BodyDef{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func BodyDef.GetTypeId() => i32 { + return bodydef_type() +} +func BodyDef.SetType(body_type: BodyType) { + bodydef_set_type(*this.raw, body_type.ToValue()) +} +func BodyDef.GetType() => BodyType { + return BodyType{value: bodydef_get_type(*this.raw)} +} +func BodyDef.SetPosition(val: Vec2) { + bodydef_set_position(*this.raw, val.ToValue()) +} +func BodyDef.GetPosition() => Vec2 { + return Vec2FromValue(bodydef_get_position(*this.raw)) +} +func BodyDef.SetAngle(val: f32) { + bodydef_set_angle(*this.raw, val) +} +func BodyDef.GetAngle() => f32 { + return bodydef_get_angle(*this.raw) +} +func BodyDef.SetFace(val: string) { + bodydef_set_face(*this.raw, ToDoraString(val)) +} +func BodyDef.GetFace() => string { + return FromDoraString(bodydef_get_face(*this.raw)) +} +func BodyDef.SetFacePos(val: Vec2) { + bodydef_set_face_pos(*this.raw, val.ToValue()) +} +func BodyDef.GetFacePos() => Vec2 { + return Vec2FromValue(bodydef_get_face_pos(*this.raw)) +} +func BodyDef.SetLinearDamping(val: f32) { + bodydef_set_linear_damping(*this.raw, val) +} +func BodyDef.GetLinearDamping() => f32 { + return bodydef_get_linear_damping(*this.raw) +} +func BodyDef.SetAngularDamping(val: f32) { + bodydef_set_angular_damping(*this.raw, val) +} +func BodyDef.GetAngularDamping() => f32 { + return bodydef_get_angular_damping(*this.raw) +} +func BodyDef.SetLinearAcceleration(val: Vec2) { + bodydef_set_linear_acceleration(*this.raw, val.ToValue()) +} +func BodyDef.GetLinearAcceleration() => Vec2 { + return Vec2FromValue(bodydef_get_linear_acceleration(*this.raw)) +} +func BodyDef.SetFixedRotation(val: bool) { + bodydef_set_fixed_rotation(*this.raw, ToDoraBool(val)) +} +func BodyDef.IsFixedRotation() => bool { + return bodydef_is_fixed_rotation(*this.raw) != 0 +} +func BodyDef.SetBullet(val: bool) { + bodydef_set_bullet(*this.raw, ToDoraBool(val)) +} +func BodyDef.IsBullet() => bool { + return bodydef_is_bullet(*this.raw) != 0 +} +func BodyDefPolygonWithCenter(center: Vec2, width: f32, height: f32, angle: f32, density: f32, friction: f32, restitution: f32) => FixtureDef { + return *FixtureDefFrom(bodydef_polygon_with_center(center.ToValue(), width, height, angle, density, friction, restitution)) +} +func BodyDefPolygon(width: f32, height: f32, density: f32, friction: f32, restitution: f32) => FixtureDef { + return *FixtureDefFrom(bodydef_polygon(width, height, density, friction, restitution)) +} +func BodyDefPolygonWithVertices(vertices: *[]Vec2, density: f32, friction: f32, restitution: f32) => FixtureDef { + return *FixtureDefFrom(bodydef_polygon_with_vertices(ToDoraVec2Buf(vertices), density, friction, restitution)) +} +func BodyDef.AttachPolygonWithCenter(center: Vec2, width: f32, height: f32, angle: f32, density: f32, friction: f32, restitution: f32) { + bodydef_attach_polygon_with_center(*this.raw, center.ToValue(), width, height, angle, density, friction, restitution) +} +func BodyDef.AttachPolygon(width: f32, height: f32, density: f32, friction: f32, restitution: f32) { + bodydef_attach_polygon(*this.raw, width, height, density, friction, restitution) +} +func BodyDef.AttachPolygonWithVertices(vertices: *[]Vec2, density: f32, friction: f32, restitution: f32) { + bodydef_attach_polygon_with_vertices(*this.raw, ToDoraVec2Buf(vertices), density, friction, restitution) +} +func BodyDefMulti(vertices: *[]Vec2, density: f32, friction: f32, restitution: f32) => FixtureDef { + return *FixtureDefFrom(bodydef_multi(ToDoraVec2Buf(vertices), density, friction, restitution)) +} +func BodyDef.AttachMulti(vertices: *[]Vec2, density: f32, friction: f32, restitution: f32) { + bodydef_attach_multi(*this.raw, ToDoraVec2Buf(vertices), density, friction, restitution) +} +func BodyDefDiskWithCenter(center: Vec2, radius: f32, density: f32, friction: f32, restitution: f32) => FixtureDef { + return *FixtureDefFrom(bodydef_disk_with_center(center.ToValue(), radius, density, friction, restitution)) +} +func BodyDefDisk(radius: f32, density: f32, friction: f32, restitution: f32) => FixtureDef { + return *FixtureDefFrom(bodydef_disk(radius, density, friction, restitution)) +} +func BodyDef.AttachDiskWithCenter(center: Vec2, radius: f32, density: f32, friction: f32, restitution: f32) { + bodydef_attach_disk_with_center(*this.raw, center.ToValue(), radius, density, friction, restitution) +} +func BodyDef.AttachDisk(radius: f32, density: f32, friction: f32, restitution: f32) { + bodydef_attach_disk(*this.raw, radius, density, friction, restitution) +} +func BodyDefChain(vertices: *[]Vec2, friction: f32, restitution: f32) => FixtureDef { + return *FixtureDefFrom(bodydef_chain(ToDoraVec2Buf(vertices), friction, restitution)) +} +func BodyDef.AttachChain(vertices: *[]Vec2, friction: f32, restitution: f32) { + bodydef_attach_chain(*this.raw, ToDoraVec2Buf(vertices), friction, restitution) +} +func BodyDef.AttachPolygonSensor(tag: i32, width: f32, height: f32) { + bodydef_attach_polygon_sensor(*this.raw, tag, width, height) +} +func BodyDef.AttachPolygonSensorWithCenter(tag: i32, center: Vec2, width: f32, height: f32, angle: f32) { + bodydef_attach_polygon_sensor_with_center(*this.raw, tag, center.ToValue(), width, height, angle) +} +func BodyDef.AttachPolygonSensorWithVertices(tag: i32, vertices: *[]Vec2) { + bodydef_attach_polygon_sensor_with_vertices(*this.raw, tag, ToDoraVec2Buf(vertices)) +} +func BodyDef.AttachDiskSensorWithCenter(tag: i32, center: Vec2, radius: f32) { + bodydef_attach_disk_sensor_with_center(*this.raw, tag, center.ToValue(), radius) +} +func BodyDef.AttachDiskSensor(tag: i32, radius: f32) { + bodydef_attach_disk_sensor(*this.raw, tag, radius) +} +func NewBodyDef() => BodyDef { + object := BodyDef{} + raw := bodydef_new() + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/buffer.wa b/Tools/dora-wa/vendor/dora/buffer.wa index a7f14d53c..56eeadd28 100644 --- a/Tools/dora-wa/vendor/dora/buffer.wa +++ b/Tools/dora-wa/vendor/dora/buffer.wa @@ -17,4 +17,33 @@ func buffer_resize(slf: i64, size: i32) #wa:import dora buffer_zero_memory func buffer_zero_memory(slf: i64) #wa:import dora buffer_get_size -func buffer_get_size(slf: i64) => i32 \ No newline at end of file +func buffer_get_size(slf: i64) => i32 +type Buffer struct { Object } +func BufferFrom(raw: i64) => *Buffer { + if raw == 0 { + return nil + } + object := Buffer{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func Buffer.GetTypeId() => i32 { + return buffer_type() +} +func Buffer.SetText(val: string) { + buffer_set_text(*this.raw, ToDoraString(val)) +} +func Buffer.GetText() => string { + return FromDoraString(buffer_get_text(*this.raw)) +} +func Buffer.Resize(size: i32) { + buffer_resize(*this.raw, size) +} +func Buffer.ZeroMemory() { + buffer_zero_memory(*this.raw) +} +func Buffer.GetSize() => i32 { + return buffer_get_size(*this.raw) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/c_45.wa b/Tools/dora-wa/vendor/dora/c_45.wa index cb3d6dd72..8ffcdf15d 100644 --- a/Tools/dora-wa/vendor/dora/c_45.wa +++ b/Tools/dora-wa/vendor/dora/c_45.wa @@ -7,4 +7,17 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #wa:import dora c45_build_decision_tree_async -func c45_build_decision_tree_async(data: i64, max_depth: i32, func0: i32, stack0: i64) \ No newline at end of file +func c45_build_decision_tree_async(data: i64, max_depth: i32, func0: i32, stack0: i64) +type _C45 struct { } +global C45 = _C45{} +func _C45.BuildDecisionTreeAsync(data: string, max_depth: i32, tree_visitor: func(depth: f64, name: string, op: string, value: string)) { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + depth, _ := stack0.PopF64() + name, _ := stack0.PopStr() + op, _ := stack0.PopStr() + value, _ := stack0.PopStr() + tree_visitor(depth, name, op, value) + }) + c45_build_decision_tree_async(ToDoraString(data), max_depth, func_id0, *stack0.raw) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/cache.wa b/Tools/dora-wa/vendor/dora/cache.wa index 125b78aa8..7e495ba77 100644 --- a/Tools/dora-wa/vendor/dora/cache.wa +++ b/Tools/dora-wa/vendor/dora/cache.wa @@ -21,4 +21,35 @@ func cache_unload() #wa:import dora cache_remove_unused func cache_remove_unused() #wa:import dora cache_remove_unused_by_type -func cache_remove_unused_by_type(type_name: i64) \ No newline at end of file +func cache_remove_unused_by_type(type_name: i64) +type _Cache struct { } +global Cache = _Cache{} +func _Cache.Load(filename: string) => bool { + return cache_load(ToDoraString(filename)) != 0 +} +func _Cache.LoadAsync(filename: string, handler: func(success: bool)) { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + success, _ := stack0.PopBool() + handler(success) + }) + cache_load_async(ToDoraString(filename), func_id0, *stack0.raw) +} +func _Cache.UpdateItem(filename: string, content: string) { + cache_update_item(ToDoraString(filename), ToDoraString(content)) +} +func _Cache.UpdateTexture(filename: string, texture: Texture2D) { + cache_update_texture(ToDoraString(filename), texture.GetRaw()) +} +func _Cache.UnloadItemOrType(name: string) => bool { + return cache_unload_item_or_type(ToDoraString(name)) != 0 +} +func _Cache.Unload() { + cache_unload() +} +func _Cache.RemoveUnused() { + cache_remove_unused() +} +func _Cache.RemoveUnusedByType(type_name: string) { + cache_remove_unused_by_type(ToDoraString(type_name)) +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/camera.wa b/Tools/dora-wa/vendor/dora/camera.wa index e9cc646bd..02ad732ab 100644 --- a/Tools/dora-wa/vendor/dora/camera.wa +++ b/Tools/dora-wa/vendor/dora/camera.wa @@ -21,7 +21,7 @@ func CameraFrom(raw: i64) => *Camera { result := &object return result } -func Camera.GetType() => i32 { +func Camera.GetTypeId() => i32 { return camera_type() } func Camera.GetName() => string { diff --git a/Tools/dora-wa/vendor/dora/dictionary.wa b/Tools/dora-wa/vendor/dora/dictionary.wa index 4b2638f85..352304544 100644 --- a/Tools/dora-wa/vendor/dora/dictionary.wa +++ b/Tools/dora-wa/vendor/dora/dictionary.wa @@ -27,7 +27,7 @@ func DictionaryFrom(raw: i64) => *Dictionary { result := &object return result } -func Dictionary.GetType() => i32 { +func Dictionary.GetTypeId() => i32 { return dictionary_type() } func Dictionary.GetCount() => i32 { diff --git a/Tools/dora-wa/vendor/dora/dora.wa b/Tools/dora-wa/vendor/dora/dora.wa index d907a661c..a6cd0e9c0 100644 --- a/Tools/dora-wa/vendor/dora/dora.wa +++ b/Tools/dora-wa/vendor/dora/dora.wa @@ -234,15 +234,24 @@ func object_to_body(obj: i64) => i64 #wa:import dora object_to_joint func object_to_joint(obj: i64) => i64 -type Object struct { +type Object :struct { raw: *i64 } +func ObjectFrom(raw: i64) => *Object { + if raw == 0 { + return nil + } + object := Object{raw: &raw} + setFinalizer(object.raw, ObjectFinalizer) + return &object +} + func Object.GetId() => i32 { return object_get_id(*this.raw) } -func Object.GetType() => i32 { +func Object.GetTypeId() => i32 { return object_get_type(*this.raw) } @@ -331,7 +340,7 @@ func value_is_vec2(value: i64) => i32 #wa:import dora value_is_size func value_is_size(value: i64) => i32 -type Value struct { +type Value :struct { raw: *i64 } @@ -542,7 +551,7 @@ func call_stack_front_vec2(stack: i64) => i32 #wa:import dora call_stack_front_size func call_stack_front_size(stack: i64) => i32 -type CallStack struct { +type CallStack :struct { raw: *i64 } @@ -675,13 +684,20 @@ func Println(values: ...interface{}) { strs := make([]string, len(values)) for i, value := range values { switch v := value.(type) { - case i32: strs[i] = strconv.FormatInt(int64(v), 10) - case i64: strs[i] = strconv.FormatInt(v, 10) - case f32: strs[i] = strconv.FormatFloat(float64(v), 'f', 2, 32) - case f64: strs[i] = strconv.FormatFloat(v, 'f', 2, 64) - case string: strs[i] = v - case *string: strs[i] = *v - case bool: strs[i] = strconv.FormatBool(v) + case i32: + strs[i] = strconv.FormatInt(int64(v), 10) + case i64: + strs[i] = strconv.FormatInt(v, 10) + case f32: + strs[i] = strconv.FormatFloat(float64(v), 'f', 2, 32) + case f64: + strs[i] = strconv.FormatFloat(v, 'f', 2, 64) + case string: + strs[i] = v + case *string: + strs[i] = *v + case bool: + strs[i] = strconv.FormatBool(v) case Vec2: strs[i] = "Vec2(" + strconv.FormatFloat(float64(v.X), 'f', 2, 32) + @@ -758,7 +774,8 @@ func Println(values: ...interface{}) { ")" } } - case nil: strs[i] = "nil" + case nil: + strs[i] = "nil" } } dora_print(ToDoraString(strings.Join(strs, " "))) @@ -809,7 +826,7 @@ func vec2_clamp(a: i64, from: i64, to: i64) => i64 #wa:operator - Vec2Sub #wa:operator * Vec2Mul Vec2MulFloat Vec2MulSize #wa:operator / Vec2Div -type Vec2 struct { +type Vec2 :struct { X: f32 Y: f32 } @@ -875,7 +892,7 @@ func Vec2.Clamp(from: Vec2, to: Vec2) => Vec2 { func Vec2.ToValue() => i64 { x := math.Float32bits(this.X) y := math.Float32bits(this.Y) - return i64(i64(y) << 32 | i64(x)) + return i64(i64(y)<<32 | i64(x)) } func Vec2FromValue(value: i64) => Vec2 { @@ -887,8 +904,8 @@ func Vec2FromValue(value: i64) => Vec2 { /* Size */ #wa:operator * SizeMulVec2 -type Size struct { - Width: f32 +type Size :struct { + Width: f32 Height: f32 } @@ -897,7 +914,7 @@ global SizeZero = Size{Width: 0, Height: 0} func Size.ToValue() => i64 { width := math.Float32bits(this.Width) height := math.Float32bits(this.Height) - return i64(i64(height) << 32 | i64(width)) + return i64(i64(height)<<32 | i64(width)) } func SizeFromValue(value: i64) => Size { @@ -912,14 +929,14 @@ func SizeMulVec2(a: Size, b: Vec2) => Vec2 { /* Color */ -type Color3 struct { +type Color3 :struct { R: u8 G: u8 B: u8 } func Color3.ToRGB() => i32 { - return i32(this.R) << 16 | i32(this.G) << 8 | i32(this.B) + return i32(this.R)<<16 | i32(this.G)<<8 | i32(this.B) } func Color3FromRGB(value: i32) => Color3 { @@ -929,13 +946,13 @@ func Color3FromRGB(value: i32) => Color3 { return Color3{R: u8(r), G: u8(g), B: u8(b)} } -type Color struct { +type Color :struct { Color3 A: u8 } func Color.ToARGB() => i32 { - return i32(this.A) << 24 | i32(this.Color3.ToRGB()) + return i32(this.A)<<24 | i32(this.Color3.ToRGB()) } func ColorFromARGB(value: i32) => Color { @@ -1250,7 +1267,7 @@ func Dictionary.Get(key: string) => (*Value, bool) { #wa:export dora_wasm_version func dora_wasm_version() => i32 { - return MajorVersion << 16 | MinorVersion << 8 | PatchVersion + return MajorVersion<<16 | MinorVersion<<8 | PatchVersion } global func_map = make([]func(), 0) @@ -1263,7 +1280,7 @@ func PushFunction(f: func()) => i32 { } if len(func_available) == 0 { func_map = append(func_map, f) - return i32(len(func_map) - 1) | flag + return i32(len(func_map)-1) | flag } else { new_len := len(func_available) - 1 func_id := func_available[new_len] @@ -1292,12 +1309,14 @@ func DerefFunction(func_id: i32) { /* BlendFunc */ -type BFunc struct { +type BFunc :struct { value: i64 } + func BFunc.ToValue() => i64 { return this.value } + global BlendFuncZero = BFunc{value: 0x0000000000001000} global BlendFuncOne = BFunc{value: 0x0000000000002000} global BlendFuncSrcColor = BFunc{value: 0x0000000000003000} @@ -1309,7 +1328,7 @@ global BlendFuncInvDstAlpha = BFunc{value: 0x0000000000008000} global BlendFuncDstColor = BFunc{value: 0x0000000000009000} global BlendFuncInvDstColor = BFunc{value: 0x000000000000a000} -type BlendFunc struct { +type BlendFunc :struct { value: i64 } @@ -1322,21 +1341,23 @@ func BlendFuncFrom(value: i64) => BlendFunc { } func NewBlendFunc(src: BFunc, dst: BFunc) => BlendFunc { - return BlendFunc{value: src.ToValue() << 8 | dst.ToValue() << 4} + return BlendFunc{value: src.ToValue()<<8 | dst.ToValue()<<4} } func NewBlendFuncSeperate(src_rgb: BFunc, dst_rgb: BFunc, src_alpha: BFunc, dst_alpha: BFunc) => BlendFunc { - return BlendFunc{value: (src_rgb.ToValue() << 8 | dst_rgb.ToValue() << 4 | src_alpha.ToValue() << 4 | dst_alpha.ToValue() << 4) << 8} + return BlendFunc{value: (src_rgb.ToValue()<<8 | dst_rgb.ToValue()<<4 | src_alpha.ToValue()<<4 | dst_alpha.ToValue()<<4) << 8} } /* TextureWrap */ -type TextureWrap struct { +type TextureWrap :struct { value: i32 } + func TextureWrap.ToValue() => i32 { return this.value } + global TextureWrapNone = TextureWrap{value: 0} global TextureWrapMirror = TextureWrap{value: 1} global TextureWrapClamp = TextureWrap{value: 2} @@ -1344,24 +1365,28 @@ global TextureWrapBorder = TextureWrap{value: 3} /* TextureFilter */ -type TextureFilter struct { +type TextureFilter :struct { value: i32 } + func TextureFilter.ToValue() => i32 { return this.value } + global TextureFilterNone = TextureFilter{value: 0} global TextureFilterPoint = TextureFilter{value: 1} global TextureFilterAnisotropic = TextureFilter{value: 2} /* Property */ -type Property struct { +type Property :struct { value: i32 } + func Property.ToValue() => i32 { return this.value } + global PropertyX = Property{value: 0} global PropertyY = Property{value: 1} global PropertyZ = Property{value: 2} @@ -1380,12 +1405,14 @@ global PropertyOpacity = Property{value: 14} /* Ease */ -type EaseType struct { +type EaseType :struct { value: i32 } + func EaseType.ToValue() => i32 { return this.value } + global EaseLinear = EaseType{value: 0} global EaseInQuad = EaseType{value: 1} global EaseOutQuad = EaseType{value: 2} @@ -1427,3 +1454,17 @@ global EaseOutInCirc = EaseType{value: 37} global EaseOutInElastic = EaseType{value: 38} global EaseOutInBack = EaseType{value: 39} global EaseOutInBounce = EaseType{value: 40} + +/* BodyType */ + +type BodyType :struct { + value: i32 +} + +func BodyType.ToValue() => i32 { + return this.value +} + +global BodyTypeDynamic = BodyType{value: 0} +global BodyTypeStatic = BodyType{value: 1} +global BodyTypeKinematic = BodyType{value: 2} diff --git a/Tools/dora-wa/vendor/dora/effect.wa b/Tools/dora-wa/vendor/dora/effect.wa index 7cadb2020..a6b19256f 100644 --- a/Tools/dora-wa/vendor/dora/effect.wa +++ b/Tools/dora-wa/vendor/dora/effect.wa @@ -27,7 +27,7 @@ func EffectFrom(raw: i64) => *Effect { result := &object return result } -func Effect.GetType() => i32 { +func Effect.GetTypeId() => i32 { return effect_type() } func Effect.Add(pass: Pass) { diff --git a/Tools/dora-wa/vendor/dora/fixture_def.wa b/Tools/dora-wa/vendor/dora/fixture_def.wa index 8fe225b8d..3f927634f 100644 --- a/Tools/dora-wa/vendor/dora/fixture_def.wa +++ b/Tools/dora-wa/vendor/dora/fixture_def.wa @@ -7,4 +7,18 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #wa:import dora fixturedef_type -func fixturedef_type() => i32 \ No newline at end of file +func fixturedef_type() => i32 +type FixtureDef struct { Object } +func FixtureDefFrom(raw: i64) => *FixtureDef { + if raw == 0 { + return nil + } + object := FixtureDef{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func FixtureDef.GetTypeId() => i32 { + return fixturedef_type() +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/grabber.wa b/Tools/dora-wa/vendor/dora/grabber.wa index cfda84188..72e2cc0c6 100644 --- a/Tools/dora-wa/vendor/dora/grabber.wa +++ b/Tools/dora-wa/vendor/dora/grabber.wa @@ -45,7 +45,7 @@ func GrabberFrom(raw: i64) => *Grabber { result := &object return result } -func Grabber.GetType() => i32 { +func Grabber.GetTypeId() => i32 { return grabber_type() } func Grabber.SetCamera(val: Camera) { diff --git a/Tools/dora-wa/vendor/dora/node.wa b/Tools/dora-wa/vendor/dora/node.wa index 81e908136..a87e53c75 100644 --- a/Tools/dora-wa/vendor/dora/node.wa +++ b/Tools/dora-wa/vendor/dora/node.wa @@ -253,7 +253,7 @@ func NodeFrom(raw: i64) => *Node { result := &object return result } -func Node.GetType() => i32 { +func Node.GetTypeId() => i32 { return node_type() } func Node.SetOrder(val: i32) { diff --git a/Tools/dora-wa/vendor/dora/pass.wa b/Tools/dora-wa/vendor/dora/pass.wa index 1af20f652..5ce20df57 100644 --- a/Tools/dora-wa/vendor/dora/pass.wa +++ b/Tools/dora-wa/vendor/dora/pass.wa @@ -31,7 +31,7 @@ func PassFrom(raw: i64) => *Pass { result := &object return result } -func Pass.GetType() => i32 { +func Pass.GetTypeId() => i32 { return pass_type() } func Pass.SetGrabPass(val: bool) { diff --git a/Tools/dora-wa/vendor/dora/physics_world.wa b/Tools/dora-wa/vendor/dora/physics_world.wa index 0b9ec3e8a..e28e06f1a 100644 --- a/Tools/dora-wa/vendor/dora/physics_world.wa +++ b/Tools/dora-wa/vendor/dora/physics_world.wa @@ -23,4 +23,60 @@ func physicsworld_set_scale_factor(val: f32); #wa:import dora physicsworld_get_scale_factor func physicsworld_get_scale_factor() => f32 #wa:import dora physicsworld_new -func physicsworld_new() => i64 \ No newline at end of file +func physicsworld_new() => i64 +type PhysicsWorld struct { Node } +func PhysicsWorldFrom(raw: i64) => *PhysicsWorld { + if raw == 0 { + return nil + } + object := PhysicsWorld{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func PhysicsWorld.GetTypeId() => i32 { + return physicsworld_type() +} +func PhysicsWorld.Query(rect: Rect, handler: func(body: Body) => bool) => bool { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + body := *BodyFrom(stack0.PopObject().GetRaw()) + result_ := handler(body) + stack0.Push(result_) + }) + return physicsworld_query(*this.raw, rect.GetRaw(), func_id0, *stack0.raw) != 0 +} +func PhysicsWorld.Raycast(start: Vec2, stop: Vec2, closest: bool, handler: func(body: Body, point: Vec2, normal: Vec2) => bool) => bool { + stack0 := NewCallStack() + func_id0 := PushFunction(func() { + body := *BodyFrom(stack0.PopObject().GetRaw()) + point, _ := stack0.PopVec2() + normal, _ := stack0.PopVec2() + result_ := handler(body, point, normal) + stack0.Push(result_) + }) + return physicsworld_raycast(*this.raw, start.ToValue(), stop.ToValue(), ToDoraBool(closest), func_id0, *stack0.raw) != 0 +} +func PhysicsWorld.SetIterations(velocity_iter: i32, position_iter: i32) { + physicsworld_set_iterations(*this.raw, velocity_iter, position_iter) +} +func PhysicsWorld.SetShouldContact(group_a: i32, group_b: i32, contact: bool) { + physicsworld_set_should_contact(*this.raw, group_a, group_b, ToDoraBool(contact)) +} +func PhysicsWorld.GetShouldContact(group_a: i32, group_b: i32) => bool { + return physicsworld_get_should_contact(*this.raw, group_a, group_b) != 0 +} +func PhysicsWorldSetScaleFactor(val: f32) { + physicsworld_set_scale_factor(val) +} +func PhysicsWorldGetScaleFactor() => f32 { + return physicsworld_get_scale_factor() +} +func NewPhysicsWorld() => PhysicsWorld { + object := PhysicsWorld{} + raw := physicsworld_new() + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + return object +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/scheduler.wa b/Tools/dora-wa/vendor/dora/scheduler.wa index 2be610d84..5b419d70f 100644 --- a/Tools/dora-wa/vendor/dora/scheduler.wa +++ b/Tools/dora-wa/vendor/dora/scheduler.wa @@ -31,7 +31,7 @@ func SchedulerFrom(raw: i64) => *Scheduler { result := &object return result } -func Scheduler.GetType() => i32 { +func Scheduler.GetTypeId() => i32 { return scheduler_type() } func Scheduler.SetTimeScale(val: f32) { diff --git a/Tools/dora-wa/vendor/dora/sensor.wa b/Tools/dora-wa/vendor/dora/sensor.wa index a3ff97e7f..12eabd55a 100644 --- a/Tools/dora-wa/vendor/dora/sensor.wa +++ b/Tools/dora-wa/vendor/dora/sensor.wa @@ -21,4 +21,39 @@ func sensor_is_sensed(slf: i64) => i32 #wa:import dora sensor_get_sensed_bodies func sensor_get_sensed_bodies(slf: i64) => i64 #wa:import dora sensor_contains -func sensor_contains(slf: i64, body: i64) => i32 \ No newline at end of file +func sensor_contains(slf: i64, body: i64) => i32 +type Sensor struct { Object } +func SensorFrom(raw: i64) => *Sensor { + if raw == 0 { + return nil + } + object := Sensor{} + object.raw = &raw + setFinalizer(object.raw, ObjectFinalizer) + result := &object + return result +} +func Sensor.GetTypeId() => i32 { + return sensor_type() +} +func Sensor.SetEnabled(val: bool) { + sensor_set_enabled(*this.raw, ToDoraBool(val)) +} +func Sensor.IsEnabled() => bool { + return sensor_is_enabled(*this.raw) != 0 +} +func Sensor.GetTag() => i32 { + return sensor_get_tag(*this.raw) +} +func Sensor.GetOwner() => Body { + return *BodyFrom(sensor_get_owner(*this.raw)) +} +func Sensor.IsSensed() => bool { + return sensor_is_sensed(*this.raw) != 0 +} +func Sensor.GetSensedBodies() => Array { + return *ArrayFrom(sensor_get_sensed_bodies(*this.raw)) +} +func Sensor.Contains(body: Body) => bool { + return sensor_contains(*this.raw, body.GetRaw()) != 0 +} \ No newline at end of file diff --git a/Tools/dora-wa/vendor/dora/sprite.wa b/Tools/dora-wa/vendor/dora/sprite.wa index d5a08f035..98e58b030 100644 --- a/Tools/dora-wa/vendor/dora/sprite.wa +++ b/Tools/dora-wa/vendor/dora/sprite.wa @@ -63,7 +63,7 @@ func SpriteFrom(raw: i64) => *Sprite { result := &object return result } -func Sprite.GetType() => i32 { +func Sprite.GetTypeId() => i32 { return sprite_type() } func Sprite.SetDepthWrite(val: bool) { diff --git a/Tools/dora-wa/vendor/dora/sprite_effect.wa b/Tools/dora-wa/vendor/dora/sprite_effect.wa index 262d255fe..4fd8f5245 100644 --- a/Tools/dora-wa/vendor/dora/sprite_effect.wa +++ b/Tools/dora-wa/vendor/dora/sprite_effect.wa @@ -21,7 +21,7 @@ func SpriteEffectFrom(raw: i64) => *SpriteEffect { result := &object return result } -func SpriteEffect.GetType() => i32 { +func SpriteEffect.GetTypeId() => i32 { return spriteeffect_type() } func NewSpriteEffect(vert_shader: string, frag_shader: string) => SpriteEffect { diff --git a/Tools/dora-wa/vendor/dora/texture_2d.wa b/Tools/dora-wa/vendor/dora/texture_2d.wa index cd3a4201d..57be60f90 100644 --- a/Tools/dora-wa/vendor/dora/texture_2d.wa +++ b/Tools/dora-wa/vendor/dora/texture_2d.wa @@ -25,7 +25,7 @@ func Texture2DFrom(raw: i64) => *Texture2D { result := &object return result } -func Texture2D.GetType() => i32 { +func Texture2D.GetTypeId() => i32 { return texture2d_type() } func Texture2D.GetWidth() => i32 {