humanoid

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: 15 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HumanoidAttackAction model.ActionId = "HumanoidAttackAction"

	HumanoidWalkAnimation = func(legLeft, legRight *model.Transform) *model.Sequence {
		s, err := model.New(
			400,
			2000./400,
			true,
			false,
			400,
			[]*model.Step{
				model.NewStep(0, true, true, nil, nil,
					map[*model.Transform]*model.TransformStep{
						legLeft:  &model.TransformStep{Set: legStanding, Mutate: legBackward},
						legRight: &model.TransformStep{Set: legStanding, Mutate: legForward},
					},
				),
				model.NewStep(100, false, false, nil, nil,
					map[*model.Transform]*model.TransformStep{
						legLeft:  &model.TransformStep{Set: legBackward, Mutate: legStanding},
						legRight: &model.TransformStep{Set: legForward, Mutate: legStanding},
					},
				),
				model.NewStep(200, true, true, nil, nil,
					map[*model.Transform]*model.TransformStep{
						legLeft:  &model.TransformStep{Set: legStanding, Mutate: legForward},
						legRight: &model.TransformStep{Set: legStanding, Mutate: legBackward},
					},
				),
				model.NewStep(300, false, false, nil, nil,
					map[*model.Transform]*model.TransformStep{
						legLeft:  &model.TransformStep{Set: legForward, Mutate: legStanding},
						legRight: &model.TransformStep{Set: legBackward, Mutate: legStanding},
					},
				),
			})
		if err != nil {
			panic(fmt.Sprintf("Critical error. Animation is broken: %v", err))
		}
		return s
	}
	HumanoidWalkAnimationTest = HumanoidWalkAnimation(n, n)

	HumanoidAttackAnimation = func(arm, hand *model.Transform, right bool) *model.Sequence {
		var armDownFrontCenter, armDownFrontCenterHit *model.Transform
		if right {
			armDownFrontCenter = armRightDownFrontCenter
			armDownFrontCenterHit = armRightDownFrontCenterHit
		} else {
			armDownFrontCenter = armLeftDownFrontCenter
			armDownFrontCenterHit = armLeftDownFrontCenterHit
		}
		s, err := model.New(
			120,
			4000./400,
			false,
			true,
			2,
			[]*model.Step{
				model.NewStep(0, true, true, nil, nil,
					map[*model.Transform]*model.TransformStep{
						arm:  &model.TransformStep{Set: armFront, Mutate: armUp},
						hand: &model.TransformStep{Set: handUp, Mutate: handMid},
					},
				),
				model.NewStep(15, false, false, nil, nil,
					map[*model.Transform]*model.TransformStep{
						arm:  &model.TransformStep{Set: armUp, Mutate: armDownFrontCenterHit},
						hand: &model.TransformStep{Set: handMid, Mutate: handHit},
					},
				),
				model.NewStep(32, false, false, nil, []model.ActionId{HumanoidAttackAction},
					map[*model.Transform]*model.TransformStep{
						arm:  &model.TransformStep{Set: armDownFrontCenterHit, Mutate: armDownFrontCenter},
						hand: &model.TransformStep{Set: handHit, Mutate: handFront},
					},
				),
				model.NewStep(60, false, false, nil, nil,
					map[*model.Transform]*model.TransformStep{
						arm:  &model.TransformStep{Set: armDownFrontCenter, Mutate: armDown},
						hand: &model.TransformStep{Set: handFront},
					},
				),
				model.NewStep(80, false, false, nil, nil,
					map[*model.Transform]*model.TransformStep{
						arm:  &model.TransformStep{Set: armDown, Mutate: armFront},
						hand: &model.TransformStep{Set: handFront, Mutate: handUp},
					},
				),
			})
		if err != nil {
			panic(fmt.Sprintf("Critical error. Animation is broken: %v", err))
		}
		return s
	}
	HumanoidAttackAnimationTest = HumanoidAttackAnimation(n, n, true)
)
View Source
var (
	HumanoidBody entity.BodyType = "Humanoid"

	Helmet entity.ItemType = "HumanoidHelmet"
	Armor  entity.ItemType = "HumanoidArmor"
	Gloves entity.ItemType = "HumanoidGloves"
	Pants  entity.ItemType = "HumanoidPants"
	Boots  entity.ItemType = "HumanoidBoots"
	Amulet entity.ItemType = "HumanoidAmulet"
	Ring   entity.ItemType = "HumanoidRing"
	Back   entity.ItemType = "HumanoidBack"

	AmuletSlot         entity.SlotId = "Amulet"
	HelmetSlot         entity.SlotId = "Helmet"
	ArmorSlot          entity.SlotId = "Armor"
	GlovesSlot         entity.SlotId = "Gloves"
	PantsSlot          entity.SlotId = "Pants"
	BootsSlot          entity.SlotId = "Boots"
	RingRightSlot      entity.SlotId = "RingRight"
	RingLeftSlot       entity.SlotId = "RingLeft"
	BackSlot           entity.SlotId = "Back"
	HandRightSlot      entity.SlotId = "HandRight"
	HandLeftSlot       entity.SlotId = "HandLeft"
	AlternateRightSlot entity.SlotId = "AlternateRight"
	AlternateLeftSlot  entity.SlotId = "AlternateLeft"

	Consumable1Slot  entity.SlotId = "Consumable1Slot"
	Consumable2Slot  entity.SlotId = "Consumable2Slot"
	Consumable3Slot  entity.SlotId = "Consumable3Slot"
	Consumable4Slot  entity.SlotId = "Consumable4Slot"
	Consumable5Slot  entity.SlotId = "Consumable5Slot"
	Consumable6Slot  entity.SlotId = "Consumable6Slot"
	Consumable7Slot  entity.SlotId = "Consumable7Slot"
	Consumable8Slot  entity.SlotId = "Consumable8Slot"
	Consumable9Slot  entity.SlotId = "Consumable9Slot"
	Consumable10Slot entity.SlotId = "Consumable10Slot"

	Head      entity.DrawSlotId = "Head"
	Torso     entity.DrawSlotId = "Torso"
	Face      entity.DrawSlotId = "Face"
	LegLeft   entity.DrawSlotId = "LegLeft"
	LegRight  entity.DrawSlotId = "legRight"
	ArmLeft   entity.DrawSlotId = "ArmLeft"
	ArmRight  entity.DrawSlotId = "ArmRight"
	HandLeft  entity.DrawSlotId = "HandLeft"
	HandRight entity.DrawSlotId = "HandRight"

	ProtrudeHeadUpOrBackLong     entity.DrawSlotId = "ProtrudeHeadUpOrBackLong"
	ProtrudeHeadUpOrBackShort    entity.DrawSlotId = "ProtrudeHeadUpOrBackShort"
	ProtrudeHeadFrontOrHangLong  entity.DrawSlotId = "ProtrudeHeadFrontOrHangLong"
	ProtrudeHeadFrontOrHangShort entity.DrawSlotId = "ProtrudeHeadFrontOrHangShort"
	ProtrudeHeadSidesLong        entity.DrawSlotId = "ProtrudeHeadSidesLong"
	ProtrudeHeadSidesShort       entity.DrawSlotId = "ProtrudeHeadSidesShort"
	ProtrudeHandLeft             entity.DrawSlotId = "ProtrudeHandsLeft"
	ProtrudeHandRight            entity.DrawSlotId = "ProtrudeHandsRight"
	ProtrudeNeck                 entity.DrawSlotId = "ProtrudeNeck"

	StandardSlots = []entity.SlotId{
		AmuletSlot,
		HelmetSlot,
		ArmorSlot,
		GlovesSlot,
		PantsSlot,
		BootsSlot,
		RingRightSlot,
		RingLeftSlot,
		BackSlot,
		HandRightSlot,
		HandLeftSlot,
		AlternateRightSlot,
		AlternateLeftSlot,
		Consumable1Slot,
		Consumable2Slot,
		Consumable3Slot,
		Consumable4Slot,
		Consumable5Slot,
		Consumable6Slot,
		Consumable7Slot,
		Consumable8Slot,
		Consumable9Slot,
		Consumable10Slot,
	}

	EquippedSlots = map[entity.SlotId]bool{
		AmuletSlot:         true,
		HelmetSlot:         true,
		ArmorSlot:          true,
		GlovesSlot:         true,
		PantsSlot:          true,
		BootsSlot:          true,
		RingRightSlot:      true,
		RingLeftSlot:       true,
		BackSlot:           true,
		HandRightSlot:      true,
		HandLeftSlot:       true,
		AlternateRightSlot: true,
		AlternateLeftSlot:  true,
	}

	ConsumableSlots = map[entity.SlotId]bool{
		Consumable1Slot:  true,
		Consumable2Slot:  true,
		Consumable3Slot:  true,
		Consumable4Slot:  true,
		Consumable5Slot:  true,
		Consumable6Slot:  true,
		Consumable7Slot:  true,
		Consumable8Slot:  true,
		Consumable9Slot:  true,
		Consumable10Slot: true,
	}

	ConsumableSlotsSorted = []entity.SlotId{
		Consumable1Slot,
		Consumable2Slot,
		Consumable3Slot,
		Consumable4Slot,
		Consumable5Slot,
		Consumable6Slot,
		Consumable7Slot,
		Consumable8Slot,
		Consumable9Slot,
		Consumable10Slot,
	}
)
View Source
var (
	Walk        = "Walk"
	AttackRight = "AttackRight"
	AttackLeft  = "AttackLeft"

	LegLeftPosition            = math32.NewVector3(13, 44, 0)
	LegRightPosition           = math32.NewVector3(-13, 44, 0)
	ArmLeftPosition            = math32.NewVector3(17, 75.5, 0)
	ArmRightPosition           = math32.NewVector3(-17, 75.5, 0)
	HandLeftPosition           = math32.NewVector3(8.5, 0, 30.5)
	HandRightPosition          = math32.NewVector3(-8.5, 0, 30.5)
	LegLeftTransformPosition   = (&math32.Vector3{}).Copy(LegLeftPosition).MultiplyScalar(model.GlobalScaleFactor)
	LegRightTransformPosition  = (&math32.Vector3{}).Copy(LegRightPosition).MultiplyScalar(model.GlobalScaleFactor)
	ArmLeftTransformPosition   = (&math32.Vector3{}).Copy(ArmLeftPosition).MultiplyScalar(model.GlobalScaleFactor)
	ArmRightTransformPosition  = (&math32.Vector3{}).Copy(ArmRightPosition).MultiplyScalar(model.GlobalScaleFactor)
	HandLeftTransformPosition  = (&math32.Vector3{}).Copy(HandLeftPosition).MultiplyScalar(model.GlobalScaleFactor)
	HandRightTransformPosition = (&math32.Vector3{}).Copy(HandRightPosition).MultiplyScalar(model.GlobalScaleFactor)
)

Functions

This section is empty.

Types

type HUD

type HUD struct {
	SideBar *SideBar
	// contains filtered or unexported fields
}

func NewHUD

func NewHUD(player entity.IPlayer) *HUD

func (*HUD) Dispose

func (g *HUD) Dispose()

func (*HUD) GatherInput

func (g *HUD) GatherInput()

func (*HUD) KeyboardInput

func (g *HUD) KeyboardInput(evname string, ev interface{})

func (*HUD) Panel

func (g *HUD) Panel() *gui.Panel

func (*HUD) PreRender

func (g *HUD) PreRender()

type Humanoid

type Humanoid struct {
	entity.Character
	// contains filtered or unexported fields
}

func NewHumanoid

func NewHumanoid(name string, i *Inventory, baseNodes map[entity.DrawSlotId]model.INode, sequences map[string]*model.Sequence, transforms map[entity.DrawSlotId]*model.Transform) *Humanoid

func (*Humanoid) Attack

func (e *Humanoid) Attack(delta float32) []entity.IAttack

func (*Humanoid) AttackIntention

func (h *Humanoid) AttackIntention() bool

func (*Humanoid) CoveredByEquipables

func (e *Humanoid) CoveredByEquipables() map[entity.DrawSlotId]bool

func (*Humanoid) Damaged

func (e *Humanoid) Damaged(damage float32)

func (*Humanoid) EquippedWeapon

func (e *Humanoid) EquippedWeapon() entity.IEquipable

func (*Humanoid) Generate

func (e *Humanoid) Generate() []entity.IEntity

func (*Humanoid) Inventory

func (h *Humanoid) Inventory() entity.IInventory

func (*Humanoid) Jump

func (e *Humanoid) Jump()

func (*Humanoid) Node

func (h *Humanoid) Node() model.INode

func (*Humanoid) PostTick

func (h *Humanoid) PostTick(delta float32)

func (*Humanoid) PreTick

func (h *Humanoid) PreTick()

func (*Humanoid) RepeatJump

func (e *Humanoid) RepeatJump()

func (*Humanoid) SetJumpPower

func (h *Humanoid) SetJumpPower(v float32)

func (*Humanoid) SetJumpTimeLimit

func (h *Humanoid) SetJumpTimeLimit(seconds float32)

func (*Humanoid) Tick

func (h *Humanoid) Tick(delta float32)

func (*Humanoid) WantToAttack

func (h *Humanoid) WantToAttack() bool

func (*Humanoid) WantToRepeatAttack

func (h *Humanoid) WantToRepeatAttack() bool

type IHumanoidEquipable

type IHumanoidEquipable interface {
	entity.IEquipable

	ArmRightNode() model.INode
	ArmLeftNode() model.INode
	LegRightNode() model.INode
	LegLeftNode() model.INode
}

type Inventory

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

func NewInventory

func NewInventory(equippedSlots []entity.SlotId, itemCount int) *Inventory

func (*Inventory) AllItems

func (i *Inventory) AllItems() []entity.IItem

func (*Inventory) Attack

func (i *Inventory) Attack(repeat bool) interface{}

func (*Inventory) AutoEquip

func (i *Inventory) AutoEquip(itemSlot int)

func (*Inventory) AutoUnequip

func (i *Inventory) AutoUnequip(slot entity.SlotId)

func (*Inventory) CanEquip

func (i *Inventory) CanEquip(itemSlot int, slot entity.SlotId) bool

func (*Inventory) CanEquipItem

func (i *Inventory) CanEquipItem(item entity.IItem, slot entity.SlotId) bool

func (*Inventory) CanPickUp

func (i *Inventory) CanPickUp(item entity.IItem) bool

func (*Inventory) DropAllLoot

func (i *Inventory) DropAllLoot()

func (*Inventory) DropEquipped

func (i *Inventory) DropEquipped(slot entity.SlotId)

func (*Inventory) DropItemSlot

func (i *Inventory) DropItemSlot(itemSlot int)

func (*Inventory) Equip

func (i *Inventory) Equip(itemSlot int, slot entity.SlotId)

func (*Inventory) EquipmentSlots

func (i *Inventory) EquipmentSlots() map[entity.SlotId]entity.IEquipable

func (*Inventory) EquippedWeapon

func (i *Inventory) EquippedWeapon() entity.IEquipable

func (*Inventory) Flip

func (i *Inventory) Flip()

func (*Inventory) Generate

func (i *Inventory) Generate() []entity.IItem

func (*Inventory) HoldAmount

func (i *Inventory) HoldAmount() int

func (*Inventory) HoldItem

func (i *Inventory) HoldItem() entity.IItem

func (*Inventory) Items

func (i *Inventory) Items() []entity.IItem

func (*Inventory) PickUp

func (i *Inventory) PickUp(item entity.IItem) int

func (*Inventory) PostTick

func (i *Inventory) PostTick(delta float32)

func (*Inventory) PreTick

func (i *Inventory) PreTick()

func (*Inventory) RemoveEquipped

func (i *Inventory) RemoveEquipped(slot entity.SlotId)

func (*Inventory) RemoveItemSlot

func (i *Inventory) RemoveItemSlot(itemSlot int)

func (*Inventory) SetHoldAmount

func (i *Inventory) SetHoldAmount(v int)

func (*Inventory) SetHoldItem

func (i *Inventory) SetHoldItem(item entity.IItem)

func (*Inventory) ShuffleEquipment

func (i *Inventory) ShuffleEquipment(slot1, slot2 entity.SlotId) bool

func (*Inventory) ShuffleItem

func (i *Inventory) ShuffleItem(itemSlot1, itemSlot2 int)

func (*Inventory) Slots

func (i *Inventory) Slots() map[entity.SlotId]entity.IItem

func (*Inventory) Tick

func (i *Inventory) Tick(delta float32)

func (*Inventory) Unequip

func (i *Inventory) Unequip(slot entity.SlotId, itemSlot int)

func (*Inventory) WhereEquipped

func (i *Inventory) WhereEquipped(item entity.IItem) entity.SlotId

func (*Inventory) WhereHas

func (i *Inventory) WhereHas(item entity.IItem) int
type SideBar struct {
	// contains filtered or unexported fields
}

func (*SideBar) Dispose

func (s *SideBar) Dispose()

func (*SideBar) Panel

func (s *SideBar) Panel() *gui.Panel

func (*SideBar) Render

func (s *SideBar) Render()

func (*SideBar) SetInventory

func (s *SideBar) SetInventory(inventory entity.IInventory)

Jump to

Keyboard shortcuts

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