//BSD License  
//DXGfx® - http://www.eteractions.com
//Copyright (c) 2005
//by Guillaume Randon
//Permission is hereby granted, free of charge, to any person obtaining a copy of this software
//and associated documentation files (the "Software"), to deal in the Software without restriction,
//including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
//and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
//subject to the following conditions:
//The above copyright notice and this permission notice shall be included in all copies or substantial
//portions of the Software.
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
//INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 
//AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
//DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using Microsoft.Samples.DirectX.UtilityToolkit;
using System.Drawing;

namespace DXGfxLib
{
    /// <summary>
    /// Triggers are a specific kind of world Area that have actions associated with them. The actions are triggered when
    /// an object enter the Area of the trigger.
    /// Trigger could react only to some specific types entering the Area or named object, they could post events or
    /// perform any kind of other actions.
    /// 
    /// Events are posted at the scene level not on specific nodes !!
    /// </summary>
    public class Trigger : Area
    {
        /// <summary>
        /// This will be used for the name of the event that will be posted to the list of scene events.
        /// </summary>
        private string eventName;

        public string EventName
        {
            get { return eventName; }
            set { eventName = value; }
        }

        /// <summary>
        /// This will be used as the type of the event that will be posted.
        /// </summary>
        private string eventType;

        public string EventType
        {
            get { return eventType; }
            set { eventType = value; }
        }

        /// <summary>
        /// This will be the value of the event. Any argument you want or any object serialized to a string, everything you
        /// want in fact provide that script or code dealing with the event is able to reconstruct the  needed value from the string.
        /// In the trigger for now we pass the name of the collidingObject !!
        /// </summary>
        private string eventValue;

        public string EventValue
        {
            get { return eventValue; }
            set { eventValue = value; }
        }

        public override void Collision(double appTime, float elapsedTime, SceneObject collidingObject)
        {
            Event evt = new Event(eventName, 0, eventType, collidingObject.name, true);

            scene.AddEvent(evt);
        }
    }
}
