using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;

namespace DXGfxLib
{
    /// <summary>
    /// This will contain only static methods meant to be used from script.
    /// 
    /// For example we can anticipate that a fairly common action from script will be to instruct avatars or npg to go
    /// to specific named areas of the world. Thus a function MoveToNamedArea is highly desirable !!
    /// </summary>
    public class ScriptHelpers
    {
        public static SceneObject GetSceneObjectFromName(string name)
        {
            return DXGfxManager.GetGlobalInstance().GetObj(name) as SceneObject;
        }

        public static void MoveToPosition(SceneNode nodeToMove, Vector3 destination, float speed, float elapsedTime)
        {
            Vector3 diff = Vector3.Subtract(destination, nodeToMove.Position);
            diff.Normalize();

            nodeToMove.Position += elapsedTime * speed * diff;
        }

        public static void MoveToNamedArea(SceneNode nodeToMove, string areaName, float speed, float elapsedTime)
        {
            MoveToPosition(nodeToMove, GetSceneObjectFromName(areaName).Position, speed, elapsedTime);
        }
    }
}
