Initial flame_lua_runtime package
This commit is contained in:
64
lib/runtime/models/runtime_event.dart
Normal file
64
lib/runtime/models/runtime_event.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
class RuntimeEvent {
|
||||
const RuntimeEvent({
|
||||
required this.type,
|
||||
this.target,
|
||||
this.handler,
|
||||
this.x,
|
||||
this.y,
|
||||
this.data = const {},
|
||||
this.sessionId,
|
||||
this.scope,
|
||||
this.targetEpoch,
|
||||
this.scopeEpoch,
|
||||
});
|
||||
|
||||
final String type;
|
||||
final String? target;
|
||||
final String? handler;
|
||||
final double? x;
|
||||
final double? y;
|
||||
final Map<String, Object?> data;
|
||||
|
||||
/// Runtime-internal lifecycle session. Not exposed to Lua.
|
||||
final int? sessionId;
|
||||
|
||||
/// Runtime-internal lifecycle scope. Not exposed to Lua.
|
||||
final String? scope;
|
||||
|
||||
/// Runtime-internal target node epoch. Not exposed to Lua.
|
||||
final int? targetEpoch;
|
||||
|
||||
/// Runtime-internal scope node epoch. Not exposed to Lua.
|
||||
final int? scopeEpoch;
|
||||
|
||||
RuntimeEvent withLifecycle({
|
||||
int? sessionId,
|
||||
String? scope,
|
||||
int? targetEpoch,
|
||||
int? scopeEpoch,
|
||||
}) {
|
||||
return RuntimeEvent(
|
||||
type: type,
|
||||
target: target,
|
||||
handler: handler,
|
||||
x: x,
|
||||
y: y,
|
||||
data: data,
|
||||
sessionId: sessionId ?? this.sessionId,
|
||||
scope: scope ?? this.scope,
|
||||
targetEpoch: targetEpoch ?? this.targetEpoch,
|
||||
scopeEpoch: scopeEpoch ?? this.scopeEpoch,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, Object?> toMap() {
|
||||
return {
|
||||
'type': type,
|
||||
if (target != null) 'target': target,
|
||||
if (handler != null) 'handler': handler,
|
||||
if (x != null) 'x': x,
|
||||
if (y != null) 'y': y,
|
||||
if (data.isNotEmpty) 'data': data,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user