ECSpanse - an Entity Component System framework for Elixir

How do you modify the state of the Ecspanse server through a liveview? I see in the examples for enabling a system in the setup callback, you can add the option of “run_in_state”. I’m not sure of how to modify the state of the server so that the system only runs when in, let’s say, the “loading” state.

For example:

 @impl Ecspanse
  def setup(data) do
    data
    |> Ecspanse.add_system_set({__MODULE__, :onload_sync_systems}, [run_in_state: :loading])
    |> Ecspanse.add_system_set({__MODULE__, :play_sync_systems}, [run_in_state: :play])
  end

  def onload_sync_systems(data) do
    data
    |> Ecspanse.add_frame_start_system(Systems.SpawnShip)
  end

  def play_sync_systems(data) do
    data
    |> Ecspanse.add_system(Systems.MoveShip)
  end

How would I change the state to “:loading” or “:play”?

1 Like