Namespace FishMMO.Server.Implementation.World.SceneServer.AI
Classes
- AIAbilityClassifier
Works out what an ability does by reading the ECA action graph the designer already built, so archetypes never have to name specific abilities.
- AIAbilityCondition
Abstract base class for AI ability conditions. Each condition evaluates a boolean predicate that determines whether an ability rotation entry should be selected. Conditions are ScriptableObject assets that can be shared across multiple rotations.
Subclasses override Evaluate(AIController, ICharacter, ICharacter) to implement specific checks such as health thresholds, buff presence, distance comparisons, etc.
- AIAbilityReach
How far an ability can actually hit something from, as the AI should reason about it.
- AIAbilityRotation
ScriptableObject that defines an ordered list of ability entries with conditions. Attach to an AIController to give NPCs intelligent, designer-driven ability selection instead of (or in addition to) the default scoring-based picker.
In Priority mode, entries are evaluated top-to-bottom and the first match wins — ideal for conditional behaviour such as "use Heal when health ≤ 40%, else use Fireball".
In Sequence mode, the NPC advances through the list in order, trying the next entry each evaluation — ideal for structured rotations such as "Fireball → Frost Bolt → Pyroblast → repeat".
- AIAbilityRotationEntry
A single entry in an AI ability rotation. Pairs an ability template with a set of conditions that must all be satisfied for the ability to be selected.
- AIAdoptGroupTargetNode
Behavior tree leaf that adopts the pack's focus. If the NPC belongs to an NPCGroup whose GroupTargetCharacter is a living target, this node sets the NPC's Target to it and returns Success.
Use case: "Focus the tank's target" → place this before a StateTransition to AttackState.
- AIAimProfile
How well an NPC aims: which point on a target it shoots at, how long it needs to settle, and how far it misses by while it has not.
- AIAimSolver
The pure arithmetic behind an NPC's aim: which point to aim at, how accurately, and with how much error.
- AIArchetypeTemplate
A complete, reusable AI brain in one asset: which states an NPC uses, how it picks abilities, how it behaves in combat, how it accrues threat, and how it is throttled at distance.
- AIBehaviorNode
Abstract base class for all behavior tree nodes. Nodes are ScriptableObject assets so designers can build trees entirely in the Unity inspector without code.
Behavior trees sit above the state machine layer and decide which BaseAIState the NPC should transition to. The state machine then handles the actual movement, combat, and animation logic.
Node types:
- AISelector — Tries children left-to-right, returns first success.
- AISequence — Runs children left-to-right, fails on first failure.
- AIInverter — Inverts the child's result.
- AIRepeater — Repeats the child a configurable number of times.
- AIConditionNode — Leaf that checks an AIAbilityCondition.
- AIStateTransitionNode — Leaf that transitions to a BaseAIState.
- AIBehaviorTree
Root container for a behavior tree. Assign to BehaviorTree to give an NPC high-level decision-making above the state machine.
The tree is evaluated once per AI tick (governed by AI LOD). If the root node returns Success, the tree produced a state transition and the current state's
UpdateStateis skipped for that tick. If it returns Failure, the current state continues normally.Example tree:
AIBehaviorTree (root = Selector) ├─ Sequence: [Condition: IsDead] → [StateTransition: DeadState] ├─ Sequence: [Condition: HP ≤ 30%] → [StateTransition: RetreatState] ├─ Sequence: [Condition: EnemyNearby] → [StateTransition: AttackState] └─ StateTransition: WanderState
- AIBodyGrid
Where every NPC body in one physics scene stands, bucketed into a uniform grid so a separation query reads a handful of cells instead of running a physics overlap.
- AIBrainCatalogue
Which brain each NPC prefab runs.
- AIBrainCatalogue.Entry
One NPC prefab's brain.
- AIBrainHost
Attaches, drives and detaches the server-side brain of every NPC spawned under one FishNet.Managing.NetworkManager.
- AIBuffCondition
Condition that checks whether a character has (or doesn't have) a specific buff or debuff.
Examples:
- "Self has buff 42" → target already has a HoT, skip re-applying.
- "Target missing debuff 7" → apply the DoT.
- AICombatDecision
The single combat decision shared by every attacking state.
- AICombatPersonality
Data-driven combat personality asset that makes two NPCs with the same ability set behave differently in combat. Assign to Personality.
The personality provides per-AbilityCategory score multipliers that PickBestAbility(float) applies on top of the default scoring. Two warriors sharing the same ability list but with different personalities will favour different abilities and positioning.
Range thresholds control how abilities are classified. Abilities whose Range falls below MeleeRangeThreshold are considered melee; those above are ranged. Abilities with HitCount greater than 1 or grounded spawn targets are classified as AOE. Self-targeted abilities are classified as Support.
- AICombatSlots
Hands each attacker its own standing spot in a ring around a shared target, so a pack surrounds its victim instead of piling onto one point.
- AICompositeNode
Composite node that wraps a list of children. Base class for AISelector and AISequence.
- AIConditionNode
Leaf node that evaluates an AIAbilityCondition and returns Success or Failure.
Use case: "Is the NPC's health below 30%?"
The existing AIAbilityCondition system is reused so designers don't need to create duplicate condition assets. Any condition that works in an ability rotation also works as a behavior tree guard.
- AIController
Controls AI navigation, state transitions, and behavior for NPCs using NavMeshAgent. Handles movement, enemy detection, leash logic, waypoints, state management, and provides a virtual camera for aiming abilities at targets during combat.
- AIDistanceCondition
Condition that evaluates based on the distance between the NPC and its current target.
Examples:
- "Distance ≤ 3" → in melee range, use a cleave ability.
- "Distance ≥ 15" → far away, use a snipe ability.
- AIGroupInCombatNode
Behavior tree leaf that checks if the NPC belongs to an NPCGroup and whether the group is currently in combat. Returns Success when the group is fighting.
Use case: "If my pack is in combat → join the fight (even if I haven't been attacked)."
- AIHasTargetNode
Behavior tree leaf that checks if the NPC currently has a combat target. Returns Success if Target is not null, Failure otherwise.
Use case: "If has target → stay in combat" in a behavior tree selector.
- AIHealthCondition
Condition that evaluates based on a character's health percentage. Can check either the NPC's own health or the current target's health.
Examples:
- "Self health ≤ 40%" → use a defensive or healing ability.
- "Target health ≤ 20%" → use an execute ability.
- "Self health ≥ 80%" → use an offensive stance ability.
- AIInverter
Decorator that inverts the child's result. Success becomes Failure and vice versa. Running passes through unchanged.
Use case: "If NOT low health → continue attacking."
- AIIsDeadNode
Behavior tree leaf that checks if the NPC is alive. Returns Success when alive, Failure when dead or missing damage controller.
Use case: First check in a selector — "If dead → DeadState". Combine with AIInverter to get "IsAlive".
- AILodSettings
Distance thresholds and per-tier update intervals for AI level-of-detail. Assign to LodSettings.
- AIPetSupportSettings
How a pet uses the heals and buffs it knows: who it looks after, and when. See PetSupport.
- AIRandomCondition
Condition that passes with a configurable random probability each evaluation. Useful for introducing variety — e.g., "30% chance to use a special attack".
- AIRepeater
Decorator that repeats its child a configurable number of times per evaluation. Returns Success after all repetitions succeed. Returns Failure if any repetition fails.
When RepeatCount is 0, repeats indefinitely (always returns Running).
- AIRetreatDecision
Decides whether a fleeing NPC keeps running, turns around, or disengages.
- AISelector
Selector (OR) node. Tries each child left-to-right and returns Success as soon as one child succeeds. Returns Failure only if every child fails. Returns Running if any child is running.
Use case: "Try heal → if that fails, try attack → if that fails, wander."
- AISeparation
Keeps NPCs from standing inside one another without Unity's crowd avoidance.
- AISequence
Sequence (AND) node. Runs each child left-to-right and returns Success only if every child succeeds. Returns Failure on the first child that fails. Returns Running if any child is running.
Use case: "Check health condition AND then transition to retreat state."
- AIShelterSettings
Whether, and in what, an archetype's NPCs go and stand out of the weather.
- AIStateTransitionNode
Leaf node that transitions the NPC's state machine to a specific BaseAIState. Always returns Success after triggering the transition.
This is the bridge between the behavior tree (decision layer) and the state machine (execution layer). The tree decides "attack", and this node calls ChangeState(BaseAIState, List<ICharacter>) to make it happen.
- AISwimRisk
The decision an NPC makes when the way to its target is through deep water: scored, never scripted. The risk is how long it would be in the water against how good a swimmer it is, with its breath on top for one that swims under; its appetite for risk is its courage, scaled by how much it wants this target. In if the appetite covers the risk; otherwise it waits on the shore; and past its leash, it lets the target go.
- AISwimSettings
Whether, and how, an archetype's NPCs swim (2026-10-05: not all NPCs can swim; swimming NPCs will probably drown, and an AI decides whether to chase into the water or stay on land).
- AISystem
The scene server's NPC brain system: runs one AIBrainHost for the process.
- AITargetSelection
Target-picking strategies shared by the attacking states and the behaviour tree.
- AIUtility
Shared utility methods for the AI subsystem. Provides common operations used across ability rotations, boss scripts, and attacking states to eliminate duplication (DRY).
- AggressionController
Manages an aggression (threat) table for a single NPC. Tracks threat from damage, healing, resource expenditure, and arbitrary point adjustments. Threat decays over time. Target selection uses both raw threat points and a vulnerability multiplier based on the target's current health and mana percentages.
Plain C# class — one instance per NPC, owned by AggressionState.
- AggressionDispatcher
Routes combat events to the one NPC that cares about them, instead of broadcasting every event to every NPC in the scene.
- AggressionEntry
Tracks accumulated aggression (threat) from a single character toward an NPC. Points are gained when the character damages the NPC, heals an enemy, spends resources, or takes other aggressive actions. Points decay over time so stale threats fade.
- AggressionState
Manages the aggression (threat) system for a single NPC. Owns the AggressionController instance, subscribes to global damage/heal/kill events, and tracks the per-NPC target re-evaluation timer.
Extracted from AIController to keep the controller focused on navigation and state management. One instance per NPC — plain C# class.
Event-driven combat entry: every hit this NPC takes is reported through OnHitRecorded, and the brain decides from its own state whether that hit starts a fight (OnThreatReceived(ICharacter)). It used to fire only when the table went from empty to non-empty, and nothing but a kill ever emptied it: a fight that ended any other way — the target out of reach, zoned, leashed away — left entries behind, so every later hit from beyond the detection radius was recorded and ignored, and each one refreshed the entry that kept it from ever going stale. Deciding per hit from the brain's state has no edge to consume.
Replay safety: Event handlers are guarded to ignore damage/heal/kill events fired during prediction replay. Global combat events are not replay-suppressed by the damage controller, so we suppress them here.
- BaseAIState
Abstract base class for all AI states. Defines common parameters and logic for state transitions, leash checks, enemy detection, and line of sight.
- BaseAttackingState
The one attacking state. Handles target selection, spacing, ability activation and mid-combat re-targeting for every NPC archetype.
- BossPhase
Defines a single phase of a boss encounter. A boss transitions to the next phase when its health drops below HealthThreshold. Each phase can override the boss's behavior tree, attacking state, and spawn adds.
- BossScript
ScriptableObject that defines a boss encounter's phases and timed mechanics. Assign to BossScript to make an NPC a scripted boss.
The AIController evaluates the boss script every tick:
- Checks health against phase thresholds.
- On phase change, applies overrides (behavior tree, attacking state, ability rotation) and spawns adds.
- Ticks all active timed mechanics and force-activates abilities or spawns when timers fire.
Example setup:
Phases: [0] HP ≥ 70% — default behavior [1] HP < 70% — spawn 2 adds, switch to Phase2 behavior tree [2] HP < 40% — enrage: switch to melee attacking stateTimed Mechanics: Meteor — every 30s, force-cast AbilityTemplate #5 Summon — every 60s, spawn skeleton prefab (only in phase 1)
- BossScriptState
Per-NPC runtime state for a BossScript. Tracks the current phase index, timed mechanic timers, and handles phase transitions and mechanic activations.
This is a plain C# class (not a ScriptableObject) because it holds mutable state that differs per NPC instance — the same BossScript asset may be shared across multiple boss spawns.
- BossTimedMechanic
Defines a timed mechanic that fires at regular intervals during a boss encounter. E.g., "Every 30 seconds, cast Meteor."
- CasterAttackingState
Caster archetype preset (mages, warlocks, crowd controllers). Sits at the far edge of its spell range, refuses to be meleed, and interrupts its own cast to escape when something gets inside the panic radius.
- DefenderAttackingState
Defender / tank archetype. Fights in melee, keeps its taunts on cooldown to hold threat, and physically interposes itself between the enemy and whoever it is protecting.
- GetBehindState
Combat sub-state that circles the NPC around to the back of its current target.
- HealerAttackingState
Healer archetype. Keeps caster spacing from the enemy, but interrupts its damage rotation to top up the most wounded nearby ally.
- IdleState
AI state for idle behavior. Handles update rate, entering, exiting, and transition logic for NPCs.
- MeleeAttackingState
Melee archetype preset. Closes to weapon reach, never backs away, and occasionally steps into a flanking or orbiting sub-state for variety.
- NPCGroup
A pack of NPCs that fight together: a shared focus target, group alerts, roles, and a tactic that arranges members around the enemy while they orbit it.
- NPCPackSettings
How a spawner's NPCs fight as a pack: whether they are one at all, and the tactic, focus and ring they share. Authored on an
ObjectSpawner, baked into itsSpawnerDefinition, and read by the running spawner when it founds an NPCGroup.
- OrbitState
Combat sub-state that strafes the NPC in a circle around its current target.
- PatrolState
Waypoint patrol. Walks the spawner-supplied waypoint ring in order.
- PetAttackingState
Pet combat preset. A plain melee-tuned attacking state with pet-appropriate defaults.
- PetIdleState
A pet's out-of-combat state: heel near its owner, hold position on a Stay order, and enter combat when the pet's PetStance says it should.
- PetSupport
How a pet uses the heals and buffs it knows: on its owner first, always, then on itself and the friends around it.
- RangedAttackingState
Ranged archetype preset (archers, hunters, gunners). Holds a working distance, kites when the target closes, and breaks away hard once the target is inside the panic radius.
- RetreatState
Moves the NPC away from its target until a safe distance is reached, then disengages.
- ReturnHomeState
AI State for returning the NPC to its home position. Handles healing and movement speed adjustments.
- RogueAttackingState
Rogue archetype. Melee, but refuses to trade blows face-to-face: it circles into the target's rear arc before opening, and drifts back around whenever the target turns on it.
- SeekShelterState
Walks to the nearest cover and waits there until the weather passes.
- WanderState
Wandering behaviour. The NPC drifts to random points around its home, pausing at idle now and then.
- WildlifeFleeState
Prey's "attacking" state: it never attacks, it runs. Slotted as a prey archetype's AttackingState, so everything that sends an NPC into a fight sends prey into flight instead: being hit (OnThreatReceived), a herd-mate's alarm (the spawner's pack, NPCGroup.AlertGroup) and its own search noticing a threat (WildlifeRules.Notices).
Structs
- AICombatContext
Everything the shared combat decision needs, as plain numbers.
- AICombatPlan
The decision produced from an AICombatContext.
- AIKiteBudget
Limits how long an NPC may keep backing away from its target before it has to stand and fight.
- AIRetreatBudget
The memory a retreating NPC needs to stop retreating: how long it has been running, how many times it has run during this fight, and whether it has committed to fighting instead.
- AIRetreatContext
Everything Decide(in AIRetreatContext) needs to reach an outcome.
- AIStateClock
Schedules a state's updates and reports how much time each one covers.
- AISwimRiskInput
The facts a chase across water is decided on.
- NPCGroupMember
One brain in an NPCGroup, and the role it plays there.
- PetSupport.Choice
One support cast a pet has decided on.
Enums
- AIAimPoint
The point on a target's body an NPC aims at.
- AICombatIntent
What an NPC has decided to do about its current target this combat tick. Produced by Plan(in AICombatContext) and executed by BaseAttackingState.
- AILodTier
AI Level-of-Detail tiers. Determines how frequently an NPC's brain ticks based on its proximity to the nearest player observer.
- AIMovementProgress
How an NPC is faring against its current destination.
- AIMovementResult
Outcome of asking an NPC to move somewhere.
- AINodeResult
Result of a behavior tree node evaluation.
- AIRetreatOutcome
What a retreating NPC should do next.
- AIRotationMode
Determines how the rotation evaluates its entries.
- AISwimMode
How a swimming NPC goes through water.
- AITargetingMode
How an NPC picks which enemy to hit when several are available. Supplied by TargetingMode and consumed by PickTarget(AIController, List<ICharacter>).
- AbilityCategory
Ability category inferred at runtime from an ability's template data. Used by AICombatPersonality to apply personality weights.
- AgentAvoidancePriority
Defines avoidance priority levels for AI agents. Higher values cause agents to avoid others more aggressively. Used to control how strongly an agent tries to avoid collisions with other agents in the navigation system.
- ComparisonOperator
Comparison operators for numeric condition evaluation.
- ConditionSubject
Determines which character a condition evaluates against.
- NPCCombatStyle
Combat style archetype that broadly describes how the NPC approaches combat. Designers pick a style per personality asset; the AICombatPersonality weights then fine-tune the behaviour.
- NPCGroupRole
Roles that NPCs can play within an NPCGroup, authored per spawner entry (
NPCSpawnableSettings.PackRole).
- PackTactic
How an NPCGroup arranges the members fighting its focus. Each such member is given a bearing around the focus (PackSlotAngle), which OrbitState steers to on the pack's TacticOrbitRadius.
- PetSupport.Kind
What a support choice does.
- PetSupport.Step
What Plan(AIController, LayerMask, bool, out Choice) decided to do this tick.
- WaterVerdict
What an NPC chasing something across water decides to do.