Esempio n. 1
0
        override public float Run()
        {
            if (!isRunning)
            {
                isRunning = true;

                if (runtimeFaceObject == null && (faceType == CharFaceType.Body || (faceType == CharFaceType.Head && !stopLooking)))
                {
                    return(0f);
                }

                if (runtimeCharToMove)
                {
                    if (faceType == CharFaceType.Body)
                    {
                        if (!isInstant && runtimeCharToMove.IsMovingAlongPath())
                        {
                            runtimeCharToMove.EndPath();
                        }

                        if (lookUpDown && isPlayer && KickStarter.settingsManager.IsInFirstPerson())
                        {
                            Player player = (Player)runtimeCharToMove;
                            player.SetTilt(runtimeFaceObject.transform.position, isInstant);
                        }

                        runtimeCharToMove.SetLookDirection(GetLookVector(KickStarter.settingsManager), isInstant);
                    }
                    else if (faceType == CharFaceType.Head)
                    {
                        if (stopLooking)
                        {
                            runtimeCharToMove.ClearHeadTurnTarget(isInstant, HeadFacing.Manual);
                        }
                        else
                        {
                            Vector3 offset = Vector3.zero;

                            Hotspot faceObjectHotspot = runtimeFaceObject.GetComponent <Hotspot>();
                            Char    faceObjectChar    = runtimeFaceObject.GetComponent <Char>();

                            if (lookAtHead && faceObjectChar != null)
                            {
                                Transform neckBone = faceObjectChar.neckBone;
                                if (neckBone != null)
                                {
                                    runtimeFaceObject = neckBone.gameObject;
                                }
                                else
                                {
                                    ACDebug.Log("Cannot look at " + faceObjectChar.name + "'s head as their 'Neck bone' has not been defined.", faceObjectChar);
                                }
                            }
                            else if (faceObjectHotspot != null)
                            {
                                if (faceObjectHotspot.centrePoint != null)
                                {
                                    runtimeFaceObject = faceObjectHotspot.centrePoint.gameObject;
                                }
                                else
                                {
                                    offset = faceObjectHotspot.GetIconPosition(true);
                                }
                            }

                            runtimeCharToMove.SetHeadTurnTarget(runtimeFaceObject.transform, offset, isInstant);
                        }
                    }

                    if (isInstant)
                    {
                        return(0f);
                    }
                    else
                    {
                        if (willWait)
                        {
                            return(defaultPauseTime);
                        }
                        else
                        {
                            return(0f);
                        }
                    }
                }

                return(0f);
            }
            else
            {
                if (faceType == CharFaceType.Head && runtimeCharToMove.IsMovingHead())
                {
                    return(defaultPauseTime);
                }
                else if (faceType == CharFaceType.Body && runtimeCharToMove.IsTurning())
                {
                    return(defaultPauseTime);
                }
                else
                {
                    isRunning = false;
                    return(0f);
                }
            }
        }