SpawnComponent - acrimi/Raven GitHub Wiki

SpawnComponent spawns one or more entities at a fixed interval. The spawned entities will inherit the spawner's orientation and can optionally be configured with a custom position offset, initial velocity, and template overrides.

Configuration

When used inside the components block, the initial state of the component can be configured with the following parameters:

Key Type Description
maxSimultaneousSpawnCount int The maximum amount of entities that can be spawned at any one time, or 0 to allow infinite simultaneous entities. If the maximum is reached, no more entities will be spawned until one of the existing entities is destroyed, even if spawnInterval has passed. Defaults to 0.
maxTotalSpawnCount int The maximum amount of entities that can be spawned, or 0 to allow infinite entities. If the maximum is reached, no more entities will be spawned unless the component is manually reset. Defaults to 0.
spawnInterval float The delay, in seconds, between spawns. Defaults to 0.
initialSpawnDelay float The delay, in seconds, before the first entity will be spawned. Defaults to the value of spawnInterval.
type string The type of entity to spawn
tag string An optional tag to add to entities that are spawned
child boolean Whether the spawned entity should be attached as a child of the spawning entity's TransformComponent or as a standalone entity. Defaults to false.
velocity float|object A velocity that will be applied to the spawned entity relative to the spawning entity's orientation. A simple forward velocity can be supplied as a direct velocity, or a 2-dimensional relative velocity can be supplied as an object.
      lateral float The lateral velocity of the spawned entity relative to the spawning entity's orientation. Positive values move to the spawning entity's right, negative values to the left.
      forward float The forward velocity of the spawned entity relative to the spawning entity's orientation. Positive values move towards the front of the spawning entity, negative values towards the back.
alignment string The case-insensitive name of the alignment that should be used to position the spawned entity relative to the parent entity. See EntityAlignment for all values. Defaults to "center".
offset object An object containing the offset that should be applied to the spawned entity relative to its initial alignment. Individual offsets can be configured for each entity orientation.
      x float The default x offset that will be used for any orientation that doesn't have a custom offset specified
      y float The default y offset that will be used for any orientation that doesn't have a custom offset specified
      lateral float The lateral offset of the spawned entity relative to the spawning entity's orientation. Positive values move to the spawning entity's right, negative values to the left. Ignored if either x or y are defined.
      forward float The forward offset of the spawned entity relative to the spawning entity's orientation. Positive values move towards the front of the spawning entity, negative values towards the back. Ignored if either x or y are defined.
      mirrored boolean Whether or not the left/right offsets should be mirrored around the entity's horizontal axis when the opposite direction is missing. This can help avoid creating redundant configurations for each direction. Defaults to true.
      [orientation] object An object containing the offsets that should be applied to the spawned entity for the orientation named by this key. The key should correspond to the lowercased name of an EntityOrientation (eg "right", "up", etc).
            x float The x offset that will be applied for this orientation
            y float The y offset that will be applied for this orientation
initializationData object An optional configuration object that will be applied to the spawned entity. Supports all properties allowed in entity templates. Will be merged with any existing templates configured for the entity's type.

Examples:

"SpawnComponent": {
  "maxSimultaneousSpawnCount": 1,
  "maxTotalSpawnCount": 10,
  "spawnInterval": 0.5,
  "initialSpawnDelay": 0,
  "type": "minion",
  "tag": "hiveSpawn",
  "child": false,
  "alignment": "origin",
  "initializationData": {
    "components": {
      "HitBoxComponent": {
        "isAttached": "true"
      }
    },
    "events": {
      "destroyed": {
        "action": "EventAction",
        "eventName": "minionKilled"
      }
    }
  }
}
"SpawnComponent": {
  "maxSimultaneousSpawnCount": 1,
  "maxTotalSpawnCount": 10,
  "spawnInterval": 0.5,
  "type": "barrier",
  "tag": "autoShield",
  "child": true,
  "alignment": "edge",
  "offset": {
    "x": -1,
    "y": -2,
    "mirrored": true,
    "up": {
      "x": -1,
      "y": 2
    },
    "right": {
      "x": 2,
      "y": -1
    }
  }
}
"SpawnComponent": {
  "maxSimultaneousSpawnCount": 1,
  "maxTotalSpawnCount": 10,
  "spawnInterval": 0.5,
  "type": "barrier",
  "tag": "autoShield",
  "child": true,
  "alignment": "edge",
  "offset": {
    "lateral": -1,
    "forward": 2
  }
}

Properties

This component has no exposed properties