Hatch Game Engine Documentation v1.4.0
The documentation for the Hatch Game Engine
Loading...
Searching...
No Matches
Entity Class Reference

A game object that can be spawned in a scene. More...

Public Member Functions

void SetAnimation (integer animation, integer frame)
 Changes the current animation of the entity, if the animation index differs from the entity's current animation index.
void ResetAnimation (integer animation, integer frame)
 Changes the current animation of the entity.
void Animate ()
 Animates the entity.
integer GetUpdatePriority ()
 Gets the update priority of the entity.
void SetUpdatePriority (integer priority)
 Sets the update priority of the entity.
integer GetIDWithinClass ()
 Gets the ordered ID of the entity amongst other entities of the same type.
void AddToRegistry (string registry)
 Adds the entity to a registry.
boolean IsInRegistry (string registry)
 Checks if the entity is in a registry.
void RemoveFromRegistry (string registry)
 Removes the entity from a registry.
void ApplyMotion ()
 Applies gravity and velocities to the entity.
boolean InView (integer viewIndex, decimal x, decimal y, decimal w, decimal h)
 Checks if the specified positions and ranges are within the specified view.
Entity CollidedWithObject (Entity other)
 Checks if the entity collided with another entity, or any entity of the specified class name.
Entity CollidedWithObject (string other)
 Checks if the entity collided with another entity, or any entity of the specified class name.
void GetHitboxFromSprite (integer sprite, integer animation, integer frame, string hitbox)
 Updates the entity's hitbox with the hitbox in the specified sprite's animation, frame and hitbox ID or name.
hitbox ReturnHitbox (integer sprite, integer animationID, integer frameID, string hitbox)
 Gets the hitbox of a sprite frame.
hitbox ReturnHitbox (integer sprite, integer animationID, integer frameID, integer hitbox)
 Gets the hitbox of a sprite frame.
boolean CollideWithObject (Entity other)
 Does collision with another entity.
boolean SolidCollideWithObject (Entity other)
 Does solid collision with another entity.
boolean TopSolidCollideWithObject (Entity other)
 Does solid collision with another entity's top.
boolean PropertyExists (string property)
 Checks if a property exists in the entity.
value PropertyGet (string property)
 Gets a property exists from the entity.
void SetViewVisibility (integer viewIndex, boolean visible)
 Sets whether the entity is visible on a specific view.
void SetViewOverride (integer viewIndex, boolean visible)
 Toggles the bypass for each view's entity rendering toggle set by Scene.SetObjectViewRender.
void AddToDrawGroup (integer drawGroup)
 Adds the entity into the specified draw group.
boolean IsInDrawGroup (integer drawGroup)
 Checks if the entity is in the specified draw group.
void RemoveFromDrawGroup (integer drawGroup)
 Removes the entity from the specified draw group.
integer PlaySound (integer sound, decimal panning=0.0, decimal speed=1.0, decimal volume=1.0)
 Plays a sound once from the entity.
integer LoopSound (integer sound, integer loopPoint, decimal panning=0.0, decimal speed=1.0, decimal volume=1.0)
 Plays a sound from the entity, looping back when it ends.
void StopSound (integer sound)
 Stops a specific sound that is being played from the entity.
void StopAllSounds ()
 Stops all sounds the entity is playing.

Public Attributes

decimal X = 0.0
 The X position of the entity.
decimal Y = 0.0
 The Y position of the entity.
decimal Z = 0.0
 The Z position of the entity.
decimal SpeedX = 0.0
 The horizontal velocity of the entity.
decimal SpeedY = 0.0
 The vertical velocity of the entity.
decimal XSpeed = 0.0
 Alias for Entity.SpeedX.
decimal YSpeed = 0.0
 Alias for Entity.SpeedY.
decimal GroundSpeed = 0.0
 The speed of the entity on the ground.
decimal GravitySpeed = 0.0
 The gravity rate of the entity.
decimal Gravity = 0.0
 Alias for Entity.GravitySpeed.
boolean AutoPhysics = false
 Whether Entity.ApplyMotion is automatically called for this entity.
integer Angle = 0
 The angle of the entity on the ground, within the range of 0x00 - 0xFF.
integer AngleMode = 0
 The angle mode of the entity on the ground, within the range of 0 - 3.
boolean OnGround = false
 Whether the entity is on the ground.
boolean Ground = false
 Alias for Entity.OnGround.
decimal ScaleX = 1.0
 Used by Draw.SpriteBasic for scaling the entity's sprite horizontally.
decimal ScaleY = 1.0
 Used by Draw.SpriteBasic for scaling the entity's sprite vertically.
decimal Rotation = 0.0
 Used by Draw.SpriteBasic for rotating the entity's sprite. See Entity.RotationStyle.
decimal Alpha = 0.0
 A field that may be used in Entity.Render for changing the opacity of a sprite.
integer BlendMode = BlendMode_NORMAL
 A field that may be used in Entity.Render for changing the BlendMode of a sprite.
integer Priority = 0
 The priority, or draw group, where this entity is located.
decimal Depth = 0.0
 The depth of the entity. Used for sorting entity draw order.
integer Sprite = -1
 The sprite index of the entity.
integer CurrentAnimation = -1
 The current sprite animation index of the entity.
integer CurrentFrame = -1
 The current frame index of the entity's current animation.
integer CurrentFrameCount = -1
 The frame count of the entity's current animation.
decimal AnimationSpeed = 0.0
 The animation speed of the entity's animation.
decimal AnimationTimer = 0.0
 The animation timer of the entity's animation.
integer AnimationFrameDuration = 0
 The duration of the entity's current animation frame.
integer AnimationLoopIndex = 0
 The loop index of entity's current animation.
ROTSTYLE RotationStyle = ROTSTYLE_NONE
 The rotation style to use when this entity's sprite is drawn by Draw.SpriteBasic.
decimal AnimationSpeedMult = 1.0
 The animation speed multiplier of the entity.
integer AnimationSpeedAdd = 0
 This value is added to the result of Entity.AnimationSpeed * Entity.AnimationSpeedMult when the entity is being animated.
integer PrevAnimation = -1
 The previous sprite animation index of the entity, if it was changed.
boolean AutoAnimate = true
 Whether Entity.Animate is automatically called for this entity.
boolean OnScreen = true
 See Entity.InRange.
boolean WasOffScreen = false
 Indicates if the entity was previously off-screen.
decimal UpdateRegionW = 0.0
 The horizontal on-screen range where the entity can update. If this is set to 0.0, the entity will update regardless of the camera's horizontal position.
decimal UpdateRegionH = 0.0
 The vertical on-screen range where the entity can update. If this is set to 0.0, the entity will update regardless of the camera's vertical position.
decimal UpdateRegionTop = 0.0
 The top on-screen range where the entity can update. If set to 0.0, the entity will use its Entity.UpdateRegionH instead.
decimal UpdateRegionLeft = 0.0
 The left on-screen range where the entity can update. If set to 0.0, the entity will use its Entity.UpdateRegionW instead.
decimal UpdateRegionRight = 0.0
 The left on-screen range where the entity can update. If set to 0.0, the entity will use its Entity.UpdateRegionW instead.
decimal UpdateRegionBottom = 0.0
 The bottom on-screen range where the entity can update. If set to 0.0, the entity will use its Entity.UpdateRegionH instead.
decimal OnScreenHitboxW = 0.0
 Alias for Entity.UpdateRegionW.
decimal OnScreenHitboxH = 0.0
 Alias for Entity.UpdateRegionH.
decimal RenderRegionW = 0.0
 The horizontal on-screen range where the entity can render. If set to 0.0, the entity will render regardless of the camera's horizontal position.
decimal RenderRegionH = 0.0
 The vertical on-screen range where the entity can render. If set to 0.0, the entity will render regardless of the camera's vertical position.
decimal RenderRegionTop = 0.0
 The top on-screen range where the entity can render. If set to 0.0, the entity will use its Entity.RenderRegionH instead.
decimal RenderRegionLeft = 0.0
 The left on-screen range where the entity can render. If this and Entity.RenderRegionRight are set to 0.0, the entity will use its Entity.RenderRegionW instead.
decimal RenderRegionRight = 0.0
 The right on-screen range where the entity can render. If this and Entity.RenderRegionLeft are set to 0.0, the entity will use its Entity.RenderRegionW instead.
decimal RenderRegionBottom = 0.0
 The bottom on-screen range where the entity can render. If set to 0.0, the entity will use its Entity.RenderRegionH instead.
boolean Visible = true
 Whether the entity is visible.
bitfield ViewRenderFlag = 0xFFFFFFFF
 Which views the entity can render on. By default, this is on for every view.
bitfield ViewOverrideFlag = 0
 Bypasses each view's entity rendering toggle set by Scene.SetObjectViewRender.
decimal HitboxW = 0.0
 The width of the hitbox.
decimal HitboxH = 0.0
 The height of the hitbox.
decimal HitboxOffX = 0.0
 The horizontal offset of the hitbox.
decimal HitboxOffY = 0.0
 The vertical offset of the hitbox.
decimal HitboxLeft = 0.0
 The left extent of the hitbox.
decimal HitboxTop = 0.0
 The top extent of the hitbox.
decimal HitboxRight = 0.0
 The right extent of the hitbox.
decimal HitboxBottom = 0.0
 The bottom extent of the hitbox.
FLIP Direction = FLIP_NONE
 Indicates whether the entity is X/Y flipped.
FLIP FlipFlag = FLIP_NONE
 Alias for Entity.Direction.
integer SlotID = -1
 If this entity was spawned from a scene file, this field contains the slot ID in which it was placed. If not, this field contains the default value of -1.
integer Filter = 0xFF
 If there is a scene list loaded, this checks to see whether the entity would spawn based on the scene's filter. See Scene_Filter.
bitfield CollisionLayers = 0
 Which layers the entity is able to collide with.
integer CollisionPlane = 0
 The collision plane of the entity.
CMODE CollisionMode = CMODE_FLOOR
 The tile collision mode of the entity.
TILECOLLISION TileCollisions = TILECOLLISION_NONE
 The direction of tile collisions for this entity.
ACTIVE Activity = ACTIVE_BOUNDS
 The active status for this entity.
boolean InRange = false
 Whether this entity is within active range; see Entity.Activity.
decimal SensorX = 0.0
 After a successful call to TileCollision.Line, this value will contain the horizontal position of where the entity collided.
decimal SensorY = 0.0
 After a successful call to TileCollision.Line, this value will contain the vertical position of where the entity collided.
boolean SensorCollided = 0
 After a successful call to TileCollision.Line, this value will be true if the entity collided with a tile, false otherwise.
integer SensorAngle = 0
 After a successful call to TileCollision.Line, this value will contain the angle of the tile within the range of 0x00 - 0xFF.
boolean Active = true
 Whether the entity is active. If set to false, the entity is removed at the end of the frame.
boolean Pauseable = true
 Whether the entity stops updating when the scene is paused.
boolean Persistent = false
boolean Interactable = true
 Whether the entity can be interacted with. If set to false, the entity will not be included in with iterations.
Persistence Persistence = Persistence_NONE
 Whether the entity persists between scenes.

Detailed Description

A game object that can be spawned in a scene.

All spawned entities inherit from this class. Entities must be spawned with Instance.Create.

Member Function Documentation

◆ AddToDrawGroup()

void Entity.AddToDrawGroup ( integer drawGroup)

Adds the entity into the specified draw group.

Parameters
drawGroupThe draw group.

◆ AddToRegistry()

void Entity.AddToRegistry ( string registry)

Adds the entity to a registry.

Parameters
registryThe registry name.

◆ CollidedWithObject() [1/2]

Entity Entity.CollidedWithObject ( Entity other)

Checks if the entity collided with another entity, or any entity of the specified class name.

Parameters
otherThe entity to collide with.
Returns
Returns the entity that was collided with, or null if it did not collide with any entity.

◆ CollidedWithObject() [2/2]

Entity Entity.CollidedWithObject ( string other)

Checks if the entity collided with another entity, or any entity of the specified class name.

Parameters
otherThe entity class to collide with.
Returns
Returns the entity that was collided with, or null if it did not collide with any entity.

◆ CollideWithObject()

boolean Entity.CollideWithObject ( Entity other)

Does collision with another entity.

Parameters
otherThe other entity to check collision for.
Returns
Returns whether the entity collided.

◆ GetHitboxFromSprite()

void Entity.GetHitboxFromSprite ( integer sprite,
integer animation,
integer frame,
string hitbox )

Updates the entity's hitbox with the hitbox in the specified sprite's animation, frame and hitbox ID or name.

Parameters
spriteThe sprite.
animationThe animation index.
frameThe frame index.
hitboxThe hitbox name or index. Defaults to 0.

◆ GetIDWithinClass()

integer Entity.GetIDWithinClass ( )

Gets the ordered ID of the entity amongst other entities of the same type.

Returns
Returns an integer value.

◆ GetUpdatePriority()

integer Entity.GetUpdatePriority ( )

Gets the update priority of the entity.

Returns
Returns an integer value.

◆ InView()

boolean Entity.InView ( integer viewIndex,
decimal x,
decimal y,
decimal w,
decimal h )

Checks if the specified positions and ranges are within the specified view.

Parameters
viewIndexThe view index.
xThe X position.
yThe Y position.
wThe width.
hThe height.
Returns
Returns whether the specified positions and ranges are within the specified view.

◆ IsInDrawGroup()

boolean Entity.IsInDrawGroup ( integer drawGroup)

Checks if the entity is in the specified draw group.

Parameters
drawGroupThe draw group.
Returns
Returns whether the entity is in the specified draw group.

◆ IsInRegistry()

boolean Entity.IsInRegistry ( string registry)

Checks if the entity is in a registry.

Parameters
registryThe registry name.
Returns
Returns a boolean value.

◆ LoopSound()

integer Entity.LoopSound ( integer sound,
integer loopPoint,
decimal panning = 0.0,
decimal speed = 1.0,
decimal volume = 1.0 )

Plays a sound from the entity, looping back when it ends.

Parameters
soundThe sound index to play.
loopPointLoop point in samples.
panningControl the panning of the audio. -1.0 makes it sound in left ear only, 1.0 makes it sound in right ear, and closer to 0.0 centers it.
speedControl the speed of the audio. Higher than 1.0 makes it faster, lesser than 1.0 is slower, 1.0 is normal speed.
volumeControls the volume of the audio. 0.0 is muted, 1.0 is normal volume.
Returns
Returns the channel index where the sound began to play, or -1 if no channel was available.

◆ PlaySound()

integer Entity.PlaySound ( integer sound,
decimal panning = 0.0,
decimal speed = 1.0,
decimal volume = 1.0 )

Plays a sound once from the entity.

Parameters
soundThe sound index to play.
panningControl the panning of the audio. -1.0 makes it sound in left ear only, 1.0 makes it sound in right ear, and closer to 0.0 centers it.
speedControl the speed of the audio. Higher than 1.0 makes it faster, lesser than 1.0 is slower, 1.0 is normal speed.
volumeControls the volume of the audio. 0.0 is muted, 1.0 is normal volume.
Returns
Returns the channel index where the sound began to play, or -1 if no channel was available.

◆ PropertyExists()

boolean Entity.PropertyExists ( string property)

Checks if a property exists in the entity.

Parameters
propertyThe property name.
Returns
Returns whether the property exists.

◆ PropertyGet()

value Entity.PropertyGet ( string property)

Gets a property exists from the entity.

Parameters
propertyThe property name.
Returns
Returns the property if it exists, or null if the property does not exist.

◆ RemoveFromDrawGroup()

void Entity.RemoveFromDrawGroup ( integer drawGroup)

Removes the entity from the specified draw group.

Parameters
drawGroupThe draw group.

◆ RemoveFromRegistry()

void Entity.RemoveFromRegistry ( string registry)

Removes the entity from a registry.

Parameters
registryThe registry name.

◆ ResetAnimation()

void Entity.ResetAnimation ( integer animation,
integer frame )

Changes the current animation of the entity.

Parameters
animationThe animation index.
frameThe frame index.

◆ ReturnHitbox() [1/2]

hitbox Entity.ReturnHitbox ( integer sprite,
integer animationID,
integer frameID,
integer hitbox )

Gets the hitbox of a sprite frame.

Parameters
spriteThe sprite index to check.
animationIDThe animation index of the sprite to check.
frameIDThe frame index of the animation to check.
hitboxThe hitbox index. Defaults to 0.
Returns
Returns a hitbox value.

◆ ReturnHitbox() [2/2]

hitbox Entity.ReturnHitbox ( integer sprite,
integer animationID,
integer frameID,
string hitbox )

Gets the hitbox of a sprite frame.

Parameters
spriteThe sprite index to check.
animationIDThe animation index of the sprite to check.
frameIDThe frame index of the animation to check.
hitboxThe hitbox name.
Returns
Returns a hitbox value.

◆ SetAnimation()

void Entity.SetAnimation ( integer animation,
integer frame )

Changes the current animation of the entity, if the animation index differs from the entity's current animation index.

Parameters
animationThe animation index.
frameThe frame index.

◆ SetUpdatePriority()

void Entity.SetUpdatePriority ( integer priority)

Sets the update priority of the entity.

Higher numbers cause entities to be updated sooner, and lower numbers cause entities to be updated later. If multiple entities have the same update priority, they are sorted by spawn order; ascending for positive priority values, and descending for negative priority values.

Parameters
priorityThe priority value.

◆ SetViewOverride()

void Entity.SetViewOverride ( integer viewIndex,
boolean visible )

Toggles the bypass for each view's entity rendering toggle set by Scene.SetObjectViewRender.

Parameters
viewIndexThe view index.
visibleWhether the entity will always be visible or not on the specified view.

◆ SetViewVisibility()

void Entity.SetViewVisibility ( integer viewIndex,
boolean visible )

Sets whether the entity is visible on a specific view.

Parameters
viewIndexThe view index.
visibleWhether the entity will be visible or not on the specified view.

◆ SolidCollideWithObject()

boolean Entity.SolidCollideWithObject ( Entity other)

Does solid collision with another entity.

Parameters
otherThe other entity to check collision for.
Returns
Returns whether the entity collided.

◆ StopSound()

void Entity.StopSound ( integer sound)

Stops a specific sound that is being played from the entity.

Parameters
soundThe sound index to interrupt.

◆ TopSolidCollideWithObject()

boolean Entity.TopSolidCollideWithObject ( Entity other)

Does solid collision with another entity's top.

Parameters
otherThe other entity to check collision for.
Returns
Returns whether the entity collided.

Member Data Documentation

◆ Persistent

boolean Entity.Persistent = false