state

package
v0.0.0-...-94e82ac Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TileRenderedWidth  = 40
	TileRenderedHeight = 24
)
View Source
const TileCols = 8
View Source
const TileRows = 5

Variables

This section is empty.

Functions

func BehaviorIs

func BehaviorIs[T EntityBehavior](behavior EntityBehavior) bool

func TicksToSampleOffset

func TicksToSampleOffset(sr beep.SampleRate, t Ticks) int

Types

type BrokenTileBehavior

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

func (*BrokenTileBehavior) Appearance

func (tb *BrokenTileBehavior) Appearance(t *Tile, y int, b *bundle.Bundle, tiles *ebiten.Image) draw.Node

func (*BrokenTileBehavior) CanEnter

func (tb *BrokenTileBehavior) CanEnter(t *Tile, e *Entity) bool

func (*BrokenTileBehavior) Clone

func (tb *BrokenTileBehavior) Clone() TileBehavior

func (*BrokenTileBehavior) Flip

func (tb *BrokenTileBehavior) Flip()

func (*BrokenTileBehavior) OnLeave

func (tb *BrokenTileBehavior) OnLeave(t *Tile, e *Entity, s *State)

func (*BrokenTileBehavior) Step

func (tb *BrokenTileBehavior) Step(t *Tile, s *State)

type Chip

type Chip struct {
	Index        int
	Name         string
	BaseDamage   int
	MakeBehavior func(damage Damage) EntityBehavior
}

func (Chip) Clone

func (c Chip) Clone() Chip

type ChipPlaque

type ChipPlaque struct {
	ElapsedTime  Ticks
	Chip         *Chip
	DoubleDamage bool
	AttackPlus   int
}

type ColumnInfo

type ColumnInfo struct {
	IsAlliedWithAnswerer bool
	AllySwapTimeLeft     int
}

func (*ColumnInfo) Clone

func (c *ColumnInfo) Clone() *ColumnInfo

type CrackedTileBehavior

type CrackedTileBehavior struct {
}

func (*CrackedTileBehavior) Appearance

func (tb *CrackedTileBehavior) Appearance(t *Tile, y int, b *bundle.Bundle, tiles *ebiten.Image) draw.Node

func (*CrackedTileBehavior) CanEnter

func (tb *CrackedTileBehavior) CanEnter(t *Tile, e *Entity) bool

func (*CrackedTileBehavior) Clone

func (tb *CrackedTileBehavior) Clone() TileBehavior

func (*CrackedTileBehavior) Flip

func (tb *CrackedTileBehavior) Flip()

func (*CrackedTileBehavior) OnLeave

func (tb *CrackedTileBehavior) OnLeave(t *Tile, e *Entity, s *State)

func (*CrackedTileBehavior) Step

func (tb *CrackedTileBehavior) Step(t *Tile, s *State)

type Damage

type Damage struct {
	Base int

	ParalyzeTime Ticks
	Flinch       bool
	Uninstall    bool
	Skull        bool
	DoubleDamage bool
	AttackPlus   int
}

type Decoration

type Decoration struct {
	ElapsedTime Ticks

	RunsInTimestop bool

	IsFlipped bool

	Type bundle.DecorationType

	TilePos TilePos
	Offset  image.Point
	// contains filtered or unexported fields
}

func (*Decoration) Appearance

func (d *Decoration) Appearance(b *bundle.Bundle) draw.Node

func (*Decoration) Clone

func (d *Decoration) Clone() *Decoration

func (*Decoration) Flip

func (d *Decoration) Flip()

func (*Decoration) ID

func (d *Decoration) ID() DecorationID

func (*Decoration) Step

func (d *Decoration) Step()

type DecorationID

type DecorationID uint64

type Direction

type Direction uint8
const (
	DirectionNone  Direction = 0
	DirectionUp    Direction = 0b0001
	DirectionDown  Direction = 0b0010
	DirectionLeft  Direction = 0b0100
	DirectionRight Direction = 0b1000
)

func DirectionDXDY

func DirectionDXDY(dx int, dy int) Direction

func (Direction) FlipH

func (d Direction) FlipH() Direction

func (Direction) FlipV

func (d Direction) FlipV() Direction

func (Direction) XY

func (d Direction) XY() (int, int)

type Element

type Element int
const (
	ElementNull   Element = 0
	ElementFire   Element = 1
	ElementAqua   Element = 2
	ElementElec   Element = 3
	ElementWood   Element = 4
	ElementSword  Element = 5
	ElementWind   Element = 6
	ElementCursor Element = 7
	ElementBreak  Element = 8
)

func (Element) IsSuperEffectiveAgainst

func (e Element) IsSuperEffectiveAgainst(e2 Element) bool

type Emotion

type Emotion int
const (
	EmotionNormal      Emotion = 0
	EmotionFullSynchro Emotion = 1
	EmotionAngry       Emotion = 2
)

type Entity

type Entity struct {
	ElapsedTime Ticks
	MaxLifeTime Ticks

	RunsInTimestop bool

	BehaviorState        EntityBehaviorState
	NextBehavior         EntityBehavior
	IsPendingDestruction bool

	Intent     Intent
	LastIntent Intent

	TilePos       TilePos
	FutureTilePos TilePos

	ForcedMovementState ForcedMovementState

	IsAlliedWithAnswerer bool

	IsFlipped bool

	IsDead bool

	Element Element

	HP        int
	MaxHP     int
	DisplayHP int

	Traits EntityTraits

	PowerShotChargeTime Ticks

	ConfusedTimeLeft    Ticks
	BlindedTimeLeft     Ticks
	ImmobilizedTimeLeft Ticks
	Flashing            Flashing
	InvincibleTimeLeft  Ticks

	Emotion Emotion

	HitResolution HitResolution
	PerTickState  EntityPerTickState

	Chips         []*Chip
	ChipUseQueued bool

	DragLockoutTimeLeft    Ticks
	ChipUseLockoutTimeLeft Ticks
	RoadLockoutTimeLeft    Ticks

	ChipPlaque ChipPlaque
	// contains filtered or unexported fields
}

func (*Entity) Appearance

func (e *Entity) Appearance(b *bundle.Bundle) draw.Node

func (*Entity) ApplyHit

func (e *Entity) ApplyHit(h Hit)

func (*Entity) CanMoveTo

func (e *Entity) CanMoveTo(tilePos TilePos, s *State) bool

func (*Entity) Clone

func (e *Entity) Clone() *Entity

func (*Entity) DoubleDamage

func (e *Entity) DoubleDamage() bool

func (*Entity) Facing

func (e *Entity) Facing() Direction

func (*Entity) FinishMove

func (e *Entity) FinishMove(s *State)

func (*Entity) Flip

func (e *Entity) Flip()

func (*Entity) ID

func (e *Entity) ID() EntityID

func (*Entity) MoveDirectly

func (e *Entity) MoveDirectly(tilePos TilePos, s *State) bool

func (*Entity) RemoveFlashing

func (e *Entity) RemoveFlashing(s *State)

func (*Entity) SetBehaviorImmediate

func (e *Entity) SetBehaviorImmediate(behavior EntityBehavior, s *State)

SetBehaviorImmediate sets the entity's behavior immediately to the next state and steps once. You probably don't want to call this: you should probably use NextBehavior instead.

func (*Entity) StartMove

func (e *Entity) StartMove(tilePos TilePos, s *State) bool

func (*Entity) Step

func (e *Entity) Step(s *State)

func (*Entity) UseChip

func (e *Entity) UseChip(s *State) bool

type EntityBehavior

type EntityBehavior interface {
	clone.Cloner[EntityBehavior]
	Appearance(e *Entity, b *bundle.Bundle) draw.Node
	Traits(e *Entity) EntityBehaviorTraits
	Step(e *Entity, s *State)
	Cleanup(e *Entity, s *State)
}

type EntityBehaviorState

type EntityBehaviorState struct {
	Behavior    EntityBehavior
	ElapsedTime Ticks
}

func (EntityBehaviorState) Clone

type EntityBehaviorTraits

type EntityBehaviorTraits struct {
	CanBeCountered bool
}

type EntityID

type EntityID uint64

type EntityPerTickState

type EntityPerTickState struct {
	WasHit bool
}

type EntityTraits

type EntityTraits struct {
	CanStepOnHoleLikeTiles bool
	IgnoresTileEffects     bool
	CannotFlinch           bool
	CannotFlash            bool
	StatusGuard            bool
	FatalHitLeaves1HP      bool
	IgnoresTileOwnership   bool
	CannotSlide            bool
	Intangible             bool
	ExtendsTileOwnership   bool
}

type Field

type Field struct {
	Tiles      []*Tile
	ColumnInfo []*ColumnInfo
}

func (*Field) Appearance

func (f *Field) Appearance(b *bundle.Bundle) draw.Node

func (*Field) Clone

func (f *Field) Clone() *Field

func (*Field) Flip

func (f *Field) Flip()

func (*Field) Step

func (f *Field) Step(s *State)

type Flashing

type Flashing struct {
	TimeLeft Ticks
	IsInvis  bool
}

type ForcedMovement

type ForcedMovement struct {
	Type      ForcedMovementType
	Direction Direction
}

type ForcedMovementState

type ForcedMovementState struct {
	ForcedMovement ForcedMovement
	ElapsedTime    Ticks
}

type ForcedMovementType

type ForcedMovementType int
const (
	ForcedMovementTypeNone      ForcedMovementType = 0
	ForcedMovementTypeSlide     ForcedMovementType = 1
	ForcedMovementTypeSmallDrag ForcedMovementType = 2
	ForcedMovementTypeBigDrag   ForcedMovementType = 2
)

func (ForcedMovementType) IsDrag

func (t ForcedMovementType) IsDrag() bool

type Hit

type Hit struct {
	TotalDamage int

	FlashTime      Ticks
	ParalyzeTime   Ticks
	ConfuseTime    Ticks
	BlindTime      Ticks
	ImmobilizeTime Ticks
	FreezeTime     Ticks
	BubbleTime     Ticks
	Flinch         bool

	ForcedMovement ForcedMovement

	Element               Element
	CanCounter            bool
	RemovesFullSynchro    bool
	SecondaryElementSword bool
	GuardPiercing         bool
	RemovesFlashing       bool
}

func (*Hit) AddDamage

func (h *Hit) AddDamage(d Damage)

type HitResolution

type HitResolution struct {
	Damage int

	Flinch         bool
	FlashTime      Ticks
	ParalyzeTime   Ticks
	ConfuseTime    Ticks
	BlindTime      Ticks
	ImmobilizeTime Ticks
	FreezeTime     Ticks
	BubbleTime     Ticks

	RemovesFullSynchro bool
	ForcedMovement     ForcedMovement
}

type HoleTileBehavior

type HoleTileBehavior struct {
}

func (*HoleTileBehavior) Appearance

func (tb *HoleTileBehavior) Appearance(t *Tile, y int, b *bundle.Bundle, tiles *ebiten.Image) draw.Node

func (*HoleTileBehavior) CanEnter

func (tb *HoleTileBehavior) CanEnter(t *Tile, e *Entity) bool

func (*HoleTileBehavior) Clone

func (tb *HoleTileBehavior) Clone() TileBehavior

func (*HoleTileBehavior) Flip

func (tb *HoleTileBehavior) Flip()

func (*HoleTileBehavior) OnLeave

func (tb *HoleTileBehavior) OnLeave(t *Tile, e *Entity, s *State)

func (*HoleTileBehavior) Step

func (tb *HoleTileBehavior) Step(t *Tile, s *State)

type IceTileBehavior

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

func (*IceTileBehavior) Appearance

func (tb *IceTileBehavior) Appearance(t *Tile, y int, b *bundle.Bundle, tiles *ebiten.Image) draw.Node

func (*IceTileBehavior) CanEnter

func (tb *IceTileBehavior) CanEnter(t *Tile, e *Entity) bool

func (*IceTileBehavior) Clone

func (tb *IceTileBehavior) Clone() TileBehavior

func (*IceTileBehavior) Flip

func (tb *IceTileBehavior) Flip()

func (*IceTileBehavior) OnLeave

func (tb *IceTileBehavior) OnLeave(t *Tile, e *Entity, s *State)

func (*IceTileBehavior) Step

func (tb *IceTileBehavior) Step(t *Tile, s *State)

type Intent

type Intent struct {
	Direction         Direction
	UseChip           bool
	Confirm           bool
	CutIn             bool
	EndTurn           bool
	ChargeBasicWeapon bool
}

type NormalTileBehavior

type NormalTileBehavior struct {
}

func (*NormalTileBehavior) Appearance

func (tb *NormalTileBehavior) Appearance(t *Tile, y int, b *bundle.Bundle, tiles *ebiten.Image) draw.Node

func (*NormalTileBehavior) CanEnter

func (tb *NormalTileBehavior) CanEnter(t *Tile, e *Entity) bool

func (*NormalTileBehavior) Clone

func (tb *NormalTileBehavior) Clone() TileBehavior

func (*NormalTileBehavior) Flip

func (tb *NormalTileBehavior) Flip()

func (*NormalTileBehavior) OnLeave

func (tb *NormalTileBehavior) OnLeave(t *Tile, e *Entity, s *State)

func (*NormalTileBehavior) Step

func (tb *NormalTileBehavior) Step(t *Tile, s *State)

type RoadTileBehavior

type RoadTileBehavior struct {
	Direction Direction
}

func (*RoadTileBehavior) Appearance

func (tb *RoadTileBehavior) Appearance(t *Tile, y int, b *bundle.Bundle, tiles *ebiten.Image) draw.Node

func (*RoadTileBehavior) CanEnter

func (tb *RoadTileBehavior) CanEnter(t *Tile, e *Entity) bool

func (*RoadTileBehavior) Clone

func (tb *RoadTileBehavior) Clone() TileBehavior

func (*RoadTileBehavior) Flip

func (tb *RoadTileBehavior) Flip()

func (*RoadTileBehavior) OnLeave

func (tb *RoadTileBehavior) OnLeave(t *Tile, e *Entity, s *State)

func (*RoadTileBehavior) Step

func (tb *RoadTileBehavior) Step(t *Tile, s *State)

type Sound

type Sound struct {
	ElapsedTime Ticks

	Type bundle.SoundType
	// contains filtered or unexported fields
}

func (*Sound) Clone

func (s *Sound) Clone() *Sound

func (*Sound) ID

func (s *Sound) ID() SoundID

func (*Sound) Step

func (s *Sound) Step()

type SoundID

type SoundID uint64

type State

type State struct {
	ElapsedTime Ticks

	RandSource *syncrand.Source

	Field *Field

	Entities map[EntityID]*Entity

	Decorations map[DecorationID]*Decoration

	Sounds map[SoundID]*Sound

	Timestop *Timestop

	CounterPlaqueTimeLeft Ticks
	// contains filtered or unexported fields
}

func New

func New(randSource *syncrand.Source) *State

func (*State) Appearance

func (s *State) Appearance(b *bundle.Bundle) draw.Node

func (*State) ApplyHit

func (s *State) ApplyHit(owner *Entity, pos TilePos, h Hit) bool

func (*State) AttachDecoration

func (s *State) AttachDecoration(d *Decoration)

func (*State) AttachEntity

func (s *State) AttachEntity(e *Entity)

func (*State) AttachSound

func (s *State) AttachSound(snd *Sound)

func (*State) Clone

func (s *State) Clone() *State

func (*State) EntitiesAt

func (s *State) EntitiesAt(pos TilePos) []*Entity

func (*State) Flip

func (s *State) Flip()

func (*State) StartTimestop

func (s *State) StartTimestop(e *Entity, timestopBehavior TimestopBehavior)

type Ticks

type Ticks int
const DefaultFlashTime Ticks = 119

This is maybe 1 frame shorter than expected?

const DefaultParalyzeTime Ticks = 149

Apparently this is 1 frame shorter than expected - BN6 will remove paralyze if timeLeft - 1 == 0, but we only remove it if timeLeft = 0.

type Tile

type Tile struct {
	BehaviorState TileBehaviorState

	TilePos TilePos

	IsFlipped     bool
	IsHighlighted bool

	Reserver EntityID

	IsAlliedWithAnswerer bool
}

func (*Tile) Appearance

func (t *Tile) Appearance(y int, b *bundle.Bundle) draw.Node

func (*Tile) CanEnter

func (t *Tile) CanEnter(e *Entity) bool

func (*Tile) Clone

func (t *Tile) Clone() *Tile

func (*Tile) ElapsedTime

func (t *Tile) ElapsedTime() Ticks

func (*Tile) Flip

func (t *Tile) Flip()

func (*Tile) OnLeave

func (t *Tile) OnLeave(e *Entity, s *State)

func (*Tile) ReplaceBehavior

func (t *Tile) ReplaceBehavior(b TileBehavior, s *State)

func (*Tile) Step

func (t *Tile) Step(s *State)

type TileBehavior

type TileBehavior interface {
	clone.Cloner[TileBehavior]
	Appearance(t *Tile, y int, b *bundle.Bundle, tiles *ebiten.Image) draw.Node
	CanEnter(t *Tile, e *Entity) bool
	OnLeave(t *Tile, e *Entity, s *State)
	Flip()
	Step(t *Tile, s *State)
}

type TileBehaviorState

type TileBehaviorState struct {
	Behavior    TileBehavior
	ElapsedTime Ticks
}

func (TileBehaviorState) Clone

type TilePos

type TilePos int

func TilePosXY

func TilePosXY(x int, y int) TilePos

func (TilePos) Flipped

func (p TilePos) Flipped() TilePos

func (TilePos) XY

func (p TilePos) XY() (int, int)

type Timestop

type Timestop struct {
	Parent *Timestop

	Owner EntityID

	Behavior            TimestopBehavior
	BehaviorElapsedTime Ticks

	IsPendingDestruction bool
}

func (*Timestop) Clone

func (t *Timestop) Clone() *Timestop

func (*Timestop) Step

func (t *Timestop) Step(s *State)

type TimestopBehavior

type TimestopBehavior interface {
	clone.Cloner[TimestopBehavior]
	Step(t *Timestop, s *State)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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