//Blizzless Project 2022
using DiIiS_NA.GameServer.Core.Types.Math;
//Blizzless Project 2022
using DiIiS_NA.GameServer.GSSystem.ActorSystem;
//Blizzless Project 2022
using DiIiS_NA.GameServer.GSSystem.MapSystem;
//Blizzless Project 2022
using DiIiS_NA.GameServer.GSSystem.PlayerSystem;
//Blizzless Project 2022
using System;
//Blizzless Project 2022
using System.Collections.Generic;
//Blizzless Project 2022
using System.Drawing;
//Blizzless Project 2022
using System.Linq;
//Blizzless Project 2022
using System.Text;
//Blizzless Project 2022
using System.Threading.Tasks;
namespace DiIiS_NA.GameServer.GSSystem.ObjectsSystem
{
public abstract class WorldObject : DynamicObject, IRevealable
{
///
/// The world object belongs to.
///
public World World { get; set; }
protected Vector3D _position;
///
/// The position of the object.
///
public Vector3D Position
{
get { return _position; }
set
{
_position = value;
if (_position == null) return;
this.Bounds = new RectangleF(this.Position.X, this.Position.Y, this.Size.Width, this.Size.Height);
var handler = PositionChanged;
if (handler != null) handler(this, EventArgs.Empty);
}
}
///
/// Event handler for position-change.
///
public event EventHandler PositionChanged;
///
/// Size of the object.
///
public Size Size { get; protected set; }
///
/// Automatically calculated bounds for object used by QuadTree.
///
public RectangleF Bounds { get; private set; }
///
/// Scale of the object.
///
public float Scale { get; set; }
public Vector3D RotationAxis { get; set; }
public float RotationW { get; set; }
///
/// Creates a new world object.
///
/// The world object belongs to.
/// The dynamicId of the object.
protected WorldObject(World world, uint dynamicID)
: base(dynamicID)
{
if (world == null) return;
//if (dynamicID == 0)
//this.DynamicID = world.NewActorID;
this.World = world;
//this.World.StartTracking(this); // track the object.
this.RotationAxis = new Vector3D();
this._position = new Vector3D();
}
///
/// Reveals the object to given player.
///
/// The player to reveal the object.
/// true if the object was revealed or false if the object was already revealed.
public abstract bool Reveal(Player player);
///
/// Unreveals the object to given plaer.
///
/// The player to unreveal the object.
/// true if the object was unrevealed or false if the object wasn't already revealed.
public abstract bool Unreveal(Player player);
///
/// Makes the object leave the world and then destroys it.
///
public override void Destroy()
{
try
{
if (this is Actor)
if (this.World != null)
this.World.Leave(this as Actor);
//this.World.EndTracking(this);
}
catch { }
this.World = null;
}
}
}