(function() {
'use strict';
var pluginName = 'NearEventSensor';
var metaTagPrefix = 'NES';
var getParamOther = function(paramNames) {
if (!Array.isArray(paramNames)) paramNames = [paramNames];
for (var i = 0; i < paramNames.length; i++) {
var name = PluginManager.parameters(pluginName)[paramNames];
if (name) return name;
}
return null;
};
var getParamNumber = function(paramNames, min, max) {
var value = getParamOther(paramNames);
if (arguments.length < 2) min = -Infinity;
if (arguments.length < 3) max = Infinity;
return (parseInt(value, 10) || 0).clamp(min, max);
};
var getParamBoolean = function(paramNames) {
var value = (getParamOther(paramNames) || '').toUpperCase();
return value === 'ON' || value === 'TRUE';
};
var getParamJson = function(paramNames, defaultValue) {
var value = getParamOther(paramNames);
try {
value = JSON.parse(value);
if (value === null) {
value = defaultValue;
}
} catch (e) {
alert(`!!!Plugin param is wrong.!!!\nPlugin:.js\nName:[]\nValue:`);
value = defaultValue;
}
return value;
};
var getArgNumber = function(arg, min, max) {
if (arguments.length < 2) min = -Infinity;
if (arguments.length < 3) max = Infinity;
return (parseInt(convertEscapeCharacters(arg), 10) || 0).clamp(min, max);
};
var getMetaValue = function(object, name) {
var metaTagName = metaTagPrefix + (name ? name : '');
return object.meta.hasOwnProperty(metaTagName) ? object.meta[metaTagName] : undefined;
};
var getMetaValues = function(object, names) {
if (!Array.isArray(names)) return getMetaValue(object, names);
for (var i = 0, n = names.length; i < n; i++) {
var value = getMetaValue(object, names);
if (value !== undefined) return value;
}
return undefined;
};
var convertEscapeCharacters = function(text) {
if (text == null) text = '';
var windowLayer = SceneManager._scene._windowLayer;
return windowLayer ? windowLayer.children[0].convertEscapeCharacters(text) : text;
};
//=============================================================================
// パラメータの取得と整形
//=============================================================================
var paramDefaultFlash = getParamBoolean(['DefaultFlash', 'デフォルトフラッシュ']);
var paramDefaultBalloon = getParamNumber(['DefaultBalloon', 'デフォルトフキダシ'], 0);
var paramDisableEmpty = getParamBoolean(['DisableEmpty', '空イベントは無効']);
var paramSensorDistance = getParamNumber(['SensorDistance', '感知距離'], 1);
var paramFlashColor = getParamJson(['FlashColor', 'フラッシュカラー'], null);
var paramFlashDuration = getParamNumber(['FlashDuration', 'フラッシュ時間'], 1);
var paramBalloonInterval = getParamNumber(['BalloonInterval', 'フキダシ間隔'], 0);
var paramConsiderationDir = getParamBoolean(['ConsiderationDir', '向きを考慮']);
if (paramFlashColor) {
paramFlashColor = [paramFlashColor.Red, paramFlashColor.Green, paramFlashColor.Blue, paramFlashColor.Alpha];
}