Documentation ¶
Overview ¶
entityid->*Entity
网络对象
space统一维护aoi数据的变化 不可也没有必要并发调用space接口
Index ¶
- Constants
- Variables
- func RegisterEntity(entity *Entity)
- func RegisterSpace(space *Space)
- func UnRegisterEntity(entity EntityId)
- func UnRegisterSpace(space SpaceId)
- type Coord
- type Entity
- func (e *Entity) BindGameClient(clientid int32)
- func (e *Entity) BindIentity(ientity Ientity)
- func (e *Entity) Decrease(key string, value float32) float32
- func (e *Entity) DistanceTo(other *Entity) Coord
- func (e *Entity) EnterSpace(spaceID SpaceId, pos Vector3)
- func (e *Entity) Flag() int32
- func (e *Entity) GetAttr(key string) float32
- func (e *Entity) GetPosition() Vector3
- func (e *Entity) Increase(key string, value float32) float32
- func (e *Entity) IsNeighbor(other *Entity) bool
- func (e *Entity) IsPersistent() bool
- func (e *Entity) IsUseAOI() bool
- func (e *Entity) LeaveSpace()
- func (e *Entity) MoveSpace(pos Vector3)
- func (e *Entity) Neighbors() EntitySet
- func (e *Entity) OnCreated()
- func (e *Entity) OnDestroy()
- func (e *Entity) OnEnterSpace()
- func (e *Entity) OnInit()
- func (e *Entity) OnLeaveSpace(space *Space)
- func (e *Entity) OnMigrateIn()
- func (e *Entity) OnMigrateOut()
- func (e *Entity) OnRestored()
- func (e *Entity) Post(users []*Entity, msg interface{})
- func (e *Entity) String() string
- type EntityAtt
- type EntityDesc
- type EntityId
- type EntityManager
- type EntitySet
- type GameClient
- type Iaoicalculator
- type Ientity
- type Ispace
- type Pather
- type Space
- type SpaceId
- type SpaceManager
- type Vector3
- type WayPoint
- type World
- func (w World) AllOfKind(kind int) []*WayPoint
- func (w World) FirstOfKind(kind int) *WayPoint
- func (w World) From() *WayPoint
- func (w World) GetWayPoint(x, y int) *WayPoint
- func (w World) RenderPath(path []Pather) string
- func (w World) SetWayPoint(way *WayPoint, x, y int)
- func (w World) To() *WayPoint
- type XZListAOICalculator
Constants ¶
View Source
const ( NIL_SPACE = 0 // 空场景 DEFAULT_FIGHT_SPACE = 1 // 默认的战斗场景 )
View Source
const ( KindPlain = iota // 平原 KindRiver // 河流 KindMountain // 山峰 KindBlocker // 阻挡 KindFrom // 起点 KindTo // 终点 KindPath // 路径点 )
Variables ¶
View Source
var KindCosts = map[int]float64{ KindPlain: 1.0, KindFrom: 1.0, KindTo: 1.0, KindRiver: 2.0, KindMountain: 3.0, }
定义消耗
View Source
var KindRunes = map[int]rune{ KindPlain: '.', KindRiver: '~', KindMountain: 'M', KindBlocker: 'X', KindFrom: 'F', KindTo: 'T', KindPath: '•', }
用于渲染 FIXME 仅用于测试
View Source
var RuneKinds = map[rune]int{ '.': KindPlain, '~': KindRiver, 'M': KindMountain, 'X': KindBlocker, 'F': KindFrom, 'T': KindTo, '•': KindPath, }
用于渲染 FIXME 仅用于测试
View Source
var RuneKindsString = map[string]int{ "-1": KindPlain, "29": KindBlocker, }
这部分跟导出的地图数据结构相关,完全可以自定义
Functions ¶
func RegisterEntity ¶
func RegisterEntity(entity *Entity)
func RegisterSpace ¶
func RegisterSpace(space *Space)
func UnRegisterEntity ¶
func UnRegisterEntity(entity EntityId)
func UnRegisterSpace ¶
func UnRegisterSpace(space SpaceId)
Types ¶
type Entity ¶
type Entity struct { Id EntityId // id标识 Desc *EntityDesc // 特征描述 I Ientity // entity装载器 Space *Space // 属于哪个space Destroyed bool // 销毁标记:true-已销毁 Client *GameClient // 网络对象 Att *EntityAtt // 属性 // contains filtered or unexported fields }
func (*Entity) BindGameClient ¶
绑定clientid FIXME 绑定适当的client可以让entity具有网络传输能力
func (*Entity) IsPersistent ¶
func (*Entity) OnEnterSpace ¶
func (e *Entity) OnEnterSpace()
func (*Entity) OnLeaveSpace ¶
func (*Entity) OnMigrateIn ¶
func (e *Entity) OnMigrateIn()
func (*Entity) OnMigrateOut ¶
func (e *Entity) OnMigrateOut()
func (*Entity) OnRestored ¶
func (e *Entity) OnRestored()
type EntityDesc ¶
type EntityManager ¶
type EntityManager struct {
// contains filtered or unexported fields
}
type GameClient ¶
type GameClient struct {
// contains filtered or unexported fields
}
func (*GameClient) GetId ¶
func (game *GameClient) GetId() int32
func (*GameClient) Post ¶
func (game *GameClient) Post(user []*Entity, msg interface{})
type Iaoicalculator ¶
type Iaoicalculator interface { Enter(aoi *aoi, pos Vector3) // 进入(Entity进入Space时调用) Leave(aoi *aoi) // 离开(Entity离开Space时调用 Move(aoi *aoi, newPos Vector3) // 移动(Entity在Space里移动时调用) // 调整关注区域列表(即调整邻居的过程,可能有新邻居,可能有失效的邻居, // 那么也就有不同的操作,对新邻居是进入,对失效邻居是离开) // @return enter:新邻居 leave:失效的邻居 Adjust(aoi *aoi) (enter []*aoi, leave []*aoi) }
aoi计算器
type Pather ¶
type Space ¶
type Space struct { Id SpaceId // 场景id Type int // space类型 I Ispace // space装载器 // contains filtered or unexported fields }
func (*Space) OnEntityEnterSpace ¶
func (*Space) OnEntityLeaveSpace ¶
func (*Space) OnSpaceCreated ¶
func (space *Space) OnSpaceCreated()
func (*Space) OnSpaceDestroy ¶
func (space *Space) OnSpaceDestroy()
func (*Space) OnSpaceInit ¶
func (space *Space) OnSpaceInit()
type SpaceManager ¶
type Vector3 ¶
type Vector3 struct { X Coord // X轴 Y Coord // Y轴 Z Coord // Z轴 VX Coord // X轴上的速度 VZ Coord // Z轴上的速度 W Coord // 度宽,for体积 H Coord // 高宽,for体积 TIME int64 // 时间戳:ms }
位置
func (Vector3) Normalized ¶
type World ¶
路径点构成的世界 map[WayPoint.X]map[WayPoint.Y]*WayPoint
func (World) FirstOfKind ¶
func (World) GetWayPoint ¶
func (World) SetWayPoint ¶
type XZListAOICalculator ¶
type XZListAOICalculator struct {
// contains filtered or unexported fields
}
func (*XZListAOICalculator) Adjust ¶
func (cal *XZListAOICalculator) Adjust(aoi *aoi) (enter []*aoi, leave []*aoi)
func (*XZListAOICalculator) Enter ¶
func (cal *XZListAOICalculator) Enter(aoi *aoi, pos Vector3)
func (*XZListAOICalculator) Leave ¶
func (cal *XZListAOICalculator) Leave(aoi *aoi)
func (*XZListAOICalculator) Move ¶
func (cal *XZListAOICalculator) Move(aoi *aoi, pos Vector3)
Click to show internal directories.
Click to hide internal directories.