Пример #1
0
    //此构造函数主要用于加载角色
    //param : 角色配置表的key值
    public Entity(uint configID, ulong uID, eCamp camp)
    {
        //注意顺序,首先应该加载 gameobject,然后实例化其他模块,因为其他模块的构造会依赖于这个gameobject
        EntityCfg = CSVManager.GetEntityCfg(configID);
        if (EntityCfg == null)
        {
            throw new Exception("找不到 configID = " + configID + " 的配置");
        }

        GameObject o = ResManager.Load <GameObject>(EntityCfg.ResPath);

        if (o == null)
        {
            throw new Exception("不存在的entity : " + EntityCfg.ResPath);
        }
        m_object = GameObject.Instantiate(o);
        m_object.transform.SetParent(EntityManager.Instance.EntityRoot);
        UID       = uID;
        this.Camp = camp;
        FillMapBones(); //映射骨骼信息
        blackboard = new Blackboard();
        InitModules();
    }