wonder.js
Version:
60 lines (53 loc) • 2.44 kB
JavaScript
;
var Caml_array = require("bs-platform/lib/js/caml_array.js");
var Log$WonderLog = require("wonder-log/lib/js/src/Log.js");
var GameObjectScriptMainService$Wonderjs = require("./GameObjectScriptMainService.js");
var MutableSparseMapService$WonderCommonlib = require("wonder-commonlib/lib/js/src/MutableSparseMapService.js");
var GetIsActiveGameObjectMainService$Wonderjs = require("../gameObject/GetIsActiveGameObjectMainService.js");
function getIsActive(script, state) {
var scriptRecord = state[/* scriptRecord */27];
return MutableSparseMapService$WonderCommonlib.get(script, scriptRecord[/* isActiveMap */4]);
}
function unsafeGetIsActive(script, state) {
var match = getIsActive(script, state);
if (match !== undefined) {
return match;
} else {
return true;
}
}
function _setIsActive(script, isActive, state) {
var scriptRecord = state[/* scriptRecord */27];
var newrecord = Caml_array.caml_array_dup(state);
newrecord[/* scriptRecord */27] = /* record */[
/* index */scriptRecord[/* index */0],
/* isScriptEventFunctionEnable */scriptRecord[/* isScriptEventFunctionEnable */1],
/* disposedIndexArray */scriptRecord[/* disposedIndexArray */2],
/* gameObjectMap */scriptRecord[/* gameObjectMap */3],
/* isActiveMap */MutableSparseMapService$WonderCommonlib.set(script, isActive, scriptRecord[/* isActiveMap */4]),
/* scriptEventFunctionDataMap */scriptRecord[/* scriptEventFunctionDataMap */5],
/* scriptAttributeMap */scriptRecord[/* scriptAttributeMap */6]
];
return newrecord;
}
function setIsActive(script, isActive, state) {
var scriptRecord = state[/* scriptRecord */27];
var match = GameObjectScriptMainService$Wonderjs.getGameObject(script, scriptRecord);
if (match !== undefined) {
var gameObject = match;
var match$1 = !GetIsActiveGameObjectMainService$Wonderjs.unsafeGetIsActive(gameObject, state) && isActive;
if (match$1) {
Log$WonderLog.warn("script:" + (String(script) + (" -> gameObject:" + (String(gameObject) + " isn\'t active, can\'t set script to active"))));
return state;
} else {
return _setIsActive(script, isActive, state);
}
} else {
return _setIsActive(script, isActive, state);
}
}
exports.getIsActive = getIsActive;
exports.unsafeGetIsActive = unsafeGetIsActive;
exports._setIsActive = _setIsActive;
exports.setIsActive = setIsActive;
/* Log-WonderLog Not a pure module */