Class Role

java.lang.Object
com.hypixel.hytale.server.npc.role.Role
All Implemented Interfaces:
IAnnotatedComponent, IAnnotatedComponentCollection

public class Role extends Object implements IAnnotatedComponentCollection
  • Field Details

    • DEBUG_APPLIED_FORCES

      public static final boolean DEBUG_APPLIED_FORCES
      See Also:
    • INTERACTION_PLAYER_DISTANCE

      public static final double INTERACTION_PLAYER_DISTANCE
      See Also:
    • RANDOMIZE_OFFSET_MAX_DISTANCE

      public static final double RANDOMIZE_OFFSET_MAX_DISTANCE
      See Also:
    • RANDOMIZE_OFFSET_SQUARED_MAX_DISTANCE

      public static final double RANDOMIZE_OFFSET_SQUARED_MAX_DISTANCE
      See Also:
  • Method Details

    • createAndAttach

      @Nonnull public static Role createAndAttach(@Nonnull Holder<EntityStore> holder, @Nonnull BuilderRole builder, @Nonnull BuilderSupport builderSupport)
      Primary entry point for building a Role for an ECS-attached NPC entity.
    • getInitialMaxHealth

      public int getInitialMaxHealth()
    • isAvoidingEntities

      public boolean isAvoidingEntities()
    • getCollisionProbeDistance

      public double getCollisionProbeDistance()
    • isApplySeparation

      public boolean isApplySeparation()
    • getSeparationDistance

      public double getSeparationDistance()
    • getRootInstruction

      public Instruction getRootInstruction()
    • getInteractionInstruction

      @Nullable public Instruction getInteractionInstruction()
    • getDeathInstruction

      @Nullable public Instruction getDeathInstruction()
    • getBodySteering

      @Nonnull public Steering getBodySteering()
    • getHeadSteering

      @Nonnull public Steering getHeadSteering()
    • getIgnoredEntitiesForAvoidance

      @Nonnull public Set<Ref<EntityStore>> getIgnoredEntitiesForAvoidance()
    • getDropListId

      public String getDropListId()
    • getBalanceAsset

      @Nullable public String getBalanceAsset()
    • getInteractionVars

      @Nullable public Map<String,String> getInteractionVars()
    • isMemory

      public boolean isMemory()
    • getMemoriesNameOverride

      public String getMemoriesNameOverride()
    • getNameTranslationKey

      public String getNameTranslationKey()
    • isMemoriesNameOverriden

      public boolean isMemoriesNameOverriden()
    • getMemoriesUnlockedBy

      public Role.MemoriesUnlockMethod getMemoriesUnlockedBy()
    • getMemoriesKillRange

      public double getMemoriesKillRange()
      0 or less means this role sets no range of its own.
    • getSpawnLockTime

      public float getSpawnLockTime()
    • postRoleBuilt

      public void postRoleBuilt(@Nonnull Holder<EntityStore> holder, @Nonnull BuilderSupport builderSupport)
    • acquireExecutionSupport

      @Nonnull public ExecutionSupport acquireExecutionSupport(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> accessor)
      Acquire the per-thread ExecutionSupport and populate it from the ECS-attached supports for this Role's entity. Caller must invoke ExecutionSupport.clearForReuse() in a finally block after use.
    • loaded

      public void loaded(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> accessor)
      Called after NPC was created using readFromBson and was added to World.
    • spawned

      public void spawned(@Nonnull Holder<EntityStore> holder, @Nonnull NPCEntity npcComponent, @Nonnull Store<EntityStore> store)
      Called after NPC was spawned and was added to World.
      Parameters:
      holder - The holder of the NPC entity.
      npcComponent - The NPC component of the entity.
      store - The store to use for event dispatch during initialisation.
    • unloaded

      public void unloaded(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> accessor)
    • removed

      public void removed(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> accessor)
    • teleported

      public void teleported(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> accessor, @Nonnull World from, @Nonnull World to)
    • getAppearanceName

      public String getAppearanceName()
    • getActiveMotionController

      public MotionController getActiveMotionController()
    • isRoleChangeRequested

      public boolean isRoleChangeRequested()
    • setRoleChangeRequested

      public void setRoleChangeRequested()
    • setActiveMotionController

      public boolean setActiveMotionController(@Nonnull Ref<EntityStore> ref, @Nonnull NPCEntity npcComponent, @Nonnull String name, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Called to set the active motion controller based on the given name
      Parameters:
      ref - The entity reference of the NPC
      npcComponent - The NPC component of the NPC entity
      name - The name of the motion controller to set
      componentAccessor - The component store for component access
      Returns:
      true if it was set successfully, false otherwise
    • setActiveMotionController

      public void setActiveMotionController(@Nonnull Ref<EntityStore> ref, @Nonnull NPCEntity npcComponent, @Nonnull MotionController motionController, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Called to set the given motion controller as the active motion controller
      Parameters:
      ref - The entity reference of the NPC
      npcComponent - The NPC component of the NPC entity
      motionController - The MotionController instance to set as active
      componentAccessor - The component store for component access
    • hasMotionController

      public boolean hasMotionController(@Nonnull String name)
      Checks if a role has a specific motion controller
      Parameters:
      name - Name of motion controller
      Returns:
      true if motion controller exists else false
    • preInitMotionControllers

      public void preInitMotionControllers(@Nonnull DebugSupport debugSupport, @Nonnull Map<String, MotionController> motionControllers, @Nullable String initialMotionController)
    • activateInitialMotionController

      public void activateInitialMotionController(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> accessor, @Nonnull NPCEntity npcComponent)
    • updateMotionControllers

      public void updateMotionControllers(@Nullable Ref<EntityStore> ref, @Nullable Model model, @Nullable Box boundingBox, @Nullable ComponentAccessor<EntityStore> componentAccessor)
      Called to update each motion controller of this role
      Parameters:
      ref - The entity reference of the NPC, if available
      model - The associated model of the NPC
      boundingBox - The bounding box of the NPC
      componentAccessor - The component accessor for component access, if available
    • updateMovementState

      public void updateMovementState(@Nonnull Ref<EntityStore> ref, @Nonnull MovementStates movementStates, @Nonnull org.joml.Vector3d velocity, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Called to update the current active movement controller
      Parameters:
      ref - The entity reference of the NPC entity
      movementStates - The movement states available
      velocity - The current velocity of the NPC
      componentAccessor - The component accessor for component access
    • tick

      public void tick(@Nonnull Ref<EntityStore> ref, float tickTime, @Nonnull Store<EntityStore> store)
      Called to tick and update this role for the associated NPC entity
      Parameters:
      ref - The entity reference of the affiliated NPC entity
      tickTime - The current tick time
      store - The affiliated entity store for component access
    • blendSeparation

      public void blendSeparation(@Nonnull Ref<EntityStore> selfRef, @Nonnull org.joml.Vector3d position, @Nonnull Rotation3f rotation, @Nonnull Steering steering, @Nonnull ComponentType<EntityStore, TransformComponent> transformComponentType, @Nonnull CommandBuffer<EntityStore> commandBuffer)
    • getLastSeparationSteering

      @Nonnull public org.joml.Vector3d getLastSeparationSteering()
    • blendAvoidance

      public void blendAvoidance(@Nonnull Ref<EntityStore> ref, @Nonnull org.joml.Vector3d position, @Nonnull Rotation3f rotation, @Nonnull Steering steering, @Nonnull CommandBuffer<EntityStore> commandBuffer)
    • getLastAvoidanceSteering

      @Nonnull public org.joml.Vector3d getLastAvoidanceSteering()
    • getRoleName

      public String getRoleName()
    • getRoleIndex

      public int getRoleIndex()
    • setRoleIndex

      public void setRoleIndex(@Nonnull Holder<EntityStore> holder, int roleIndex, @Nonnull String roleName)
    • isInvulnerable

      public boolean isInvulnerable()
    • isIgnoreDisableNPCIncomingDamage

      public boolean isIgnoreDisableNPCIncomingDamage()
    • isBreathesInAir

      public boolean isBreathesInAir()
    • isBreathesInWater

      public boolean isBreathesInWater()
    • getInertia

      public double getInertia()
    • getKnockbackScale

      public double getKnockbackScale()
    • canBreathe

      public boolean canBreathe(@Nonnull BlockMaterial breathingMaterial, int fluidId)
    • couldBreathe

      public boolean couldBreathe(@Nonnull BlockMaterial breathingMaterial, int fluidId)
    • couldBreatheCached

      public boolean couldBreatheCached(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> accessor)
    • setVelocity

      public void setVelocity(@Nonnull org.joml.Vector3d velocity, @Nullable VelocityConfig velocityConfig, boolean ignoreDamping)
    • processAddVelocityInstruction

      public void processAddVelocityInstruction(@Nonnull org.joml.Vector3d velocity, @Nullable VelocityConfig velocityConfig, float preMultiplier)
    • processSetVelocityInstruction

      public void processSetVelocityInstruction(@Nonnull org.joml.Vector3d velocity, @Nullable VelocityConfig velocityConfig, float preMultiplier)
    • isOnGround

      public boolean isOnGround()
    • setArmor

      public void setArmor(@Nonnull NPCEntity npcComponent, @Nullable String[] armor)
    • isPickupDropOnDeath

      public boolean isPickupDropOnDeath()
    • requiresLeashPosition

      public boolean requiresLeashPosition()
    • clearOnce

      public void clearOnce(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> accessor)
    • clearOnceIfNeeded

      public void clearOnceIfNeeded(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> accessor)
    • setMarkedTarget

      public void setMarkedTarget(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> accessor, @Nonnull String targetSlot, @Nonnull Ref<EntityStore> target)
    • isIgnoredForAvoidance

      public boolean isIgnoredForAvoidance(@Nonnull Ref<EntityStore> entityReference)
    • getAvoidanceMode

      public Role.AvoidanceMode getAvoidanceMode()
    • getCollisionRadius

      public double getCollisionRadius()
    • getFlockSpawnTypes

      public int[] getFlockSpawnTypes()
    • getFlockAllowedRoles

      @Nonnull public String[] getFlockAllowedRoles()
    • isFlockSpawnTypesRandom

      public boolean isFlockSpawnTypesRandom()
    • isCanLeadFlock

      public boolean isCanLeadFlock()
    • getFlockInfluenceRange

      public double getFlockInfluenceRange()
    • getDeathAnimationTime

      public double getDeathAnimationTime()
    • getDeathParticles

      @Nullable public String getDeathParticles()
    • isDropDeathItemsInstantly

      public boolean isDropDeathItemsInstantly()
    • hasDroppedDeathItems

      public boolean hasDroppedDeathItems()
    • setDeathItemsDropped

      public void setDeathItemsDropped()
    • getDeathInteraction

      @Nullable public String getDeathInteraction()
    • getDespawnAnimationTime

      public float getDespawnAnimationTime()
    • setReachedTerminalAction

      public void setReachedTerminalAction(boolean hasReached)
    • hasReachedTerminalAction

      public boolean hasReachedTerminalAction()
    • isBackingAway

      public boolean isBackingAway()
    • setBackingAway

      public void setBackingAway(boolean backingAway)
    • getSteeringMotionName

      @Nullable public String getSteeringMotionName()
    • getLastBodySteeringMotion

      @Nullable public BodyMotion getLastBodySteeringMotion()
    • getSteeringRelaxedConstraints

      @Nullable public EnumSet<RelaxedConstraint> getSteeringRelaxedConstraints()
    • componentCount

      public int componentCount()
      Description copied from interface: IAnnotatedComponentCollection
      Returns the number of components aggregated
      Specified by:
      componentCount in interface IAnnotatedComponentCollection
      Returns:
      the number of components aggregated
    • getComponent

      public IAnnotatedComponent getComponent(int index)
      Description copied from interface: IAnnotatedComponentCollection
      Returns the annotated component at the given index, or null if the component at said index is not annotated
      Specified by:
      getComponent in interface IAnnotatedComponentCollection
      Parameters:
      index - the index to fetch
      Returns:
      the annotated component, or null if the component at the index is not annotated
    • getInfo

      public void getInfo(ExecutionSupport executionSupport, ComponentInfo holder)
      Description copied from interface: IAnnotatedComponent
      Populates the ComponentInfo holder with any relevant information relating to this particular component
      Specified by:
      getInfo in interface IAnnotatedComponent
      Parameters:
      executionSupport - per-execution context
      holder - the ComponentInfo instance to populate
    • getIndex

      public int getIndex()
      Specified by:
      getIndex in interface IAnnotatedComponent
    • setContext

      public void setContext(IAnnotatedComponent parent, int index)
      Specified by:
      setContext in interface IAnnotatedComponent
    • getParent

      @Nullable public IAnnotatedComponent getParent()
      Specified by:
      getParent in interface IAnnotatedComponent
    • getLabel

      public String getLabel()
      Specified by:
      getLabel in interface IAnnotatedComponent
    • isCorpseStaysInFlock

      public boolean isCorpseStaysInFlock()
    • onLoadFromWorldGenOrPrefab

      public void onLoadFromWorldGenOrPrefab(@Nonnull Ref<EntityStore> ref, @Nonnull NPCEntity npcComponent, @Nonnull ComponentAccessor<EntityStore> componentAccessor)