EnemyActionInstance

Serializable nested class used to populate the attackSequence array in the Inspector. Each slot pairs an EnemyAction with the number of loop iterations it runs for before the sequence advances.

FieldTypeDescription
actionEnemyActionThe EnemyAction ScriptableObject to execute in this slot.
loopintNumber of loop iterations this action runs before the sequence moves to the next slot.

Inspector Fields

FieldTypeDescription
_damageintBase damage dealt per attack hit.
_defenseintBase defense value subtracted from incoming damage.
defaultDirectionDirectionFacing direction applied when the level starts.
loopboolWhen enabled the patrol sequence repeats from the beginning after reaching the last waypoint.
moveSequenceDirection[]Ordered patrol directions the enemy follows when no player is detected within range.
directionsDirection[]Directions to scan for the player each turn.
rangeintCell distance used when scanning for the player.
attackSequenceEnemyActionInstance[]Ordered attack actions with per-slot loop counts. Played in order when the player is detected.

Properties

PropertyTypeDescription
damageint (get/set)Base damage dealt per attack. Overrides the base class virtual property.
defenseint (get/set)Defense value subtracted from incoming damage. Overrides the base class virtual property.
currentInstructionInstructionThe instruction currently being executed by this enemy.

Events

EventSignatureDescription
OnMouseHoverAction<bool>Fired on pointer enter (true) and pointer exit (false). Used by the Enemy HUD to show or hide the action panel.
OnStartActionFired when the attack sequence begins for the first time.
OnActionChangeAction<EnemyAction>Fired each time the active action changes within the attack sequence, passing the new action.
OnEndActionFired when the full attack sequence has finished all of its iterations.
OnExecuteAction<ExecutionContext>Fired each time an instruction step executes. IExecutionSuscriber components are subscribed automatically during Initialize().

Methods

MethodDescription
Initialize(ExecutionContext context,
ExecutionContextElement parent)
Flattens the attackSequence into a per-instruction list, subscribes all IExecutionSuscriber children to OnExecute, and registers an OnDie callback to interrupt the current task when the enemy dies.
GetTask() → TaskITaskReceiver implementation. Scans the configured directions for the player — returns an attack Task if detected, a patrol Task otherwise. Called by the InstructionRunner each turn.
Execute()Runs the current instruction and fires OnExecute. Called by the active task once per turn step.
PlaySound(AudioResource resource)Stops any currently playing sound and plays the given AudioResource on the character's AudioSource.
Validate() → boolIObstacle implementation — always returns false, making the enemy an impassable obstacle that blocks player movement.

Inherited from CharacterInstanceController

The following members are defined on the base class and available on every EnemyController instance:

MemberTypeDescription
positionVector2 (get/set)World-space position of the character.
directionDirectionCurrent facing direction.
healthHealthThe Health component managing hit points and death.
blockingboolWhether the enemy is in a blocking pose. Checked by EnemyHealth before applying damage.
HUDTransformRoot of the in-world HUD elements. Flipped alongside the sprite on direction changes.
SetDirection(Direction direction)Faces the character and flips the sprite and HUD for left/right directions.
PlayAnimation(string stageName)Plays an animator state by name. Does nothing if the character is dead.
ℹ️
Enemies are fully autonomous. Place the prefab in the scene, configure moveSequence and attackSequence in the Inspector, and the InstructionRunner schedules their tasks automatically each loop iteration — no scripting required for basic enemies.