UNPKG

wonder.js

Version:
53 lines (47 loc) 3.39 kB
'use strict'; var Log$WonderLog = require("wonder-log/lib/js/src/Log.js"); var Contract$WonderLog = require("wonder-log/lib/js/src/Contract.js"); var ArrayService$Wonderjs = require("../../../atom/ArrayService.js"); var StateDataMain$Wonderjs = require("../data/StateDataMain.js"); var IsDebugMainService$Wonderjs = require("../state/IsDebugMainService.js"); var ArrayService$WonderCommonlib = require("wonder-commonlib/lib/js/src/ArrayService.js"); var GameObjectsMapService$Wonderjs = require("../../../primitive/GameObjectsMapService.js"); var OperateSettingService$Wonderjs = require("../../../record/main/setting/OperateSettingService.js"); var JudgeAllInstanceService$Wonderjs = require("../../../record/all/instance/JudgeAllInstanceService.js"); var HasComponentGameObjectService$Wonderjs = require("../../../record/main/gameObject/HasComponentGameObjectService.js"); var MutableSparseMapService$WonderCommonlib = require("wonder-commonlib/lib/js/src/MutableSparseMapService.js"); function isSupportInstance(state) { return JudgeAllInstanceService$Wonderjs.isSupportInstance(OperateSettingService$Wonderjs.unsafeGetGPU(state[/* settingRecord */0])[/* useHardwareInstance */0], state[/* gpuDetectRecord */5]); } function isSourceInstance(materialIndex, gameObjectsMap, gameObjectRecord) { Contract$WonderLog.requireCheck((function (param) { return Contract$WonderLog.test(Log$WonderLog.buildAssertMessage("all gameObjects are or are not sourceInstance", "some are, the others are not"), (function (param) { var gameObjects = GameObjectsMapService$Wonderjs.getGameObjects(materialIndex, gameObjectsMap); if (gameObjects !== undefined) { var gameObjects$1 = gameObjects; var gameObjectsLen = gameObjects$1.length; var isSourceInstanceLen = gameObjects$1.filter((function (gameObject) { return HasComponentGameObjectService$Wonderjs.hasSourceInstanceComponent(gameObject, gameObjectRecord); })).length; return Contract$WonderLog.assertTrue(isSourceInstanceLen === gameObjectsLen || isSourceInstanceLen === 0); } else { return Contract$WonderLog.assertPass(/* () */0); } })); }), IsDebugMainService$Wonderjs.getIsDebug(StateDataMain$Wonderjs.stateData)); var match = GameObjectsMapService$Wonderjs.getGameObjects(materialIndex, gameObjectsMap); if (match !== undefined) { return HasComponentGameObjectService$Wonderjs.hasSourceInstanceComponent(ArrayService$Wonderjs.unsafeGetFirst(match), gameObjectRecord); } else { return false; } } function buildMap(index, gameObjectsMap, gameObjectRecord) { return ArrayService$WonderCommonlib.reduceOneParam((function (map, materialIndex) { return MutableSparseMapService$WonderCommonlib.set(materialIndex, isSourceInstance(materialIndex, gameObjectsMap, gameObjectRecord), map); }), MutableSparseMapService$WonderCommonlib.createEmpty(/* () */0), ArrayService$Wonderjs.range(0, index - 1 | 0)); } exports.isSupportInstance = isSupportInstance; exports.isSourceInstance = isSourceInstance; exports.buildMap = buildMap; /* Log-WonderLog Not a pure module */