33 lines
536 B
Odin
33 lines
536 B
Odin
package main
|
|
|
|
|
|
FX :: struct {
|
|
using base: BaseEntity,
|
|
parent: Handle,
|
|
lifetime: f32,
|
|
permanent: bool,
|
|
}
|
|
|
|
init_fx :: proc(state: ^GameState, fx: FX) -> Handle {
|
|
return spawn(state, Entity{v = fx})
|
|
}
|
|
|
|
fx_update :: proc(state: ^GameState, fx: ^FX, h: Handle, dt: f32) {
|
|
if fx.parent != {} {
|
|
if pe := get_entity(state, fx.parent); pe != nil {
|
|
fx.pos = get_base(pe).pos
|
|
} else {
|
|
fx.marked = true
|
|
return
|
|
}
|
|
}
|
|
|
|
if !fx.permanent {
|
|
if fx.lifetime > 0 {
|
|
fx.lifetime -= dt
|
|
} else {
|
|
fx.marked = true
|
|
}
|
|
}
|
|
}
|