Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
notbadgun committed May 2, 2022
1 parent c7925ca commit 1679902
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 43 deletions.
2 changes: 1 addition & 1 deletion examples/scenes/blocksbuster/blocksbuster.collection
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ instances {
}
instances {
id: "buster"
prototype: "/scene3d/prefabs/characters/buster.go"
prototype: "/examples/scenes/blocksbuster/buster.go"
position {
x: 0.0
y: 0.05
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
components {
id: "buster"
component: "/scene3d/scripts/characters/buster.script"
component: "/examples/scenes/blocksbuster/scripts/buster.script"
position {
x: 0.0
y: 0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,50 +1,12 @@
local animation = require("scene3d.scripts.animation")
local blob_shadow = require("scene3d.scripts.blob_shadow")
local collision = require("scene3d.scripts.collision")
local frustum_mesh = require("scene3d.scripts.frustum_mesh")
local render3d = require("scene3d.render.render3d")

-- go.property("mesh_enabled", true)
go.property("mesh1_id", hash("mesh1"))
go.property("mesh2_id", hash("mesh2"))

-- frustum_mesh.lua
go.property("frustum_cull_enabled", true)
go.property("frustum_mesh_max_dimension", 1)
go.property("frustum_mesh_use_world_position", false)

-- collision.lua
go.property("collision_type", hash("trigger"))
go.property("collision_group", hash(""))
go.property("collision_mask", hash(""))

go.property("message_receiver", msg.url())
go.property("message_init", hash(""))

local EMPTY_HASH = hash("")

function init(self)
frustum_mesh.init(self, msg.url(nil, nil, self.mesh1_id))
frustum_mesh.init(self, msg.url(nil, nil, self.mesh2_id))
collision.init(self, { trigger = COLLISION_TRIGGER })

if self.message_init ~= EMPTY_HASH then
msg.post(self.message_receiver, self.message_init)
end

physics.set_group("#collision_trigger", "default")
self.busted_blocks_id = {}
physics.set_group("#collision_trigger", "default")
end

function final(self)
frustum_mesh.final(self)
collision.final(self)
end

function update(self, dt)
frustum_mesh.update(self)
collision.update(self, dt)

for block_id, _ in pairs(self.busted_blocks_id) do
local block_position = go.get_world_position(block_id)
local distance = go.get_world_position() - block_position
Expand All @@ -68,8 +30,6 @@ function update(self, dt)
end

function on_message(self, message_id, message, sender)
collision.on_message(self, message_id, message, sender)

if message_id == hash("trigger_response") then
if message.other_id ~= hash("/buildings_floor_10x10") then
local collision_dynamic_url = msg.url(nil, message.other_id, "collision_dynamic")
Expand Down

0 comments on commit 1679902

Please sign in to comment.