entity

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DirectionVector

func DirectionVector(e world.Entity) mgl64.Vec3

DirectionVector returns a vector that describes the direction of the entity passed. The length of the Vec3 returned is always 1.

func EyePosition

func EyePosition(e world.Entity) mgl64.Vec3

EyePosition returns the position of the eyes of the entity if the entity implements entity.Eyed, or the actual position if it doesn't.

func Facing

func Facing(e world.Entity) world.Direction

Facing returns the horizontal direction that an entity is facing.

func TargetBlock

func TargetBlock(e world.Entity, maxDistance float64) world.BlockPos

TargetBlock finds the target block of the entity passed. The block position returned will be at most maxDistance away from the entity. If no block can be found there, the block position returned will be that of an air block.

Types

type Effect added in v0.0.2

type Effect interface {
	// Instant checks if the effect is instance. If it is instant, the effect will only be ticked a single
	// time when added to an entity.
	Instant() bool
	// Apply applies the effect to an entity. For instant effects, this method applies the effect once, such
	// as healing the Living entity for instant health.
	Apply(e Living)
	// Level returns the level of the effect. A higher level generally means a more powerful effect.
	Level() int
	// Duration returns the leftover duration of the effect.
	Duration() time.Duration
	// WithDuration returns the effect with a duration passed.
	WithDuration(d time.Duration) Effect
	// RGBA returns the colour of the effect. If multiple effects are present, the colours will be mixed
	// together to form a new colour.
	RGBA() color.RGBA
	// ShowParticles checks if the particle should show particles. If not, entities that have the effect
	// will not display particles around them.
	ShowParticles() bool
	// AmbientSource specifies if the effect came from an ambient source, such as a beacon or conduit. The
	// particles will be less visible when this is true.
	AmbientSource() bool
	// Start is called for lasting events. It is sent the first time the effect is applied to an entity.
	Start(e Living)
	// End is called for lasting events. It is sent the moment the effect expires.
	End(e Living)
}

Effect represents an effect that may be added to a living entity. Effects may either be instant or last for a specific duration.

type EffectManager added in v0.0.2

type EffectManager struct {
	// contains filtered or unexported fields
}

EffectManager manages the effects of an entity. The effect manager will only store effects that last for a specific duration. Instant effects are applied instantly and not stored.

func NewEffectManager added in v0.0.2

func NewEffectManager() *EffectManager

NewEffectManager creates and returns a new initialised EffectManager.

func (*EffectManager) Add added in v0.0.2

func (m *EffectManager) Add(e Effect, entity Living)

Add adds an effect to the manager. If the effect is instant, it is applied to the Living entity passed immediately. If not, the effect is added to the EffectManager and is applied to the entity every time the Tick method is called. Effect levels of 0 or below will not do anything.

func (*EffectManager) Effects added in v0.0.2

func (m *EffectManager) Effects() []Effect

Effects returns a list of all effects currently present in the effect manager. This will never include effects that have expired.

func (*EffectManager) Remove added in v0.0.2

func (m *EffectManager) Remove(e Effect, entity Living)

Remove removes any Effect present in the EffectManager with the type of the effect passed.

func (*EffectManager) Tick added in v0.0.2

func (m *EffectManager) Tick(entity Living)

Tick ticks the EffectManager, applying all of its effects to the Living entity passed when applicable and removing expired effects.

type Eyed

type Eyed interface {
	// EyeHeight returns the offset from their base position that the eyes of an entity are found at.
	EyeHeight() float64
}

Eyed represents an entity that has eyes.

type Item

type Item struct {
	// contains filtered or unexported fields
}

Item represents an item entity which may be added to the world. Players and several humanoid entities such as zombies are able to pick up these entities so that the items are added to their inventory.

func NewItem

func NewItem(i item.Stack, pos mgl64.Vec3) *Item

NewItem creates a new item entity using the item stack passed. The item entity will be positioned at the position passed. If the stack's count exceeds its max count, the count of the stack will be changed to the maximum.

func (*Item) AABB

func (it *Item) AABB() physics.AABB

AABB ...

func (*Item) Close

func (it *Item) Close() error

Close closes the item, removing it from the world that it is currently in.

func (*Item) Item

func (it *Item) Item() item.Stack

Item returns the item stack that the item entity holds.

func (Item) OnGround

func (c Item) OnGround() bool

OnGround checks if the entity that this computer calculates is currently on the ground.

func (*Item) Pitch

func (it *Item) Pitch() float64

Pitch always returns 0.

func (*Item) Position

func (it *Item) Position() mgl64.Vec3

Position returns the current position of the item entity.

func (*Item) SetVelocity

func (it *Item) SetVelocity(v mgl64.Vec3)

SetVelocity sets the velocity of the item entity. The values in the Vec3 passed represent the speed on that axis in blocks/tick.

func (*Item) State

func (it *Item) State() []state.State

State ...

func (*Item) Tick

func (it *Item) Tick(current int64)

Tick ticks the entity, performing movement.

func (*Item) Velocity

func (it *Item) Velocity() mgl64.Vec3

Velocity returns the current velocity of the item. The values in the Vec3 returned represent the speed on that axis in blocks/tick.

func (*Item) World

func (it *Item) World() *world.World

World returns the world that the item entity is currently in, or nil if it is not added to a world.

func (*Item) Yaw

func (it *Item) Yaw() float64

Yaw always returns 0.

type Living

type Living interface {
	world.Entity
	// Health returns the health of the entity.
	Health() float64
	// MaxHealth returns the maximum health of the entity.
	MaxHealth() float64
	// SetMaxHealth changes the maximum health of the entity to the value passed.
	SetMaxHealth(v float64)
	// AttackImmune checks if the entity is currently immune to entity attacks. Entities typically turn
	// immune for half a second after being attacked.
	AttackImmune() bool
	// Hurt hurts the entity for a given amount of damage. The source passed represents the cause of the
	// damage, for example damage.SourceEntityAttack if the entity is attacked by another entity.
	// If the final damage exceeds the health that the player currently has, the entity is killed.
	Hurt(damage float64, source damage.Source)
	// Heal heals the entity for a given amount of health. The source passed represents the cause of the
	// healing, for example healing.SourceFood if the entity healed by having a full food bar. If the health
	// added to the original health exceeds the entity's max health, Heal may not add the full amount.
	Heal(health float64, source healing.Source)
	// KnockBack knocks the entity back with a given force and height. A source is passed which indicates the
	// source of the velocity, typically the position of an attacking entity. The source is used to calculate
	// the direction which the entity should be knocked back in.
	KnockBack(src mgl64.Vec3, force, height float64)
	// Speed returns the current speed of the living entity. The default value is different for each entity.
	Speed() float64
	// SetSpeed sets the speed of an entity to a new value.
	SetSpeed(float64)
}

Living represents an entity that is alive and that has health. It is able to take damage and will die upon taking fatal damage.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL