实现更多的触发器

This commit is contained in:
flswld
2023-04-08 22:53:41 +08:00
parent 630c0444a0
commit e554b99e7e
14 changed files with 1065 additions and 364 deletions

View File

@@ -1,12 +1,20 @@
package model
import (
"hk4e/common/constant"
"hk4e/gdconf"
)
type DbSceneGroup struct {
VariableMap map[string]int32
KillConfigMap map[uint32]bool
GadgetStateMap map[uint32]uint8
}
type DbScene struct {
SceneId uint32
UnlockPointMap map[uint32]bool
SceneGroupMap map[uint32]*DbSceneGroup
}
type DbWorld struct {
@@ -31,6 +39,7 @@ func NewScene(sceneId uint32) *DbScene {
r := &DbScene{
SceneId: sceneId,
UnlockPointMap: make(map[uint32]bool),
SceneGroupMap: make(map[uint32]*DbSceneGroup),
}
return r
}
@@ -70,3 +79,59 @@ func (s *DbScene) CheckPointUnlock(pointId uint32) bool {
_, exist := s.UnlockPointMap[pointId]
return exist
}
func (s *DbScene) GetSceneGroupById(groupId uint32) *DbSceneGroup {
dbSceneGroup, exist := s.SceneGroupMap[groupId]
if !exist {
dbSceneGroup = &DbSceneGroup{
VariableMap: make(map[string]int32),
KillConfigMap: make(map[uint32]bool),
GadgetStateMap: make(map[uint32]uint8),
}
s.SceneGroupMap[groupId] = dbSceneGroup
}
return dbSceneGroup
}
func (g *DbSceneGroup) GetVariableByName(name string) int32 {
return g.VariableMap[name]
}
func (g *DbSceneGroup) SetVariable(name string, value int32) {
g.VariableMap[name] = value
}
func (g *DbSceneGroup) CheckVariableExist(name string) bool {
_, exist := g.VariableMap[name]
return exist
}
func (g *DbSceneGroup) AddKill(configId uint32) {
g.KillConfigMap[configId] = true
}
func (g *DbSceneGroup) CheckIsKill(configId uint32) bool {
_, exist := g.KillConfigMap[configId]
return exist
}
func (g *DbSceneGroup) RemoveAllKill() {
g.KillConfigMap = make(map[uint32]bool)
}
func (g *DbSceneGroup) GetGadgetState(configId uint32) uint8 {
state, exist := g.GadgetStateMap[configId]
if !exist {
return constant.GADGET_STATE_DEFAULT
}
return state
}
func (g *DbSceneGroup) ChangeGadgetState(configId uint32, state uint8) {
g.GadgetStateMap[configId] = state
}
func (g *DbSceneGroup) CheckGadgetExist(configId uint32) bool {
_, exist := g.GadgetStateMap[configId]
return exist
}