All pastes #371297 Raw Edit

Anonymous

public text v1 · immutable
#371297 ·published 2007-02-25 06:33 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Drawing;

using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using Microsoft.DirectX.DirectSound;

namespace BladeEngine
{
    public class Entity
    {
        private int m_Color = Color.White.ToArgb ( );
        private int m_Health;

        private float m_Width;
        private float m_Height;
        private float m_Gravity = 0.001f;
        private float m_Rotation = 0;

        private Vector3 m_Pos;
        private Vector3 m_Velocity = new Vector3 ( 0.0f , 0.0f, 0.0f );
        private Vector3 m_Angle;
        private Vector3 m_RotationCenter;

        private Entity m_Parent;

        private Pen m_Pen;

        private Tex m_Texture;

        private string m_Name;


        public Entity ( )
        {
            m_Pen = new Pen ( );
        }

        ~Entity ( )
        {
            Dispose ( );
        }



        public void Activate ( )    //  Some entity's need to be activated.
        {
        }

        public void Spawn ( )       //  Spawns the entity.
        {
            EntityManager.Entitys.Add ( this );
        }

        public void DropToFloor ( ) //  Teleport's the entity to the ground.
        {

        }

        public void EmitSound ( )   //  Emits a sound from the entity.
        {
        }

        public void StopSound ( )   //  Stops any sound it's currently emmiting.
        {
        }

        public void Fire ( )        //  Can set certain properties to the entity.
        {
        }

        //  Get's

        public Vector3 GetAngles ( )   //  Returns the entity's current angles.
        {
            return m_Angle;
        }

        public void GetClass ( )    //  Returns the entity's type, prop_physic, prop_vehicle, ect.
        {
        }

        public int GetColor ( )    //  Returns the color the entity's set to.
        {
            return m_Color;
        }

        public Texture GetModel ( )    //  Returns the model the entity is using.
        {
            return m_Texture.Texture;
        }

        public string GetName ( )     //  Returns the target name of an entity.
        {
            return m_Name;
        }

        public Entity GetParent ( )   //  Returns the entity's parent entity.
        {
            return m_Parent;
        }

        public float GetGravity ( )
        {
            return m_Gravity;
        }

        public Vector3 GetPos ( )      //  Returns the position of the entity as a vector.
        {
            return m_Pos;
        }

        public float GetRotation ( )
        {
            return m_Rotation;
        }

        public Vector3 GetVelocity ( ) //  Returns the velocity of an entity as a vector.
        {
            return m_Velocity;
        }

        public int GetHealth ( )   //  Returns the health of an entity as an integer.
        {
            return m_Health;
        }

        public float GetWidth ( )
        {
            return m_Width;
        }

        public float GetHeight ( )
        {
            return m_Height;
        }

        //  Set's

        public void SetName ( string name )
        {
            m_Name = name;
        }

        public void SetAngles ( Vector3 angle )   //  Sets the entity's angles.
        {
            m_Angle = angle;
        }

        public void SetRotation ( float rotation )
        {
            m_Rotation = rotation;
        }

        public void SetRotationCenter ( Vector3 rotationcenter )
        {
            m_RotationCenter = rotationcenter;
        }

        public void SetColor ( int color )    //  Sets the color of the entity.
        {
            m_Color = color;
        }

        public void SetGravity ( float gravity )  //  Sets the amount of gravity is stressed on the entity.
        {
            m_Gravity = gravity;
        }

        public void SetHealth ( int health )   //  Sets the entitys health.
        {
            m_Health = health;
        }

        public void SetParent ( Entity parent )   //  Sets the parent entity.
        {
            m_Parent = parent;
        }

        public void SetPos ( Vector3 pos )      //  Sets the position of the entity.
        {
            m_Pos = pos;
        }

        public void SetVelocity ( Vector3 velocity ) //  Sets the entitys velocity.
        {
            m_Velocity = velocity;
        }

        public void SetModel ( string strPath )
        {
            m_Texture = new Tex ( strPath );
            m_Width = m_Texture.Width;
            m_Height = m_Texture.Height;
        }

        public void BaseUpdate ( )
        {
            m_Texture.Translation = m_Pos;
            m_Texture.RotationCenter = m_RotationCenter;
            m_Texture.Rotation = m_Rotation;

            m_Pos.Y += m_Velocity.Y;
            m_Pos.X += m_Velocity.X;

            m_Velocity.Y *= m_Gravity;
            m_Velocity.X *= m_Gravity;

            Update ( );
        }

        public virtual void Update ( )
        {

        }

        public void BaseRender ( )
        {
            if ( m_Texture != null )
            {
                m_Pen.Color = m_Color;
                m_Pen.DrawTexture ( m_Texture );
            }
            Render ( );
        }

        public virtual void Render ( )
        {

        }

        public virtual void Dispose ( )
        {
            if ( m_Parent != null )
            {
                m_Parent.Dispose ( );
            }

            if ( m_Pen != null )
            {
                m_Pen.Dispose ( );
                m_Pen = null;
            }

            if ( m_Texture != null )
            {
                m_Texture = null;
            }
            this.Disposed = true;
        }
    }
}