Files
lity3d/Engine/VisualScript/block_executor.h
T
shuiyu1123 0669d102ce feat: major engine overhaul - scene demo with lighting, sphere, ground
- Scene Demo: cube + sphere + ground plane with proper lighting
- Audio: XAudio2 dynamic loading + WAV playback
- Physics: expanded collision system
- Renderer: improved pipeline with materials
- UI: extended widget system
- VisualScript: enhanced serializer + block interactions
- ASM: optimized math/memory/profiling routines
- Window: mouse input + scroll support
2026-07-12 08:21:07 +08:00

87 lines
2.0 KiB
C

#pragma once
// ============================================================================
// block_executor.h - 积木执行引擎
// ============================================================================
#include "block_workspace.h"
#define MAX_VARIABLES 256
#define MAX_CALL_STACK 32
#define MAX_EXEC_STACK 1024
#define MAX_LOOP_STACK 32
// 变量
typedef struct {
char name[64];
SlotValue value;
int used;
} Variable;
// 调用帧
typedef struct {
Block* block;
Block* return_block;
} CallFrame;
// 循环帧
typedef struct {
Block* loop_block;
int counter;
int target;
Block* after_block;
} LoopFrame;
// 执行状态
typedef enum {
EXEC_IDLE = 0,
EXEC_RUNNING,
EXEC_WAITING,
EXEC_PAUSED,
EXEC_ERROR
} ExecState;
// 执行器
typedef struct BlockExecutor {
BlockWorkspace* workspace;
ExecState state;
Variable variables[MAX_VARIABLES];
int variable_count;
CallFrame call_stack[MAX_CALL_STACK];
int call_stack_top;
LoopFrame loop_stack[MAX_LOOP_STACK];
int loop_stack_top;
Block* current_block;
double wait_timer;
int breakpoint_enabled;
Block* breakpoint_block;
} BlockExecutor;
// 初始化/销毁
BlockExecutor* executor_create(BlockWorkspace* ws);
void executor_destroy(BlockExecutor* exec);
// 控制
void executor_start(BlockExecutor* exec);
void executor_stop(BlockExecutor* exec);
void executor_pause(BlockExecutor* exec);
void executor_resume(BlockExecutor* exec);
void executor_step(BlockExecutor* exec);
// 更新 (每帧调用)
void executor_update(BlockExecutor* exec, double delta_time);
// 变量操作
void executor_set_variable(BlockExecutor* exec, const char* name, SlotValue value);
SlotValue executor_get_variable(BlockExecutor* exec, const char* name);
void executor_create_variable(BlockExecutor* exec, const char* name);
// 日志回调
typedef void (*LogCallback)(const char* msg, int level);
void executor_set_log_callback(LogCallback cb);