@gmetrixr/rjson
Version:
(R)ecursive Json
39 lines (38 loc) • 1.66 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const r_1 = require("../../../r");
/**
* Remove rules when events and then actions for collider mesh element
*/
class Migration {
execute(projectJson) {
const pJson = projectJson;
const projectF = r_1.r.record(pJson);
const scenes = projectF.getRecords(r_1.RT.scene);
for (const scene of scenes) {
const sceneF = r_1.r.scene(scene);
const colliderMeshElements = sceneF.getAllDeepChildrenIdsWithFilter(r_1.RT.element, (el) => el.props.element_type === r_1.en.ElementType.collider_mesh);
if (colliderMeshElements.length > 0) {
const rules = sceneF.getRecords(r_1.RT.rule);
for (const rule of rules) {
const ruleF = r_1.r.record(rule);
const whenEvents = ruleF.getRecords(r_1.RT.when_event);
for (const we of whenEvents) {
if (colliderMeshElements.includes(we.props.co_id)) {
ruleF.deleteRecord(r_1.RT.when_event, we.id);
}
}
const thenActions = ruleF.getRecords(r_1.RT.then_action);
for (const ta of thenActions) {
if (colliderMeshElements.includes(ta.props.co_id)) {
ruleF.deleteRecord(r_1.RT.then_action, ta.id);
}
}
}
}
}
projectF.set(r_1.rtp.project.version, 148);
}
}
const migration = new Migration();
exports.default = migration;