新增蓝图结点

This commit is contained in:
boyce
2025-11-07 14:16:47 +08:00
parent f8953d1764
commit b78d9721f2
2 changed files with 53 additions and 16 deletions

View File

@@ -50,6 +50,7 @@ func (bm *Blueprint) regSysNode(){
bm.RegExecNode(&LessThanInteger{}) bm.RegExecNode(&LessThanInteger{})
bm.RegExecNode(&EqualInteger{}) bm.RegExecNode(&EqualInteger{})
bm.RegExecNode(&RangeCompare{}) bm.RegExecNode(&RangeCompare{})
bm.RegExecNode(&EqualSwitch{})
bm.RegExecNode(&Probability{}) bm.RegExecNode(&Probability{})
bm.RegExecNode(&CreateTimer{}) bm.RegExecNode(&CreateTimer{})
} }
@@ -113,6 +114,10 @@ func (bm *Blueprint) Do(graphID int64, entranceID int64, args ...any) (Port_Arra
} }
func (bm *Blueprint) ReleaseGraph(graphID int64) { func (bm *Blueprint) ReleaseGraph(graphID int64) {
if graphID == 0 {
return
}
defer delete(bm.mapGraph, graphID) defer delete(bm.mapGraph, graphID)
graph := bm.mapGraph[graphID] graph := bm.mapGraph[graphID]
if graph == nil { if graph == nil {

View File

@@ -15,8 +15,6 @@ const (
EntranceID_Timer = 3 EntranceID_Timer = 3
) )
type Entrance_ArrayParam struct { type Entrance_ArrayParam struct {
BaseExecNode BaseExecNode
} }
@@ -471,6 +469,40 @@ func (em *RangeCompare) Exec() (int, error) {
return 0, nil return 0, nil
} }
// EqualSwitch 等于分支==
type EqualSwitch struct {
BaseExecNode
}
func (em *EqualSwitch) GetName() string {
return "EqualSwitch"
}
func (em *EqualSwitch) Exec() (int, error) {
inPortA := em.GetInPort(1)
if inPortA == nil {
return -1, fmt.Errorf("GreaterThanInteger inParam 1 not found")
}
ret, ok := inPortA.GetInt()
if !ok {
return -1, fmt.Errorf("GreaterThanInteger inParam 1 error")
}
intArray := em.execNode.GetInPortDefaultIntArrayValue(2)
if intArray == nil {
return 0, nil
}
for i := 0; i < len(intArray) && i < em.GetOutPortCount()-2; i++ {
if ret == intArray[i] {
return i + 2, nil
}
}
return 0, nil
}
// Probability 概率判断(万分比) // Probability 概率判断(万分比)
type Probability struct { type Probability struct {
BaseExecNode BaseExecNode