import{createUnityColor}from"../../../unity/tool";import{REQUEST_TYPE}from"../../../unity/model-api";import{merge}from"lodash";const defaultFireSetting={size:1,density:1,color:createUnityColor("#ff0000ff")};export let FenceType=function(a){return a.HoneycombFence="HoneycombFence",a.WireFrameFence="WireFrameFence",a.LaserFence="LaserFence",a}({});const defaultFenceSetting={style:FenceType.HoneycombFence,color:createUnityColor("#ff0000ff"),intensity:1,height:40,speed:1,gap:1,size:1,wireThickness:.25};export let AreaEffectType=function(a){return a.AreaFire="AreaFire",a.AreaFence="AreaFence",a}({});export const createArea=async(a,b)=>{var c,d;let e;if(a.effectType===AreaEffectType.AreaFire)e=merge(defaultFireSetting,a.setting?a.setting:{});else if(a.effectType===AreaEffectType.AreaFence)e=merge(defaultFenceSetting,a.setting?a.setting:{});else throw new Error("\u672A\u77E5 `\u9762\u7279\u6548` \u7C7B\u578B\uFF1A"+a.effectType);let f=a.positions.map(a=>({X:a.x,Y:a.y,Z:a.z}));if(0===f.length)throw new Error("Positions \u4E3A\u7A7A");const{ID:g}=await b.unity.invoke(REQUEST_TYPE.CreatAreaEffect,{EffectType:a.effectType,SpaceID:a.spaceID,Positions:f,Setting:{Size:e.size,Density:e.density,Style:e.style,Intensity:e.intensity,Height:e.height,Speed:e.speed,Gap:e.gap,WireThickness:e.wireThickness,Color:null!==(c=a.setting)&&void 0!==c&&c.color?createUnityColor(null===(d=a.setting)||void 0===d?void 0:d.color):e.color}});return{id:g,remove:()=>{b.unity.invoke(REQUEST_TYPE.RemoveAreaEffect,{Ids:[g]})}}};