rrbox / ecs-swift

Entity Component System for swift
MIT License
3 stars 0 forks source link

Entity commands の仕組みの見直し #77

Open rrbox opened 4 months ago

rrbox commented 4 months ago

70 , #55 や #76 に関連のある変更です。

70 で entity 生成直後か entity 検索によるかで entity commands の種類を変える方法を採用しました。

しかし、#55 で entity への graphic の割り当ての際に entity commands によって実装方法が異なることや、それぞれに同じメソッドを作成しても、entity commands 共通のメソッドとして動的に実行することが難しくなるなど、問題が生じているようです。

最良は、同じ entity command (entity record の変更)を別々の entity commands に push するだけで、実行方法が分けられることです。

rrbox commented 4 months ago

Entity command は command とは別の扱いとする必要があります。

  1. Entity commands オブジェクトに entity command の queue を用意し、push していきます。
  2. commands オブジェクトには entity commands の queue (あるいは entity commands そのもの)を command(entity transaction)として push します。
  3. フレーム終了後に entity commands を command(entity transaction)として実行、その中で entity command の queue が順次実行されます。
  4. entity commands が実行されたあと、システム全体にエンティティの構造変化が反映されます。