basis

package
v0.0.0-...-eba1a7b Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Created by xuzhuoxi on 2019-03-14. @author xuzhuoxi

Created by xuzhuoxi on 2019-03-14. @author xuzhuoxi

Created by xuzhuoxi on 2019-03-14. @author xuzhuoxi

Created by xuzhuoxi on 2019-03-14. @author xuzhuoxi

Created by xuzhuoxi on 2019-03-08. @author xuzhuoxi

Created by xuzhuoxi on 2019-03-14. @author xuzhuoxi

Created by xuzhuoxi on 2019-03-14. @author xuzhuoxi

Created by xuzhuoxi on 2019-03-16. @author xuzhuoxi

Created by xuzhuoxi on 2019-02-19. @author xuzhuoxi

Created by xuzhuoxi on 2019-03-09. @author xuzhuoxi

Created by xuzhuoxi on 2019-03-09. @author xuzhuoxi

Created by xuzhuoxi on 2019-03-14. @author xuzhuoxi

Created by xuzhuoxi on 2019-03-14. @author xuzhuoxi

Index

Constants

View Source
const (
	PidVarWorld = iota + 1000
	PidVarZone
	PidVarRoom
	PidVarUser
	PidVarCorps
	PidVarTeam
	PidVarChannel
)
View Source
const (
	EventUserJoinRoom  = "EventUserJoinRoom"
	EventUserLeaveRoom = "EventUserLeaveRoom"
)
View Source
const (
	EventVariableChanged = "EventVariableChanged"
)
View Source
const (
	ExtMmoVar = "EVar"
)

Variables

View Source
var (
	MaxTeamMember = 0
	TeamId        = 1000
	TeamName      = "的队伍"
)
View Source
var (
	TeamCorpsId   = 1000
	TeamCorpsName = "的军团"
)

Functions

func EntityEqual

func EntityEqual(entity1 IEntity, entity2 IEntity) bool

func GetTeamCorpsId

func GetTeamCorpsId() string

func GetTeamId

func GetTeamId() string

func NearXY

func NearXY(pos1 XY, pos2 XY, distance float64) bool

判断两点是否相近 用于转发附近消息

func NearXYZ

func NearXYZ(pos1 XYZ, pos2 XYZ, distance float64) bool

判断两点是否相近 用于转发附近消息

func NewVarSet

func NewVarSet() encodingx.IKeyValue

Types

type ChannelType

type ChannelType uint16
const (
	//无效
	None ChannelType = iota
	//状态
	StatusChannel
	//聊天
	ChatChannel
	//事件
	EventChannel
)

type EntityType

type EntityType uint16
const (
	EntityWorld EntityType = 1 << iota
	EntityZone
	EntityRoom
	EntityUser
	EntityTeamCorps
	EntityTeam
	EntityChannel

	EntityNone EntityType = 0
	EntityAll  EntityType = EntityWorld | EntityZone | EntityRoom | EntityUser | EntityTeamCorps | EntityTeam | EntityChannel
)

func (EntityType) Include

func (t EntityType) Include(check EntityType) bool

func (EntityType) Match

func (t EntityType) Match(check EntityType) bool

type IChannelBehavior

type IChannelBehavior interface {
	MyChannel() IChannelEntity
	//订阅频道
	TouchChannel(subscriber string)
	//取消频道订阅
	UnTouchChannel(subscriber string)
	//消息广播
	Broadcast(speaker string, handler func(receiver string)) int
	//消息指定目标广播
	BroadcastSome(speaker string, receiver []string, handler func(receiver string)) int
}

频道行为

type IChannelEntity

type IChannelEntity interface {
	IEntity
	IInitEntity
	IChannelBehavior
}

频道实体

type IChannelIndex

type IChannelIndex interface {
	IEntityIndex
	//检查Channel是否存在
	CheckChannel(chanId string) bool
	//获取Channel
	GetChannel(chanId string) IChannelEntity
	//从索引中增加一个Channel
	AddChannel(channel IChannelEntity) error
	//从索引中移除一个Channel
	RemoveChannel(chanId string) (IChannelEntity, error)
	//从索引中更新一个Channel
	UpdateChannel(channel IChannelEntity) error
}

频道索引

type IDestroyEntity

type IDestroyEntity interface {
	//释放实体
	DestroyEntity()
}

type IEntity

type IEntity interface {
	//唯一标识
	UID() string
	//昵称,显示使用
	NickName() string
	//实体类型
	EntityType() EntityType
}

type IEntityChild

type IEntityChild interface {
	GetParent() string
	NoneParent() bool

	SetParent(ownerId string)
	ClearParent()
}

type IEntityContainer

type IEntityContainer interface {
	NumChildren() int
	Full() bool

	Contains(entity IEntity) (isContains bool)
	ContainsById(entityId string) (isContains bool)
	GetChildById(entityId string) (entity IEntity, ok bool)
	ReplaceChildInto(entity IEntity) error
	AddChild(entity IEntity) error
	RemoveChild(entity IEntity) error
	RemoveChildById(entityId string) (entity IEntity, ok bool)

	ForEachChild(each func(child IEntity) (interruptCurrent bool, interruptRecurse bool))
	ForEachChildByType(entityType EntityType, each func(child IEntity), recurse bool)
}

type IEntityGroup

type IEntityGroup interface {
	//接纳实体的类型
	EntityType() EntityType
	//最大实例数
	MaxLen() int
	//实体数量
	Len() int
	//实体已满
	IsFull() bool

	//包含实体id
	Entities() []string
	//包含实体id
	CopyEntities() []string
	//检查实体是否属于当前组
	ContainEntity(entityId string) bool

	//加入实体到组,进行唯一性检查
	Accept(entity string) error
	//加入实体到组,进行唯一性检查
	AcceptMulti(entityId []string) (count int, err error)
	//从组中移除实体
	Drop(entityId string) error
	//从组中移除实体
	DropMulti(entityId []string) (count int, err error)
}

type IEntityIndex

type IEntityIndex interface {
	EntityType() EntityType
	//检查存在
	Check(id string) bool
	//获取one
	Get(id string) IEntity
	//添加
	Add(entity IEntity) error
	//从索引中移除
	Remove(id string) (IEntity, error)
	//更新
	Update(entity IEntity) error
}

type IInitEntity

type IInitEntity interface {
	//初始化实体
	InitEntity()
}

type IManagerBase

type IManagerBase interface {
	logx.ILoggerSetter
	InitManager()
	DisposeManager()
}

type IRoomEntity

type IRoomEntity interface {
	IEntity
	IInitEntity
	IEntityChild

	//IUserGroup
	IEntityContainer
	IVariableSupport
}

房间实体

type IRoomGroup

type IRoomGroup interface {
	//房间列表
	RoomList() []string
	//检查房间存在性
	ContainRoom(roomId string) bool
	//添加房间
	AddRoom(roomId string) error
	//移除房间
	RemoveRoom(roomId string) error
}

type IRoomIndex

type IRoomIndex interface {
	IEntityIndex
	//检查Room是否存在
	CheckRoom(roomId string) bool
	//获取Room
	GetRoom(roomId string) IRoomEntity
	//添加一个新Room到索引中
	AddRoom(room IRoomEntity) error
	//从索引中移除一个Room
	RemoveRoom(roomId string) (IRoomEntity, error)
	//从索引中更新一个Room
	UpdateRoom(room IRoomEntity) error
}

房间索引

type ITeamControl

type ITeamControl interface {
	//队长
	Leader() string
	//用户列表
	MemberList() []string
	//检查用户
	ContainMember(memberId string) bool
	//加入用户,进行唯一性检查
	AcceptMember(memberId string) error
	//从组中移除用户
	DropMember(memberId string) error
	//从组中移除用户
	RiseLeader(memberId string) error
	//解散队伍
	DisbandTeam() error
}

type ITeamCorpsEntity

type ITeamCorpsEntity interface {
	IEntity
	IEntityChild
	IInitEntity

	IEntityContainer
	//ITeamGroup
	IVariableSupport
}

兵团实体

type ITeamCorpsIndex

type ITeamCorpsIndex interface {
	IEntityIndex
	//检查Corps是否存在
	CheckCorps(corpsId string) bool
	//获取Corps
	GetCorps(corpsId string) ITeamCorpsEntity
	//添加一个新Corps到索引中
	AddCorps(corps ITeamCorpsEntity) error
	//从索引中移除一个Corps
	RemoveCorps(corpsId string) (ITeamCorpsEntity, error)
	//更新一个新Corps到索引中
	UpdateCorps(corps ITeamCorpsEntity) error
}

type ITeamEntity

队伍实体

type ITeamGroup

type ITeamGroup interface {
	//队伍列表
	TeamList() []string
	//检查队伍存在性
	ContainTeam(roomId string) bool
	//添加房间
	AddTeam(roomId string) error
	//移除房间
	RemoveTeam(roomId string) error
}

type ITeamIndex

type ITeamIndex interface {
	IEntityIndex
	//检查Team是否存在
	CheckTeam(teamId string) bool
	//获取Team
	GetTeam(teamId string) ITeamEntity
	//添加一个新Team到索引中
	AddTeam(team ITeamEntity) error
	//从索引中移除一个Team
	RemoveTeam(teamId string) (ITeamEntity, error)
	//从索引中更新一个Team
	UpdateTeam(team ITeamEntity) error
}

队伍索引

type IUserBlackList

type IUserBlackList interface {
	//通信黑名单,返回原始切片,如果要修改的,请先copy
	Blacks() []string
	//增加黑名单
	AddBlack(targetId string) error
	//移除黑名单
	RemoveBlack(targetId string) error
	//处于
	OnBlack(targetId string) bool
}

黑名单

type IUserEntity

type IUserEntity interface {
	IEntity
	IInitEntity
	IDestroyEntity
	IUserSubscriber
	IVariableSupport
	//用户名
	UserName() string

	GetLocation() (idType EntityType, id string)
	SetLocation(idType EntityType, id string)

	GetTeamInfo() (teamId string, corpsId string)
	SetTeam(teamId string)
	SetCorps(corpsId string)

	GetPosition() XYZ
	SetPosition(pos XYZ)
}

用户实体

type IUserGroup

type IUserGroup interface {
	//用户列表
	UserList() []string
	//检查用户
	ContainUser(userId string) bool
	//加入用户,进行唯一性检查
	AcceptUser(userId string) error
	//从组中移除用户
	DropUser(userId string) error
}

type IUserIndex

type IUserIndex interface {
	IEntityIndex
	//检查User是否存在
	CheckUser(userId string) bool
	//获取User
	GetUser(userId string) IUserEntity
	//添加一个新User到索引中
	AddUser(user IUserEntity) error
	//从索引中移除一个User
	RemoveUser(userId string) (IUserEntity, error)
	//从索引中更新一个User
	UpdateUser(user IUserEntity) error
}

玩家索引

type IUserSubscriber

type IUserSubscriber interface {
	IUserWhiteList
	IUserBlackList
	//处于激活
	OnActive(targetId string) bool
}

参与者

type IUserWhiteList

type IUserWhiteList interface {
	//通信白名单,返回原始切片,如果要修改的,请先copy
	Whites() []string
	//增加白名单
	AddWhite(targetId string) error
	//移除白名单
	RemoveWhite(targetId string) error
	//处于
	OnWhite(targetId string) bool
}

黑名单

type IVariableSupport

type IVariableSupport interface {
	eventx.IEventDispatcher
	SetVar(key string, value interface{})
	SetVars(kv encodingx.IKeyValue)
	GetVar(key string) (interface{}, bool)
	Vars() encodingx.IKeyValue

	CheckVar(key string) bool
	RemoveVar(key string)
}

变量列表

type IWorldEntity

type IWorldEntity interface {
	IEntity
	IInitEntity

	IEntityContainer
	//IZoneGroup
	IVariableSupport
}

世界实体

type IWorldIndex

type IWorldIndex interface {
	IEntityIndex
	//检查World是否存在
	CheckWorld(worldId string) bool
	//获取World
	GetWorld(worldId string) IWorldEntity
	//添加一个新World到索引中
	AddWorld(world IWorldEntity) error
	//从索引中移除一个World
	RemoveWorld(worldId string) (IWorldEntity, error)
	//更新一个新World到索引中
	UpdateWorld(zone IWorldEntity) error
}

type IZoneEntity

type IZoneEntity interface {
	IEntity
	IEntityChild
	IInitEntity

	IEntityContainer
	//IRoomGroup
	IVariableSupport
}

区域实体

type IZoneGroup

type IZoneGroup interface {
	//区域列表
	ZoneList() []string
	//检查区域存在性
	ContainZone(zoneId string) bool
	//添加区域
	AddZone(zoneId string) error
	//移除区域
	RemoveZone(zoneId string) error
}

type IZoneIndex

type IZoneIndex interface {
	IEntityIndex
	//检查Zone是否存在
	CheckZone(zoneId string) bool
	//获取Zone
	GetZone(zoneId string) IZoneEntity
	//添加一个新Zone到索引中
	AddZone(zone IZoneEntity) error
	//从索引中移除一个Zone
	RemoveZone(zoneId string) (IZoneEntity, error)
	//更新一个新Zone到索引中
	UpdateZone(zone IZoneEntity) error
}

type XY

type XY struct {
	X float64
	Y float64
}

type XYZ

type XYZ struct {
	X float64
	Y float64
	Z float64
}

func (XYZ) XY

func (xyz XYZ) XY() XY

Jump to

Keyboard shortcuts

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