import { _decorator, Component, Director, director, instantiate, Node, Size, Vec2, Vec3 } from 'cc';
import { ClientEvent } from '../clientEvent';
import { config } from '../config';
import { att_ani_data, att_click_data, att_count_down, att_drag_data, att_question_select, att_text_sound_data, att_top_data, attributes_data, scene_tips_rule_data, widget_item_data } from '../../data/data';
import { attributes_name } from './attributes/attributes_name';
import { attributes_x_y } from './attributes/attributes_x_y';
import { attributes_w_h } from './attributes/attributes_w_h';
import { attributes_res } from './attributes/attributes_res';
import { main } from '../main';
import { attributes_origin } from './attributes/attributes_origin';
import { attributes_delete } from './attributes/attributes_delete';
import { attributes_drop } from './attributes/attributes_drop';
import { attributes_slide } from './attributes/attributes_slide';
import { attributes_click } from './attributes/attributes_click';
import { attributes_be_active } from './attributes/attributes_be_active';
import { attributes_animation } from './attributes/attributes_animation';
import { attributes_active } from './attributes/attributes_active';
import { tools } from '../tools';
import { attributes_top } from './attributes/attributes_top';
import { attributes_text_sound } from './attributes/attributes_text_sound';
import { attributes_question_select } from './attributes/attributes_question_select';
import { attributes_count_down } from './attributes/attributes_count_down';
import { attributes_z_index } from './attributes/attributes_z_index';
import { attributes_dir } from './attributes/attributes_dir';
import { attributes_show } from './attributes/attributes_show';
import { attributes_scene_setting } from './attributes/attributes_scene_setting';
import { attributes_remark } from './attributes/attributes_remark';
import { attributes_rotation } from './attributes/attributes_rotation';
import { attributes_anchor } from './attributes/attributes_anchor';
const { ccclass, property } = _decorator;

@ccclass('Attributes')
export class Attributes extends Component {
    private attributes_map:Map<string,Node> = new Map
    @property(Node) attributes_name:Node = null;
    @property(Node) attributes_remark:Node = null;
    @property(Node) attributes_x_y:Node = null;
    @property(Node) attributes_w_h:Node = null;
    @property(Node) attributes_anchor:Node = null;
    @property(Node) attributes_rotation:Node = null;
    @property(Node) attributes_res:Node = null;
    @property(Node) attributes_origin:Node = null;
    @property(Node) attributes_be_event:Node = null; //被动事件
    @property(Node) attributes_animation:Node = null; //动画
    @property(Node) attributes_drop:Node = null; 
    @property(Node) attributes_click:Node = null; 
    @property(Node) attributes_slide:Node = null; 
    @property(Node) attributes_delete:Node = null;
    @property(Node) attributes_be_active:Node = null;
    @property(Node) attributes_active:Node = null;
    @property(Node) attributes_top:Node = null;
    @property(Node) attributes_text_sound:Node = null;
    @property(Node) attributes_question_select:Node = null;
    @property(Node) attributes_count_down:Node = null;
    @property(Node) attributes_z_index:Node = null;
    @property(Node) attributes_dir:Node = null;
    @property(Node) attributes_show:Node = null;
    @property(Node) attributes_scene_setting:Node = null;
    @property(Node) content:Node = null;
    private cur_att_data:attributes_data = null;
    private _main:main = null;
    public static Singleton:Attributes = null;
    public static is_show_more_scene_arrow:boolean = true; //是否显示多场景箭头
    start() {
        Attributes.Singleton = this;
        ClientEvent.on(config.Event.UpdateAttributes,this.UpdateAttributes,this)
        ClientEvent.on(config.Event.ShowWidgetList,this.ShowWidgetList,this)
        this.attributes_map.set("name",this.attributes_name)
        this.attributes_map.set("remark",this.attributes_remark)
        this.attributes_map.set("pos",this.attributes_x_y)
        this.attributes_map.set("size",this.attributes_w_h)
        this.attributes_map.set("anchor",this.attributes_anchor)
        this.attributes_map.set("rotation",this.attributes_rotation)
        this.attributes_map.set("url",this.attributes_res)
        this.attributes_map.set("origin",this.attributes_origin)
        // this.attributes_map.set("be_event",this.attributes_be_event)
        this.attributes_map.set("animation",this.attributes_animation)
        this.attributes_map.set("drop",this.attributes_drop)
        this.attributes_map.set("click",this.attributes_click)
        this.attributes_map.set("slide",this.attributes_slide)
        this.attributes_map.set("delete",this.attributes_delete)
        this.attributes_map.set("be_active",this.attributes_be_active)
        this.attributes_map.set("active",this.attributes_active)
        this.attributes_map.set("top",this.attributes_top)
        this.attributes_map.set("text_sound",this.attributes_text_sound)
        this.attributes_map.set("question_select",this.attributes_question_select)
        this.attributes_map.set("count_down",this.attributes_count_down)
        this.attributes_map.set("z_index",this.attributes_z_index)
        this.attributes_map.set("dir",this.attributes_dir)
        this.attributes_map.set("show",this.attributes_show)
        this.attributes_map.set("scene_set",this.attributes_scene_setting)
        this.attributes_remark.getComponent(attributes_remark).initView(this.onChangeRemark.bind(this))
        this.attributes_scene_setting.getComponent(attributes_scene_setting).initView(this.onChangSceneTipsRuleStatus.bind(this),this.onChangSceneAttributesStatus.bind(this))
        this.attributes_show.getComponent(attributes_show).initView(this.onChangShowStatus.bind(this))
        this.attributes_dir.getComponent(attributes_dir).initView(this.onChangeDir.bind(this))
        this.attributes_z_index.getComponent(attributes_z_index).initView(this.onChangeZIndex.bind(this))
        this.attributes_count_down.getComponent(attributes_count_down).initView(this.onChangeCountDown.bind(this))
        this.attributes_question_select.getComponent(attributes_question_select).initView(this.onChangeQuestionSelect.bind(this))
        this.attributes_text_sound.getComponent(attributes_text_sound).initView(this.onChangeTextSound.bind(this))
        this.attributes_top.getComponent(attributes_top).initView(this.onChangeTop.bind(this))
        this.attributes_active.getComponent(attributes_active).initView(this.onChangeActive.bind(this))
        this.attributes_animation.getComponent(attributes_animation).initView(this.onChangeAnimation.bind(this))
        this.attributes_be_active.getComponent(attributes_be_active).initView(this.onChangBeActiveStatus.bind(this))
        this.attributes_click.getComponent(attributes_click).initView(this.onChangClick.bind(this))
        this.attributes_slide.getComponent(attributes_slide).initView(this.onChangSlide.bind(this))
        this.attributes_drop.getComponent(attributes_drop).initView(this.onChangDrag.bind(this),this.onChangDragErrBackStatus.bind(this))
        this.attributes_delete.getComponent(attributes_delete).initView(this.onDelete.bind(this))
        this.attributes_w_h.getComponent(attributes_w_h).initView(this.onChangeSize.bind(this))
        this.attributes_x_y.getComponent(attributes_x_y).initView(this.onChangePos.bind(this))
        this.attributes_rotation.getComponent(attributes_rotation).initView(this.onChangeRotation.bind(this))
        this.attributes_anchor.getComponent(attributes_anchor).initView(this.onChangeAnchor.bind(this))
        this.attributes_origin.getComponent(attributes_origin).initView(this.onChangeOrigin.bind(this))
        this.hideAllAtt()
    }

    onChangeRemark(text: string) {
        this.cur_att_data.remark = text
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.remark)
    }

    onChangeAnchor(anchor:Vec2){
       this.cur_att_data.anchor_x = anchor.x
       this.cur_att_data.anchor_y = anchor.y
       ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.anchor)
    }

    onChangeRotation(rotation: number) {
        this.cur_att_data.rotation = rotation
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.rotation)
    }

    onChangSceneTipsRuleStatus(data:scene_tips_rule_data){
        this.cur_att_data.scene_rule_tips_data = data;
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.scene_rule_tips)
    }

    onChangSceneAttributesStatus(data:attributes_data) {
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.show_more_scene_arrow)
    }

    onChangShowStatus(show:boolean){
        this.cur_att_data.is_show = show;
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.show)
    }

    onChangeDir(dir:number){
        this.cur_att_data.img_dir = dir;
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.dir)
    }

    onChangeZIndex(zIndex:number){
        this.cur_att_data.zIndex = zIndex;
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.zIndex)
    }

    onChangeCountDown(data:att_count_down){
        this.cur_att_data.count_down = data;
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.count_down)
    }

    onChangeQuestionSelect(data:att_question_select){
        this.cur_att_data.question_select = data;
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.question_select)
    }

    onChangeTextSound(data:att_text_sound_data){
        this.cur_att_data.text_sound_data = data;
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.text_sound)
    }

    onChangeTop(data:att_top_data){
        this.cur_att_data.top_data = data;
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.top)
    }

    onChangeActive(active:boolean){
        this.cur_att_data.edit_active = active;
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.active)
    }

    onChangeAnimation(ani_list:att_ani_data[]){
        this.cur_att_data.animation_list = ani_list;
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.animation)
    }

    onChangBeActiveStatus(is_be_active:boolean){
        this.cur_att_data.is_interaction = is_be_active;
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.is_interaction)
    }
    onChangClick(data:att_click_data){
        this.cur_att_data.click_data = data;
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.click)
    }

    onChangSlide(dir:number,num:number,distance:number){
        this.cur_att_data.slide_data.slide_dir = dir;
        this.cur_att_data.slide_data.slide_num = num;
        this.cur_att_data.slide_data.slide_distance = distance;
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.slide)
    }

    onChangDragErrBackStatus(b:boolean){
        this.cur_att_data.drag_data.is_err_drag_back = b;
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.drag_err_back_status)
    }

    onChangDrag(data:att_drag_data){
        this.cur_att_data.drag_data = data;
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.drag)
    }

    onDelete(){
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.delete)
    }

    onChangeOrigin(){
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.origin)
    }

    onChangePos(pos:Vec3){
        this.cur_att_data.x = pos.x;
        this.cur_att_data.y =pos.y;
        this.cur_att_data.z =pos.z;
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.pos)
    }

    onChangeSize(size:Size){
        this.cur_att_data.width = size.width;
        this.cur_att_data.height =size.height;
        ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.size)
    }

    public initView(m:main){
        this._main = m;
    }

    UpdateAttributes(data:attributes_data){
        this.cur_att_data = data;
        if(data!=null){
            this.showAllAtt()
            this.attributes_map.get("scene_set").active = false;
            if(data.type===config.attributes_type.widget){
                this.attributes_map.get("remark").active = true;
                this.attributes_map.get("drop").active = false;
                this.attributes_map.get("click").active = false;
                this.attributes_map.get("slide").active = false;
                this.attributes_map.get("top").active = false;
                this.attributes_map.get("question_select").active = false;
                this.attributes_map.get("text_sound").active = false;
                this.attributes_map.get("count_down").active = false;
                this.attributes_map.get("z_index").active = false;
                this.attributes_map.get("anchor").active = true;
                this.attributes_map.get("rotation").active = true;
                if(data.widget_type===config.Widget_Type_List.DRAG_TYPE){
                    this.attributes_map.get("drop").active = true;
                }else if(data.widget_type===config.Widget_Type_List.CLICK_TYPE){
                    this.attributes_map.get("click").active = true;
                }else if(data.widget_type===config.Widget_Type_List.IMG_TYPE){
                    this.attributes_map.get("animation").active = false;
                }else if(data.widget_type===config.Widget_Type_List.SLIDE_TYPE){
                    this.attributes_map.get("slide").active = true;
                }else if(data.widget_type===config.Widget_Type_List.UI_TOP){
                    this.attributes_map.get("top").active = true;
                    this.attributes_map.get("animation").active = false;
                    this.attributes_map.get("origin").active = false;
                    this.attributes_map.get("url").active = false;
                    this.attributes_map.get("pos").active = false;
                    this.attributes_map.get("size").active = false;
                }else if(data.widget_type===config.Widget_Type_List.TEXT_SOUND){
                    this.attributes_map.get("animation").active = false;
                    this.attributes_map.get("origin").active = false;
                    this.attributes_map.get("url").active = false;
                    this.attributes_map.get("pos").active = false;
                    this.attributes_map.get("size").active = false;
                    this.attributes_map.get("text_sound").active = true;
                    this.attributes_map.get("anchor").active = false;
                    this.attributes_map.get("rotation").active = false;
                }else if(data.widget_type===config.Widget_Type_List.QUESTION_SELECT){
                    this.attributes_map.get("animation").active = false;
                    this.attributes_map.get("origin").active = false;
                    this.attributes_map.get("url").active = false;
                    this.attributes_map.get("pos").active = false;
                    this.attributes_map.get("size").active = false;
                    this.attributes_map.get("pos").active = true;
                    this.attributes_map.get("question_select").active = true;
                    this.attributes_map.get("anchor").active = false;
                    this.attributes_map.get("rotation").active = false;
                }else if(data.widget_type===config.Widget_Type_List.COUNT_DOWN){
                    this.attributes_map.get("animation").active = false;
                    this.attributes_map.get("origin").active = false;
                    this.attributes_map.get("url").active = false;
                    this.attributes_map.get("pos").active = true;
                    this.attributes_map.get("size").active = false;
                    this.attributes_map.get("count_down").active = true;
                    this.attributes_map.get("anchor").active = false;
                    this.attributes_map.get("rotation").active = false;
                }
            }else if(data.type===config.attributes_type.scene){
                this.hideAllAtt()
                this.attributes_map.get("name").active = true;
                this.attributes_map.get("remark").active = false;
                this.attributes_map.get("size").active = true;
                this.attributes_map.get("url").active = true;
                this.attributes_map.get("animation").active = true;
                this.attributes_map.get("scene_set").active = true;
                this.attributes_map.get("anchor").active = false;
                this.attributes_map.get("rotation").active = false;
                this.attributes_map.get("be_active").active = true;
            }
            this.scheduleOnce(()=>{
                this.updateAttInfo()
            },0.1)
  
        }else{
            this.hideAllAtt()
        }
    }

    updateAttInfo(){
        if(this.cur_att_data!=null){
            let name = this.getNameCom()
            name.update_att(`${this.cur_att_data.name}-id:${this.cur_att_data.id}`)

            let remark = this.getRemarkCom()
            remark.update_att(this.cur_att_data.remark)

            let pos = this.getPosCom()
            pos.update_att(this.cur_att_data.x,this.cur_att_data.y,this.cur_att_data.z)

            let size = this.getSizeCom()
            size.update_att(this.cur_att_data.width,this.cur_att_data.height)

            let anchor = this.getAnchorCom()
            anchor.update_att(this.cur_att_data ,this.cur_att_data.anchor_x, this.cur_att_data.anchor_y)

            let rotation = this.getRotationCom()
            rotation.update_att(this.cur_att_data.rotation)

            let url = this.getUrlCom()
            url.update_att(this.cur_att_data.src_name)

            let drag = this.getDragCom()
            if(this.cur_att_data.drag_data!=null){
                drag.update_att(this.cur_att_data.drag_data)
            }

            let slide = this.getSlideCom()
            if(this.cur_att_data.slide_data!=null){
                slide.update_att(this.cur_att_data.slide_data)
            }

            let click = this.getClickCom()
            if(this.cur_att_data.click_data!=null){
                click.update_att(this.cur_att_data.click_data)
            }

            let animation = this.getAnimationCom()
            animation.update_att(this.cur_att_data.animation_list)

            let active = this.getEditActiveCom()
            active.update_att(this.cur_att_data.edit_active)

            let top = this.getTopCom()
            if(this.cur_att_data.top_data!=null){
                top.update_att(this.cur_att_data.top_data)
            }
        
            let text_sound = this.getTextSoundCom()
            if(this.cur_att_data.text_sound_data!=null){
                text_sound.update_att(this.cur_att_data.text_sound_data)
            }

            let _question_select = this.getQuestionCom()

            if(this.cur_att_data.question_select!=null){
                _question_select.update_att(this.cur_att_data.question_select)
            }

            let _count_down = this.getCountDownCom()

            if(this.cur_att_data.count_down!=null){
                _count_down.update_att(this.cur_att_data.count_down)
            }

            this.attributes_be_active.getComponent(attributes_be_active).update_att(this.cur_att_data.is_interaction)
            
            let z_index = this.getZIndexCom()
            z_index.update_att(this.cur_att_data.zIndex)

            let show_com = this.getShowCom()
            show_com.update_att(this.cur_att_data.is_show)
            
            let scene_set = this.getSceneSetingCom()
            if(this.cur_att_data.type===config.attributes_type.scene){
                scene_set.update_att_info(this._main, this.cur_att_data)
                if(this.cur_att_data.scene_rule_tips_data!=null){
                    scene_set.update_att(this.cur_att_data.scene_rule_tips_data)
                }else{
                    this.cur_att_data.scene_rule_tips_data = new scene_tips_rule_data
                    scene_set.update_att(this.cur_att_data.scene_rule_tips_data)
                }
            }
        
        }

    }

    getSceneSetingCom(){
        return this.attributes_map.get("scene_set").getComponent(attributes_scene_setting);
    }

    getShowCom(){
        return this.attributes_map.get("show").getComponent(attributes_show);
    }
    getTopCom(){
        return this.attributes_map.get("top").getComponent(attributes_top);
    }

    getAnimationCom(){
        return this.attributes_map.get("animation").getComponent(attributes_animation);
    }

    getClickCom(){
        return this.attributes_map.get("click").getComponent(attributes_click);
    }

    getSlideCom(){
        return this.attributes_map.get("slide").getComponent(attributes_slide);
    }

    getDragCom(){
        return this.attributes_map.get("drop").getComponent(attributes_drop);
    }

    getNameCom(){
        return this.attributes_map.get("name").getComponent(attributes_name);
    }

    getRemarkCom(){
        return this.attributes_map.get("remark").getComponent(attributes_remark);
    }

    getPosCom(){
        return this.attributes_map.get("pos").getComponent(attributes_x_y);
    }

    getSizeCom(){
        return this.attributes_map.get("size").getComponent(attributes_w_h);
    }

    getAnchorCom() {
        return this.attributes_map.get("anchor").getComponent(attributes_anchor);
    }

    getRotationCom(){
        return this.attributes_map.get("rotation").getComponent(attributes_rotation);
    }

    getEditActiveCom(){
        return this.attributes_map.get("active").getComponent(attributes_active);
    }

    getQuestionCom(){
        return this.attributes_map.get("question_select").getComponent(attributes_question_select);
    }

    getCountDownCom(){
        return this.attributes_map.get("count_down").getComponent(attributes_count_down);
    }


    public getUrlCom(){
        return this.attributes_map.get("url").getComponent(attributes_res);
    }

    public getTextSoundCom(){
        return this.attributes_map.get("text_sound").getComponent(attributes_text_sound);
    }

    
    public getZIndexCom(){
        return this.attributes_map.get("z_index").getComponent(attributes_z_index);
    }

    showAllAtt(){
        this.attributes_map.forEach((v,k)=>{
            v.active = true;
        })
    }


    hideAllAtt(){
        this.attributes_map.forEach((v,k)=>{
            v.active = false;
        })
    }

    public get_cur_att_data(){
        return this.cur_att_data;
    }

    public get_cur_scene_all_widget():widget_item_data[]{ //获取当前所有控件
        let data = this._main.edit_scene_view.getCurSelectScene()
        if(!data){
            return []
        }
        let temp = []
        for (let index = 0; index < data.page_list.length; index++) {
            const element = data.page_list[index];
            for (let i = 0; i < element.page_widget_list.length; i++) {
                const widget = element.page_widget_list[i];
                temp.push(widget)
            }
        }
        return temp;
    }

    public get_cur_scene_widget_by_type(type:number):widget_item_data[]{ //根据类型获取所有的
        let data = this._main.edit_scene_view.getCurSelectScene()
        if(!data){
            return []
        }
        let temp = []
        for (let index = 0; index < data.page_list.length; index++) {
            const element = data.page_list[index];
            for (let i = 0; i < element.page_widget_list.length; i++) {
                const widget = element.page_widget_list[i];
                if(type===widget.type){
                    temp.push(widget)
                }
            }
        }
        return temp;
    }

    public get_cur_scene_all_only_widget(){ //获取当前所有控件
        let data = this._main.edit_scene_view.getCurSelectScene()
        if(!data){
            return []
        }
        let temp = []
        for (let index = 0; index < data.page_list.length; index++) {
            const element = data.page_list[index];
            for (let i = 0; i < element.page_widget_list.length; i++) {
                const widget = element.page_widget_list[i];
                if(widget.type!=config.Widget_Type_List.UI_TOP){
                    temp.push(widget)
                }
            }
        }
        return temp;
    }

    public get_cur_scene_widget_by_id(id:number){ // 根据控件id获取
        let data = this._main.edit_scene_view.getCurSelectScene()
        for (let index = 0; index < data.page_list.length; index++) {
            const element = data.page_list[index];
            for (let i = 0; i < element.page_widget_list.length; i++) {
                const widget = element.page_widget_list[i];
                if(widget.att.id===id){
                    return widget;
                }
            }
        }
        return null;
    }

    public get_widget_at_page_by_widget(select_widget:widget_item_data){ //根据widget 找到所属分页
        let page_index = 0;
        let data = this._main.edit_scene_view.getCurSelectScene()
        for (let index = 0; index < data.page_list.length; index++) {
            const element = data.page_list[index];
            for (let i = 0; i < element.page_widget_list.length; i++) {
                const widget = element.page_widget_list[i];
                if(widget.att.id===select_widget.att.id){
                    page_index = index;
                    break;
                }
            }
        }
        return page_index;
    }

    public get_scene_list(){
        let scene_list = this._main.control_view.get_bag_data().content;
        let temp = []
        for (let index = 0; index < scene_list.length; index++) {
            const s = scene_list[index];
            if(s.is_child_scene){
                temp.push(s)
            }
        }
        return temp;
    }

    ShowWidgetList(){
        let list = this.get_cur_scene_all_widget()
        if(list.length<=0){
            return tools.showToast("当前场景没有控件！")
        }
        tools.show_widget_list(list)
    }

    ShowALlChildScene(call){
        let list = this.get_scene_list()
        if(list.length<=0){
            return tools.showToast("还没有添加子场景")
        }
        tools.show_select_child_scene(list,call)
    }

    getEventList(){
        let data = this._main.edit_scene_view.getCurSelectScene()
        if(data._task_data == null) {
            return []
        }
        return data._task_data.event_list
    }

    getBeActionEventList(){
        let data = this._main.edit_scene_view.getCurSelectScene()
        let temp = []
        for (let index = 0; index < data._task_data.event_list.length; index++) {
            const element = data._task_data.event_list[index];
            if(element.type==config.event_type.be_event){
                temp.push(element)
            }
        }
        return temp
    }

    getEventItemById(event_id:number){
        let list = this.getEventList();
        for (let index = 0; index < list.length; index++) {
            const element = list[index];
            if(event_id===element.event_id){
                return element;
            }
        }
        return null;
    }

}


