Class ReturnHomeState
- Namespace
- FishMMO.Server.Implementation.World.SceneServer.AI
- Assembly
- FishMMO.Server.dll
AI State for returning the NPC to its home position. Handles healing and movement speed adjustments.
[CreateAssetMenu(fileName = "New AI ReturnHome State", menuName = "FishMMO/Character/NPC/AI/ReturnHome State", order = 0)]
public class ReturnHomeState : BaseAIState, ICachedObject
- Inheritance
-
ObjectScriptableObjectReturnHomeState
- Implements
- Inherited Members
-
ScriptableObject.SetDirty()ScriptableObject.CreateInstance<T>()Object.GetEntityId()Object.MemberwiseClone()Object.GetInstanceID()Object.GetHashCode()Object.InstantiateAsync<T>(T)Object.InstantiateAsync<T>(T, Transform)Object.InstantiateAsync<T>(T, Vector3, Quaternion)Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion, Transform)Object.Instantiate(Object)Object.Instantiate(Object, Scene)Object.Instantiate<T>(T, InstantiateParameters)Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)Object.Instantiate(Object, Transform)Object.Instantiate<T>(T)Object.Instantiate<T>(T, Vector3, Quaternion)Object.Instantiate<T>(T, Vector3, Quaternion, Transform)Object.Instantiate<T>(T, Transform)Object.Destroy(Object)Object.DestroyImmediate(Object)Object.DontDestroyOnLoad(Object)Object.DestroyObject(Object)Object.FindObjectsOfType<T>()Object.FindObjectsByType<T>(FindObjectsSortMode)Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)Object.FindObjectOfType<T>()Object.FindFirstObjectByType<T>()Object.FindAnyObjectByType<T>()Object.FindFirstObjectByType<T>(FindObjectsInactive)Object.FindAnyObjectByType<T>(FindObjectsInactive)Object.FindObjectsByType<T>()Object.FindObjectsByType<T>(FindObjectsInactive)Object.ToString()Object.nameObject.hideFlags
Remarks
Two uses. The leash sends a fighting NPC home through this state, and it is also one of the calm movement states TransitionToRandomMovementState() drifts between. Only the first is an evade: while a leash that ended a fight has the NPC walking home it takes no damage, threat, taunt, debuff or knockback (IsEvading, CharacterEvade). The evade is held by the controller, not by this shared asset, and ends by construction the moment this state stops being the NPC's current state — there is nothing here to switch off.
The heal belongs to the leash, too. CompleteHealOnReturn is authored here but applied by AIController's leash check, which is the only thing that knows a leash — not a calm pick — sent the NPC home. It used to be applied by Enter(AIController), and since this state is also in the calm movement pool, a damaged NPC that simply drifted home between fights was topped up to full on the way.
Fields
CompleteHealOnReturn
If true, the NPC is fully healed when a LEASH sends it home through this state. A calm stroll home picked from the movement pool never heals. Applied by AIController (see the class remarks).
[Tooltip("Fully heal the NPC when a leash sends it home. A calm stroll home never heals.")]
public bool CompleteHealOnReturn
Field Value
HomeArrivalRadius
How close to home counts as home. Also the fallback scatter radius when home itself cannot be sampled onto the NavMesh.
[Tooltip("Distance from home that counts as arriving.")]
public float HomeArrivalRadius
Field Value
Methods
Enter(AIController)
Called when the state is entered. Sets the NPC's destination to home and increases speed. Does not heal: see the class remarks.
public override void Enter(AIController controller)
Parameters
controllerAIControllerThe AI controller managing this NPC.
Exit(AIController)
Called when the state is exited. Resets movement speed.
public override void Exit(AIController controller)
Parameters
controllerAIControllerThe AI controller managing this NPC.
UpdateState(AIController, float)
Called every frame while in this state. Checks if the NPC has reached its home destination and transitions to random movement.
public override void UpdateState(AIController controller, float deltaTime)
Parameters
controllerAIControllerThe AI controller managing this NPC.
deltaTimefloatTime since last update.