public void SetState(int index)
        {
            if (index < 0 || index >= perso.Perso3dData.Family.states.Count)
            {
                return;
            }
            stateIndex   = index;
            currentState = index;
            state        = perso.Perso3dData.Family.states[index];
            //UpdateViewCollision(controller.viewCollision);

            // Set animation
            ushort anim_index = 0;
            byte   bank_index = 0;

            if (state.anim_ref != null)
            {
                anim_index = state.anim_ref.anim_index;
                bank_index = perso.Perso3dData.Family.animBank;
            }

            if (state.anim_ref != null && state.anim_ref.a3d != null)
            {
                animationSpeed = state.speed;
                InitAnimation(state.anim_ref.a3d);
                UpdateAnimation();
            }
            else
            {
                a3d = null;
            }
        }
        public void Init()
        {
            if (perso != null && perso.Perso3dData.Family != null)
            {
                Family fam = perso.Perso3dData.Family;
                if (fam != null && fam.objectLists != null && fam.objectLists.Count > 0)
                {
                    Array.Resize(ref poListNames, fam.objectLists.Count + 1);
                    Array.Copy(fam.objectLists.Select(o => (o == null ? "Null" : o.ToString())).ToArray(), 0, poListNames, 1, fam.objectLists.Count);

                    //Array.Copy(l.uncategorizedObjectLists.Select(o => (o == null ? "Null" : o.ToString())).ToArray(), 0, poListNames, 1 + fam.objectLists.Count, l.uncategorizedObjectLists.Count);

                    currentPOList = fam.GetIndexOfPhysicalList(perso.Perso3dData.ObjectList) + 1;
                    if (currentPOList == -1)
                    {
                        currentPOList = 0;
                    }
                    poListIndex = currentPOList;
                }
                if (fam != null && fam.states != null && fam.states.Count > 0)
                {
                    stateNames = fam.states.Select(s => (s == null ? "Null" : s.ToString())).ToArray();
                    hasStates  = true;
                    state      = perso.Perso3dData.StateCurrent;
                    for (int i = 0; i < fam.states.Count; i++)
                    {
                        if (state == fam.states[i])
                        {
                            currentState = i;
                            stateIndex   = i;
                            SetState(i);
                            break;
                        }
                    }
                    if (state == null && fam.states.Count > 0)
                    {
                        currentState = 0;
                        stateIndex   = 0;
                        SetState(0);
                    }
                }
            }
            loaded = true;
        }