新增蓝图热更新功能

This commit is contained in:
boyce
2025-11-17 15:01:51 +08:00
parent 027e83b706
commit eaf20c4e3a
4 changed files with 136 additions and 46 deletions

View File

@@ -4,16 +4,20 @@ import (
"fmt"
"time"
"github.com/duanhf2012/origin/v2/log"
"github.com/duanhf2012/origin/v2/service"
"github.com/goccy/go-json"
"github.com/duanhf2012/origin/v2/log"
)
const ReturnVarial = "g_Return"
var IsDebug = false
type IGraph interface {
Do(entranceID int64, args ...any) (Port_Array, error)
Release()
GetGraphFileName() string
HotReload(newBaseGraph *baseGraph)
}
type IBlueprintModule interface {
@@ -30,7 +34,7 @@ type baseGraph struct {
type Graph struct {
graphFileName string
graphID int64
graphID int64
*baseGraph
graphContext
IBlueprintModule
@@ -140,7 +144,7 @@ func (gc *graphConfig) GetNodeByID(nodeID string) *nodeConfig {
func (gr *Graph) Do(entranceID int64, args ...any) (Port_Array, error) {
if IsDebug {
log.Debug("Graph Do", log.String("graphName",gr.graphFileName),log.Int64("graphID", gr.graphID), log.Int64("entranceID", entranceID))
log.Debug("Graph Do", log.String("graphName", gr.graphFileName), log.Int64("graphID", gr.graphID), log.Int64("entranceID", entranceID))
}
entranceNode := gr.entrance[entranceID]
@@ -204,3 +208,11 @@ func (gr *Graph) Release() {
// 清理掉所有数据
*gr = Graph{}
}
func (gr *Graph) HotReload(newBaseGraph *baseGraph) {
gr.baseGraph = newBaseGraph
}
func (gr *Graph) GetGraphFileName() string{
return gr.graphFileName
}