stage

package
v0.0.0-...-677ea5f Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Com_Transform actor.TComponent = iota
	Com_Move
)
View Source
const (
	Event_Visible actor.TEvent = iota
	Event_Invisible
	Event_BeginMove
	Event_Move
	Event_EndMove
)

Variables

This section is empty.

Functions

func BeginMoveObject

func BeginMoveObject(spc actor.ISpace, tid, objectId int64, x, y float32, complete utils.Action)

func BindActorEventVisibleFac

func BindActorEventVisibleFac(typ actor.TActor, fac FActorEventVisibleFac)

绑定不同类型Actor的可见事件工厂

func CheckEventChunk

func CheckEventChunk(actor actor.IActor, event actor.IEvent) bool

检测事件的区块是否有效

func EndMoveObject

func EndMoveObject(spc actor.ISpace, tid, objectId int64, complete utils.Action)

func GetAOISize

func GetAOISize(spc actor.ISpace) int32

func GetBeginMoveEvent

func GetBeginMoveEvent(obj actor.IActor) actor.IEvent

func GetBoundsChunk

func GetBoundsChunk(spc actor.ISpace, cx, cy int32, size int32) (chunkId string, tags []string)

空间协程使用

func GetChunkBoundsKey

func GetChunkBoundsKey(chunkId string, size int32) string

func GetChunkId

func GetChunkId(x, y int32) string

func GetEndMoveEvent

func GetEndMoveEvent(obj actor.IActor) actor.IEvent

func GetEventInvisible

func GetEventInvisible(obj actor.IActor) actor.IEvent

func GetEventVisible

func GetEventVisible(obj actor.IActor) actor.IEvent

func GetMoveEvent

func GetMoveEvent(obj actor.IActor) actor.IEvent

func GetObjChunk

func GetObjChunk(obj actor.IActor) (cx, cy int32)

对象协程使用

func MoveObject

func MoveObject(tid int64, obj actor.IActor, data interface{}, ms int64)

@Description: 对象移动心跳 @param tid 链路id @param obj 移动对象 @param data 数据,使用的*moveCache @param ms 时间间隔

func NewStage

func NewStage(option *Option) *stage

func RecycleObject

func RecycleObject(spc actor.ISpace, tid, objectId int64,
	getInvisibleEvent func(obj actor.IActor) actor.IEvent, complete utils.Action)

func SetStage

func SetStage(spc actor.ISpace, stage IStage)

func SpawnEvent

func SpawnEvent(typ actor.TEvent, cx, cy, size int32) actor.IEvent

func SpawnObject

func SpawnObject(spc actor.ISpace, tid, objectId int64, typ actor.TActor, data interface{},
	getVisibleEvent func(obj actor.IActor) actor.IEvent, complete utils.Action)

生成对象

Types

type ChunkBounds

type ChunkBounds struct {
	MinX    int32
	MaxX    int32
	MinY    int32
	MaxY    int32
	OutMinX int32
	OutMaxX int32
	OutMinY int32
	OutMaxY int32
	Width   int32
	Length  int32
}

所在空间的包围盒和超出的数值 超出数值用于大场景区块边界通知

type ComMove

type ComMove struct {
	//每秒移速
	Speed float32
	//是否正在移动
	Moving bool
	//移动的心跳id,用于取消心跳
	TickId int64
	//最后一次移动时间
	LastMoveTime time.Time
	//移动方向归一后x值
	ForwardX float32
	//移动方向归一后y值
	ForwardY float32
}

func (*ComMove) Begin

func (d *ComMove) Begin(x, y float32) (ok bool)

func (*ComMove) End

func (d *ComMove) End()

func (*ComMove) GetOffset

func (d *ComMove) GetOffset() (float32, float32)

func (*ComMove) Type

func (d *ComMove) Type() actor.TComponent

type ComTransform

type ComTransform struct {
	//空间坐标x
	X float32
	//空间坐标y
	Y float32
	//区块x轴索引
	CX int32
	//区块y轴索引
	CY int32
}

func (*ComTransform) Type

func (d *ComTransform) Type() actor.TComponent

type EventBase

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

type EventBeginMove

type EventBeginMove struct {
	EventBase
	ObjectId int64
	X        float32
	Y        float32
	ForwardX float32
	ForwardY float32
}

有可能

func (*EventBeginMove) Type

func (e *EventBeginMove) Type() actor.TEvent

type EventEndMove

type EventEndMove struct {
	EventBase
	ObjectId int64
}

func (*EventEndMove) Type

func (e *EventEndMove) Type() actor.TEvent

type EventInvisible

type EventInvisible struct {
	EventBase
	ObjectId int64
}

func (*EventInvisible) Type

func (e *EventInvisible) Type() actor.TEvent

type EventMove

type EventMove struct {
	EventBase
	ObjectId   int64
	ObjectType actor.TActor
	X          float32
	Y          float32
	ForwardX   float32
	ForwardY   float32
}

func (*EventMove) Type

func (e *EventMove) Type() actor.TEvent

type EventVisible

type EventVisible struct {
	EventBase
	ObjectId   int64
	ObjectType actor.TActor
	//Transform
	X float32
	Y float32
	//Move
	Speed  float32
	Moving bool
	MoveX  float32
	MoveY  float32
}

func (*EventVisible) Type

func (e *EventVisible) Type() actor.TEvent

type FActorEventVisibleFac

type FActorEventVisibleFac func(obj actor.IActor) actor.IEvent

type IStage

type IStage interface {
	// @Description: 舞台宽度,对应x
	// @return int32
	Width() int32
	// @Description: 舞台长度,对应y
	// @return int32
	Length() int32
	// @Description: 单块的尺寸
	// @return int32
	ChunkSize() int32
	// @Description: 舞台宽的块数量
	// @return int32
	ChunkWidthCount() int32
	// @Description: 舞台长的块数量
	// @return int32
	ChunkLengthCount() int32
	// @Description: 默认视野范围,例如九宫是1,中心格子包围一圈
	// @return int32
	AOISize() int32
	// @Description: 实际坐标转块位置,超出范围会纠正
	// @param x
	// @param y
	// @return cx
	// @return cy
	// @return nx 纠正后的x坐标
	// @return ny 纠正后的y坐标
	PositionToChunk(x, y float32) (cx, cy int32, nx, ny float32)
	// @Description:
	// @param cx
	// @param cy
	// @param size
	// @return b
	GetChunkBounds(cx, cy int32, size int32) (b *ChunkBounds)
	// @Description: 获取包围块
	// @param x 块x
	// @param y 块y
	// @param size 包围尺寸
	// @return center 中心块id
	// @return bounds 周围块id
	GetBoundsChunks(x, y, size int32) (center string, bounds []string)
	// @Description: 获取开放地图的包围块,包含相邻舞台的块
	// @param x 块x
	// @param y 块y
	// @param size 包围尺寸
	// @return center 中心块id
	// @return leftTop 左上视野块
	// @return centerTop 中上视野块
	// @return rightTop 右上视野块
	// @return leftMiddle 左中视野块
	// @return centerMiddle 中视野块,(当前舞台的)
	// @return rightMiddle 右中视野块
	// @return leftBottom 左下视野块
	// @return centerBottom 中下视野块
	// @return rightBottom 右下视野块
	GetOpenBoundsChunks(x, y, size int32) (center string, leftTop, centerTop, rightTop,
		leftMiddle, centerMiddle, rightMiddle,
		leftBottom, centerBottom, rightBottom []string)
	// @Description: 从一块移动达到另一块的变化,返回退出块,进入块,不变块
	// @param outX 退出块x
	// @param outY 退出块y
	// @param inX 进入块x
	// @param inY 进入块y
	// @param size 视野包围尺寸
	// @return out 退出视野的所有块
	// @return in 进入视野的所有块
	// @return un 不变视野的所有块
	GetChunkChangeCache(outX, outY, inX, inY, size int32) (out, in, un []string)
}

@Description: 宫格舞台

func GetStage

func GetStage(spc actor.ISpace) IStage

type Option

type Option struct {
	Width     int32
	Length    int32
	ChunkSize int32
	AOISize   int32
}

Jump to

Keyboard shortcuts

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