Wyrm
A class in Root.Township, Alta.Intelligence.
The wyrm creature's AI agent. It switches between a burrowed and an emerged action set, and syncs whether its body and collision are visible. The AI runs on the server.
- Listed in Creatures and AI
- Inherits or implements
Agent<Wyrm> - Derived types
Wyrm,ActiveCatch,ActiveDig,ActiveDodge,ActiveEmerge,ActiveMeleeAttack,ActiveSpin,ActiveSpit - Documented in Common creatures, Creature data, Creatures and AI
Constructors
| Member | What it is |
|---|---|
Wyrm() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
11 private and internal fields
| Member | What it is |
|---|---|
private Transform body | Backing field for Body: the part that's shown when emerged and turned toward the target. |
private ActionComponentSet burrowedActions | Action set used while burrowed. Built once per set and shared by all wyrms. |
private ActionComponentSet emergedActions | Action set used while emerged. Built once per set and shared by all wyrms. |
private Transform head | Transform used as the wyrm's Position. |
private ImpactGenerator[] impactors | Impact generators whose current attacks Attacks returns. |
private string killedAnimatorBoolean | Animator bool set true on death. Defaults to isDead. |
private string killedAnimatorTrigger | Animator parameter set on death. Defaults to Killed; it's set with SetBool, not as a trigger. |
private float rotationSpeed | Degrees per second RotateToTarget turns the body, before the speed multiplier. |
private float sameTargetMultiplier | Backing field for SameTargetMultiplier. Defaults to 1.2. |
private MethodSyncStruct<bool> syncGameObjects | Method sync for SyncGameObjects, sent on connect and when the body is shown or hidden. |
private bool wasIdle | Whether the last action was idle, so IdleStart only resets when idling starts. |
Properties
| Member | What it is |
|---|---|
Transform Body { get; } | The body transform that RotateToTarget turns. |
ActionSet<Wyrm> BurrowedPossibilitySet { get; set; } | Actions this wyrm can pick while underground. |
ActionSet<Wyrm> EmergedPossibilitySet { get; set; } | Actions this wyrm can pick while above ground. |
float FlurryChance { get; set; } | Current chance of a follow-up melee flurry. Melee attacks raise it each hit and reset it to 0 when a flurry fires. |
float IdleStart { get; private set; } | Time the wyrm went idle. The dig action uses the idle time to decide when to burrow; set far in the future while busy. |
override Vector3 Position { get; } | The head's position, used as the wyrm's position for targeting. |
float SameTargetMultiplier { get; } | Configured weighting for keeping the same target. |
protected static Dictionary<ActionComponentSet, ActionSet<Wyrm>> BurrowedActions { get; private set; } | Shared cache of burrowed action sets, one per ActionComponentSet asset, across all wyrms. |
protected static Dictionary<ActionComponentSet, ActionSet<Wyrm>> EmergedActions { get; private set; } | Shared cache of emerged action sets, one per ActionComponentSet asset, across all wyrms. |
Methods
| Member | What it is |
|---|---|
override IEnumerable<AttackParameters> Attacks() (iterator) | Yields the current attack of each of the wyrm's impactors. |
override void Initialize() | Sets up the network message that syncs body visibility. |
override void OnConnected(Player player) | Server: sends a joining player whether the body is currently shown. |
void RotateToTarget(float speedMultiplier = 1) | Turns the body on the horizontal plane towards the current target at the configured speed. |
void SetGameObjectsActive(bool isActive) | Shows or hides the body and collision objects. On the server it also syncs the change to the chunk. |
void UseBurrowedActions() | Switches the action decider to the burrowed set. Called when the wyrm digs. |
void UseEmergedActions() | Switches the action decider to the emerged set. Called when the wyrm emerges. |
protected override void Awake() | Turns collision off, makes its colliders ignore each other and hides the body. |
protected override bool ChangeAction() | Picks a new action and tracks IdleStart, so idle time counts from when it went idle. |
protected override void InitializeAi() | Builds or reuses the burrowed and emerged action sets and starts in burrowed mode. |
protected override void InitializeStatic() | Creates the shared action set caches. |
protected override void Killed(HealthObject healthobject) | Turns off collision and sets the death animator parameters. |
1 private and internal method
Used in
Members of other types that take, return or hold a Wyrm: