Skip to main content

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.

Constructors​

MemberWhat it is
Wyrm()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

11 private and internal fields
MemberWhat it is
private Transform bodyBacking field for Body: the part that's shown when emerged and turned toward the target.
private ActionComponentSet burrowedActionsAction set used while burrowed. Built once per set and shared by all wyrms.
private ActionComponentSet emergedActionsAction set used while emerged. Built once per set and shared by all wyrms.
private Transform headTransform used as the wyrm's Position.
private ImpactGenerator[] impactorsImpact generators whose current attacks Attacks returns.
private string killedAnimatorBooleanAnimator bool set true on death. Defaults to isDead.
private string killedAnimatorTriggerAnimator parameter set on death. Defaults to Killed; it's set with SetBool, not as a trigger.
private float rotationSpeedDegrees per second RotateToTarget turns the body, before the speed multiplier.
private float sameTargetMultiplierBacking field for SameTargetMultiplier. Defaults to 1.2.
private MethodSyncStruct<bool> syncGameObjectsMethod sync for SyncGameObjects, sent on connect and when the body is shown or hidden.
private bool wasIdleWhether the last action was idle, so IdleStart only resets when idling starts.

Properties​

MemberWhat 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​

MemberWhat 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
MemberWhat it is
private void SyncGameObjects(IPlayer player, Stream stream, bool value)Syncs whether the wyrm's body and collision are shown; clients apply it.

Used in​

Members of other types that take, return or hold a Wyrm: