aboutsummaryrefslogtreecommitdiff
path: root/src/objs/speck_entity.lua
blob: 0de6f4fd20e8fd67eefb7722cbf1fab886b0957d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
register_comp("Speck_System", function(ent, filepath)
  ent.speck_sys = load_speck_sys(filepath)
end)

function speck_update_sys(ent, dt)
  ent.speck_sys.x = ent.x
  ent.speck_sys.y = ent.y

  ent.speck_sys:update(dt)
end

function speck_draw_sys(ent)
  ent.speck_sys:draw()
end

function new_speck_entity(x, y, filepath)
  local ent = new_entity()
  add_comp(ent, "Position", x, y)
  add_comp(ent, "Speck_System", filepath)
  ent.speck_sys.oneshot = true

  add_comp(ent, "Speck_Entity")
end

register_comp("Speck_Entity", TAGCOMP)

function speck_entity_system(ent, dt)
  local sys = ent.speck_sys
  if not sys.emitting and sys:is_empty() then
    queue_entity_kill(ent)
  end
end