Noah2610 / deathfloor

Work-in-progress Mega Man inspired game.
MIT License
2 stars 0 forks source link

Spawn entities with entity config action #39

Closed hoichael closed 4 years ago

hoichael commented 4 years ago

Shoot property for enemy config

Noah2610 commented 4 years ago

Ideal implementation: Figure out a way for entities to spawn other entities via entity config events/actions. Will take some time to design and implement, but would be a pretty flexible implementation, that could be used to spawn any entity, not only bullets.

Quicker implementation: Add a Shooter component; add component to entities that should shoot (in regular intervals?). Way less flexible, but easier and quicker to implement.

Noah2610 commented 4 years ago

@hoichael This works, although I'm not quite happy with it yet. Merged on master.

Spawn objects, as if placed in Tiled, with the SpawnAction in an entity config. Example: https://github.com/Noah2610/deathfloor/blob/c2db68032587f2a7ab54e9d7d5cf7acc0967e5d8/resources/settings/enemies/dev/dev.ron#L75 The data given to the SpawnAction, is the same data as generated when placing an object in Tiled. It needs the position, size, type, and props for the object to spawn.

Closing for now, might refactor this later.

Noah2610 commented 4 years ago

@hoichael There's a new object type, Custom(CUSTOM_TYPE). Define custom entity configs in any RON file under resources/settings/custom_entities/.

Use this object type for entities with custom logic, that are not enemies. Prefer defining custom entities over enemies, when they don't need all enemy logic.

Enemy spawning custom projectiles, for example: Projectile-spawning enemy: https://github.com/Noah2610/deathfloor/blob/1ab098639f0c04247a7c109a4ef316067f84d7a7/resources/settings/enemies/dev/dev_bullet_spawner.ron Spawned projectiles: https://github.com/Noah2610/deathfloor/blob/1ab098639f0c04247a7c109a4ef316067f84d7a7/resources/settings/custom_entities/dev/bullet.ron

Note, custom entities are not loaded/unloaded from the loading system by default. If this becomes necessary I'll add a way to do this.