public void DeleteObjectsById(string id, bool deleteSelf = true)
    {
        if (this.entityCreate.DeleteObjectsById(id))
        {
            return;
        }
        if (!RoleManager.sceneEntities.ContainsKey(id))
        {
            return;
        }
        if (!deleteSelf && id == Singleton <RoleManager> .Instance.mainRole.id)
        {
            return;
        }
        SceneEntity sceneEntity = RoleManager.sceneEntities[id];

        RoleManager.sceneEntities.Remove(id);
        if (sceneEntity != null)
        {
            if (sceneEntity.lingqiObj != null && sceneEntity.lingqiObj.gameObject != null)
            {
                RoleManager.partnerAndLingQiEntities.Remove(sceneEntity.lingqiObj.id);
                sceneEntity.lingqiObj.Recycle();
                sceneEntity.lingqiObj = null;
            }
            if (sceneEntity.partnerObj != null && sceneEntity.partnerObj.gameObject != null)
            {
                RoleManager.partnerAndLingQiEntities.Remove(sceneEntity.partnerObj.id);
                sceneEntity.partnerObj.Recycle();
                sceneEntity.partnerObj = null;
            }
            if (sceneEntity.petObj != null && sceneEntity.petObj.gameObject != null)
            {
                RoleManager.partnerAndLingQiEntities.Remove(sceneEntity.petObj.id);
                sceneEntity.petObj.Recycle();
                sceneEntity.petObj = null;
            }
            if (sceneEntity.beautyObj != null && sceneEntity.beautyObj.gameObject != null)
            {
                RoleManager.partnerAndLingQiEntities.Remove(sceneEntity.beautyObj.id);
                sceneEntity.beautyObj.Recycle();
                sceneEntity.beautyObj = null;
            }
            if (sceneEntity.gameObject != null)
            {
                sceneEntity.Recycle();
            }
            HusongFollow component = this.mainRole.transform.GetComponent <HusongFollow>();
            if (component != null && component.targetId == id)
            {
                component.targetEntity = null;
            }
        }
        if (this.positionSync != null)
        {
            this.positionSync.DeleteObjectPosition(id);
        }
    }
Exemple #2
0
    private static int get_targetEntity(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            HusongFollow husongFollow = (HusongFollow)obj;
            SceneEntity  targetEntity = husongFollow.targetEntity;
            ToLua.Push(L, targetEntity);
            result = 1;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index targetEntity on a nil value");
        }
        return(result);
    }
Exemple #3
0
    private static int get_targetId(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            HusongFollow husongFollow = (HusongFollow)obj;
            string       targetId     = husongFollow.targetId;
            LuaDLL.lua_pushstring(L, targetId);
            result = 1;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index targetId on a nil value");
        }
        return(result);
    }
Exemple #4
0
    private static int set_targetEntity(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            HusongFollow husongFollow = (HusongFollow)obj;
            SceneEntity  targetEntity = (SceneEntity)ToLua.CheckUnityObject(L, 2, typeof(SceneEntity));
            husongFollow.targetEntity = targetEntity;
            result = 0;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index targetEntity on a nil value");
        }
        return(result);
    }