entity

package
v0.0.0-...-b8d9494 Latest Latest
Warning

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

Go to latest
Published: May 13, 2021 License: BSD-3-Clause Imports: 4 Imported by: 30

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Artifact = ItemCategory{}
View Source
var Common = ItemCategory{}
View Source
var Rare = ItemCategory{}

Functions

func CanStack

func CanStack(source, destination IItem) bool

func CheckColisionBetweenFrames

func CheckColisionBetweenFrames(x1Old, y1Old, z1Old, x1New, y1New, z1New float32, cylinder1 []*Cylinder, x2Old, y2Old, z2Old, x2New, y2New, z2New float32, cylinder2 []*Cylinder) bool

func Distance2D

func Distance2D(v1 *math32.Vector3, v2 *math32.Vector3) float32

func FilterEnemy

func FilterEnemy(v interface{}) bool

func FilterEvil

func FilterEvil(v interface{}) bool

func FilterGood

func FilterGood(v interface{}) bool

func FilterPlayer

func FilterPlayer(v interface{}) bool

func NormalizeAngle

func NormalizeAngle(a float32) float32

func ShortestDistanceBetweenLines

func ShortestDistanceBetweenLines(x1Old, z1Old, x1New, z1New, x2Old, z2Old, x2New, z2New float32) float32

func Stack

func Stack(source, destination IItem)

Types

type AmmoType

type AmmoType string

type Attack

type Attack struct {
	Entity
	// contains filtered or unexported fields
}

func NewAttack

func NewAttack(p *Entity, targetFilter Filter, attackColision []*RelativeCylinder, damage float32) *Attack

func (*Attack) Colision

func (e *Attack) Colision() []*Cylinder

func (*Attack) Hit

func (e *Attack) Hit(c ICharacter, delta float32)

func (*Attack) InnerEntity

func (e *Attack) InnerEntity() IEntity

func (*Attack) Node

func (e *Attack) Node() model.INode

func (*Attack) PostTick

func (e *Attack) PostTick(delta float32)

func (*Attack) PreTick

func (e *Attack) PreTick()

func (*Attack) Reach

func (e *Attack) Reach() float32

func (*Attack) SetReach

func (e *Attack) SetReach(v float32)

func (*Attack) SetTargetFilter

func (e *Attack) SetTargetFilter(v Filter)

func (*Attack) TargetFilter

func (e *Attack) TargetFilter() Filter

func (*Attack) Tick

func (e *Attack) Tick(delta float32)

type BodyType

type BodyType string

type Character

type Character struct {
	Entity
	// contains filtered or unexported fields
}

func NewCharacter

func NewCharacter(p *Entity) *Character

func (*Character) AddDontPickUpUntilFar

func (e *Character) AddDontPickUpUntilFar(item IItem)

func (*Character) Attack

func (e *Character) Attack(delta float32)

func (*Character) AttackAnimationSpeed

func (e *Character) AttackAnimationSpeed() float32

func (*Character) Damaged

func (e *Character) Damaged(damage float32)

func (*Character) DontPickUpUntilFarDistance

func (e *Character) DontPickUpUntilFarDistance() float32

func (*Character) HandHeight

func (e *Character) HandHeight() float32

func (*Character) InnerEntity

func (e *Character) InnerEntity() IEntity

func (*Character) IsAttacking

func (e *Character) IsAttacking() bool

func (*Character) IsJumping

func (e *Character) IsJumping() bool

func (*Character) Jump

func (e *Character) Jump()

func (*Character) JumpMoveFactor

func (e *Character) JumpMoveFactor() float32

func (*Character) LookIntention

func (e *Character) LookIntention() float32

func (*Character) MoveIntention

func (e *Character) MoveIntention() *math32.Vector3

func (*Character) OuterDistanceTo

func (e *Character) OuterDistanceTo(c ICharacter) float32

func (*Character) PickUp

func (e *Character) PickUp(IItem)

func (*Character) PostTick

func (e *Character) PostTick(delta float32)

func (*Character) PreTick

func (e *Character) PreTick()

func (*Character) PushFactor

func (e *Character) PushFactor() float32

func (*Character) PushForce

func (e *Character) PushForce() float32

func (*Character) RepeatJump

func (e *Character) RepeatJump()

func (*Character) SetAttackAnimationSpeed

func (e *Character) SetAttackAnimationSpeed(v float32)

func (*Character) SetAttacking

func (e *Character) SetAttacking(v bool)

func (*Character) SetDontPickUpUntilFarDistance

func (e *Character) SetDontPickUpUntilFarDistance(v float32)

func (*Character) SetHandHeight

func (e *Character) SetHandHeight(v float32)

func (*Character) SetJumpMoveFactor

func (e *Character) SetJumpMoveFactor(v float32)

func (*Character) SetJumping

func (e *Character) SetJumping(v bool)

func (*Character) SetLookIntention

func (e *Character) SetLookIntention(v float32)

func (*Character) SetPushFactor

func (e *Character) SetPushFactor(v float32)

func (*Character) SetPushForce

func (e *Character) SetPushForce(v float32)

func (*Character) SetTargetFilter

func (e *Character) SetTargetFilter(v Filter)

func (*Character) SetWalkAnimationSpeed

func (e *Character) SetWalkAnimationSpeed(v float32)

func (*Character) SetWalkAnimationWhenStopping

func (e *Character) SetWalkAnimationWhenStopping(v float32)

func (*Character) StyleEquipables

func (e *Character) StyleEquipables() map[SlotId]IEquipable

func (*Character) TargetFilter

func (e *Character) TargetFilter() Filter

func (*Character) Think

func (e *Character) Think()

func (*Character) Tick

func (e *Character) Tick(delta float32)

func (*Character) WalkAnimationSpeed

func (e *Character) WalkAnimationSpeed() float32

func (*Character) WalkAnimationWhenStopping

func (e *Character) WalkAnimationWhenStopping() float32

func (*Character) WantToAttack

func (e *Character) WantToAttack() bool

func (*Character) WantToPickUp

func (e *Character) WantToPickUp(item IItem) bool

func (*Character) WantToRepeatAttack

func (e *Character) WantToRepeatAttack() bool

type Consumable

type Consumable struct {
	Item
}

func NewConsumable

func NewConsumable(i *Item) *Consumable

func (*Consumable) Consume

func (c *Consumable) Consume()

type CountableId

type CountableId string

type Cylinder

type Cylinder struct {
	X              float32
	Y              float32
	Z              float32
	SimpleCylinder *SimpleCylinder
}

Cylinder is a simple cylinder somewhere in the 3D space.

func RelativeToAbsolute

func RelativeToAbsolute(r *RelativeCylinder, lookAngle float32) *Cylinder

func RelativeToAbsoluteList

func RelativeToAbsoluteList(r []*RelativeCylinder, lookAngle float32) []*Cylinder

func SimpleToAbsolute

func SimpleToAbsolute(s *SimpleCylinder) *Cylinder

func SimpleToAbsoluteList

func SimpleToAbsoluteList(s []*SimpleCylinder) []*Cylinder

type DrawSlotId

type DrawSlotId string

type Entity

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

func NewEntity

func NewEntity(name string) *Entity

func (*Entity) Acceleration

func (e *Entity) Acceleration() float32

func (*Entity) BorderDistanceTo

func (e *Entity) BorderDistanceTo(c IEntity) float32

func (*Entity) CenterDistanceTo

func (e *Entity) CenterDistanceTo(c IEntity) float32

func (*Entity) ClimbRadius

func (e *Entity) ClimbRadius() float32

func (*Entity) ClimbReach

func (e *Entity) ClimbReach() float32

func (*Entity) Colision

func (e *Entity) Colision() []*Cylinder

func (*Entity) Damageable

func (e *Entity) Damageable() bool

func (*Entity) Damaged

func (e *Entity) Damaged(damage float32)

func (*Entity) Destroy

func (e *Entity) Destroy()

func (*Entity) Destroyed

func (e *Entity) Destroyed() bool

func (*Entity) FallingToVoidPosition

func (e *Entity) FallingToVoidPosition() (v *math32.Vector3)

func (*Entity) FormerPosition

func (e *Entity) FormerPosition() *math32.Vector3

func (*Entity) Friction

func (e *Entity) Friction() float32

func (*Entity) Generate

func (e *Entity) Generate() []IEntity

func (*Entity) Gravity

func (e *Entity) Gravity(v float32)

func (*Entity) Healed

func (e *Entity) Healed(points float32)

func (*Entity) Health

func (e *Entity) Health() float32

func (*Entity) Height

func (e *Entity) Height() float32

func (*Entity) HorizontalSpeed

func (e *Entity) HorizontalSpeed() float32

func (*Entity) LookAngle

func (e *Entity) LookAngle() float32

func (*Entity) MaxHealth

func (e *Entity) MaxHealth() float32

func (*Entity) MaxHorizontalSpeed

func (e *Entity) MaxHorizontalSpeed() float32

func (*Entity) MaxSpeed

func (e *Entity) MaxSpeed() float32

func (*Entity) MinHorizontalSpeed

func (e *Entity) MinHorizontalSpeed() float32

func (*Entity) Name

func (e *Entity) Name() string

func (*Entity) Node

func (e *Entity) Node() model.INode

func (*Entity) OnGround

func (e *Entity) OnGround() bool

func (*Entity) OuterRadius

func (e *Entity) OuterRadius() float32

func (*Entity) Position

func (e *Entity) Position() *math32.Vector3

func (*Entity) PostTick

func (e *Entity) PostTick(delta float32)

func (*Entity) PreTick

func (e *Entity) PreTick()

func (*Entity) Radius

func (e *Entity) Radius() float32

func (*Entity) RotationHorizontalSpeed

func (e *Entity) RotationHorizontalSpeed() float32

func (*Entity) SetAcceleration

func (e *Entity) SetAcceleration(v float32)

func (*Entity) SetClimbRadius

func (e *Entity) SetClimbRadius(v float32)

func (*Entity) SetClimbReach

func (e *Entity) SetClimbReach(v float32)

func (*Entity) SetDamageable

func (e *Entity) SetDamageable(v bool)

func (*Entity) SetFallingToVoidPosition

func (e *Entity) SetFallingToVoidPosition(v *math32.Vector3)

func (*Entity) SetFriction

func (e *Entity) SetFriction(v float32)

func (*Entity) SetHealth

func (e *Entity) SetHealth(v float32)

func (*Entity) SetHeight

func (e *Entity) SetHeight(v float32)

func (*Entity) SetLookAngle

func (e *Entity) SetLookAngle(v float32)

func (*Entity) SetMaxHealth

func (e *Entity) SetMaxHealth(v float32)

func (*Entity) SetMaxSpeed

func (e *Entity) SetMaxSpeed(v float32)

func (*Entity) SetMinSpeed

func (e *Entity) SetMinSpeed(v float32)

func (*Entity) SetOnGround

func (e *Entity) SetOnGround(v bool)

func (*Entity) SetOuterRadius

func (e *Entity) SetOuterRadius(v float32)

func (*Entity) SetRadius

func (e *Entity) SetRadius(v float32)

func (*Entity) SetRotationSpeed

func (e *Entity) SetRotationSpeed(v float32)

func (*Entity) SetShadowOpacity

func (e *Entity) SetShadowOpacity(v float32)

func (*Entity) SetSpeed

func (e *Entity) SetSpeed(v float32)

func (*Entity) ShadowNode

func (e *Entity) ShadowNode() model.INode

func (*Entity) ShadowOpacity

func (e *Entity) ShadowOpacity() float32

func (*Entity) Speed

func (e *Entity) Speed() *math32.Vector3

func (*Entity) Tick

func (e *Entity) Tick(delta float32)

type Equipable

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

func NewEquipable

func NewEquipable(i *Item, bodyType BodyType) *Equipable

func (*Equipable) AllowRepeat

func (e *Equipable) AllowRepeat() bool

func (*Equipable) AttackValue

func (e *Equipable) AttackValue() int

func (*Equipable) BodyType

func (e *Equipable) BodyType() BodyType

func (*Equipable) CoverDrawSlots

func (e *Equipable) CoverDrawSlots() []DrawSlotId

func (*Equipable) DefenseValue

func (e *Equipable) DefenseValue() int

func (*Equipable) IsTwoHanded

func (e *Equipable) IsTwoHanded() bool

func (*Equipable) SetAllowRepeat

func (e *Equipable) SetAllowRepeat(v bool)

func (*Equipable) SetAttackValue

func (e *Equipable) SetAttackValue(v int)

func (*Equipable) SetCoverDrawSlots

func (e *Equipable) SetCoverDrawSlots(v []DrawSlotId)

func (*Equipable) SetDefenseValue

func (e *Equipable) SetDefenseValue(v int)

func (*Equipable) SetTwoHanded

func (e *Equipable) SetTwoHanded(v bool)

type Filter

type Filter func(interface{}) bool

type IAttack

type IAttack interface {
	IEntity

	InnerEntity() IEntity

	Reach() float32

	TargetFilter() Filter
	Hit(c ICharacter, delta float32)
}

type ICharacter

type ICharacter interface {
	IEntity
	InnerEntity() IEntity

	MoveIntention() *math32.Vector3
	SetLookIntention(float32)
	LookIntention() float32

	Inventory() IInventory

	PushForce() float32

	SetDontPickUpUntilFarDistance(float32)
	DontPickUpUntilFarDistance() float32
	AddDontPickUpUntilFar(item IItem)

	PickUp(IItem)
	WantToPickUp(IItem) bool

	StyleEquipables() map[SlotId]IEquipable

	EquippedWeapon() IEquipable
	AttackIntention() bool
	TargetFilter() Filter

	HandHeight() float32

	WantToAttack() bool
	WantToRepeatAttack() bool
	IsAttacking() bool
	SetAttacking(bool)
	Attack(delta float32) []IAttack

	Jump()
	RepeatJump()
	IsJumping() bool
	SetJumping(bool)

	OuterDistanceTo(ICharacter) float32

	Think()
}

type IConsumable

type IConsumable interface {
	IItem

	Consume()
}

type IEnemy

type IEnemy interface {
	ICharacter
	IEvil

	TargetSeeDistance() float32

	Target() IEntity

	SeeTarget(IEntity)
}

type IEntity

type IEntity interface {
	model.IDrawable
	ITickable
	Name() string
	ShadowNode() model.INode

	Colision() []*Cylinder
	Radius() float32
	OuterRadius() float32
	ClimbRadius() float32
	ClimbReach() float32
	Height() float32

	Position() *math32.Vector3
	FormerPosition() *math32.Vector3
	Speed() *math32.Vector3
	MaxSpeed() float32
	SetLookAngle(float32)
	LookAngle() float32
	Destroyed() bool
	Health() float32
	SetHealth(v float32)
	MaxHealth() float32
	SetMaxHealth(v float32)

	Gravity(v float32)
	SetOnGround(bool)
	OnGround() bool

	BorderDistanceTo(IEntity) float32
	CenterDistanceTo(IEntity) float32

	FallingToVoidPosition() *math32.Vector3
	SetFallingToVoidPosition(*math32.Vector3)

	Generate() []IEntity
	Healed(float32)
	Damaged(float32)
	Destroy()
}

type IEquipable

type IEquipable interface {
	IItem

	EquippedNode() model.INode

	AllowRepeat() bool
	Attack(delta float32, damage float32, position *math32.Vector3, attackAngle, legHeight, handHeight, totalHeight float32, filter Filter) []IAttack
	CoverDrawSlots() []DrawSlotId

	AttackValue() int
	DefenseValue() int

	BodyType() BodyType

	IsTwoHanded() bool
}

type IEvil

type IEvil interface {
	Evil()
}

type IGood

type IGood interface {
	Good()
}

type IInventory

type IInventory interface {
	ITickable

	Slots() map[SlotId]IItem
	EquipmentSlots() map[SlotId]IEquipable
	CanEquip(itemSlot int, slot SlotId) bool
	CanEquipItem(item IItem, slot SlotId) bool
	AutoEquip(itemSlot int)
	Equip(itemSlot int, slot SlotId)
	AutoUnequip(slot SlotId)
	Unequip(slot SlotId, itemSlot int)
	ShuffleEquipment(slot1, slot2 SlotId) bool

	Items() []IItem

	EquippedWeapon() IEquipable

	WhereHas(IItem) int
	WhereEquipped(item IItem) SlotId

	CanPickUp(item IItem) bool
	PickUp(item IItem) int
	ShuffleItem(itemSlot1, itemSlot2 int)

	SetHoldAmount(v int)
	HoldAmount() int
	SetHoldItem(item IItem)
	HoldItem() IItem

	RemoveItemSlot(itemSlot int)
	RemoveEquipped(slot SlotId)

	DropItemSlot(itemSlot int)
	DropEquipped(slot SlotId)
	DropAllLoot()
	Generate() []IItem

	Flip()

	Attack(bool) interface{}
}

type IItem

type IItem interface {
	IEntity
	InnerEntity() IEntity

	DroppedNode() model.INode
	InventoryNode() model.INode

	WaitBeforePickupable(seconds float32)
	IsPickupable() bool

	SimpleValue() float32

	ItemType() ItemType

	ProvidesAmmo() AmmoType
	SetProvidesAmmo(v AmmoType)
	RequiresAmmo() AmmoType
	SetRequiresAmmo(v AmmoType)

	SetCountableId(countableId CountableId)
	IsCountable() bool
	CountableId() CountableId
	SetCount(v int)
	Count() int

	SetCategory(ItemCategory)
	Category() ItemCategory

	Clone() IItem
}

func Split

func Split(source IItem, amount int) IItem

type IPlayer

type IPlayer interface {
	ICharacter
	IGood
}

type ITickable

type ITickable interface {
	PreTick()
	Tick(delta float32)
	PostTick(delta float32)
}

type Item

type Item struct {
	Entity // When dropped
	// contains filtered or unexported fields
}

func NewItem

func NewItem(p *Entity, itemType ItemType) *Item

func (*Item) Category

func (e *Item) Category() ItemCategory

func (*Item) Count

func (e *Item) Count() int

func (*Item) CountableId

func (e *Item) CountableId() CountableId

func (*Item) InnerEntity

func (e *Item) InnerEntity() IEntity

func (*Item) IsCountable

func (e *Item) IsCountable() bool

func (*Item) IsPickupable

func (e *Item) IsPickupable() bool

func (*Item) ItemType

func (e *Item) ItemType() ItemType

func (*Item) PostTick

func (e *Item) PostTick(delta float32)

func (*Item) PreTick

func (e *Item) PreTick()

func (*Item) ProvidesAmmo

func (e *Item) ProvidesAmmo() AmmoType

func (*Item) RequiresAmmo

func (e *Item) RequiresAmmo() AmmoType

func (*Item) SetCategory

func (e *Item) SetCategory(v ItemCategory)

func (*Item) SetCount

func (e *Item) SetCount(v int)

func (*Item) SetCountableId

func (e *Item) SetCountableId(countableId CountableId)

func (*Item) SetProvidesAmmo

func (e *Item) SetProvidesAmmo(v AmmoType)

func (*Item) SetRequiresAmmo

func (e *Item) SetRequiresAmmo(v AmmoType)

func (*Item) Tick

func (e *Item) Tick(delta float32)

func (*Item) WaitBeforePickupable

func (e *Item) WaitBeforePickupable(seconds float32)

type ItemCategory

type ItemCategory struct{}

type ItemType

type ItemType string
var (
	OneHandedWeapon ItemType = "OneHandedWeapon"
	TwoHandedWeapon ItemType = "TwoHandedWeapon"
	Shield          ItemType = "Shield"
	Other           ItemType = "Other"

	WeaponItemType = map[ItemType]bool{
		OneHandedWeapon: true,
		TwoHandedWeapon: true,
	}

	HandItemType = map[ItemType]bool{
		OneHandedWeapon: true,
		Shield:          true,
		TwoHandedWeapon: true,
		Other:           true,
	}
)

type RelativeCylinder

type RelativeCylinder struct {
	Ahead          float32
	Y              float32
	SimpleCylinder *SimpleCylinder
}

RelativeCylinder is a cylinder relative to a bigger entity, e.g. a sword that's carried.

func GenerateCylinders

func GenerateCylinders(maxWidth, reach, height, y, startAhead float32) []*RelativeCylinder

type SimpleCylinder

type SimpleCylinder struct {
	Radius float32
	Height float32
}

SimpleCylinder is a bare abstract cylinder with a certain volume.

type SlotId

type SlotId string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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