this.GoalType = "PLANTMINE";
this.Version = 1;
this.DefaultPriority = 0.79;
this.MinRadius = 32;
this.RolePriorityBonus = 0.1;
this.MaxUsers_InUse(1);
this.MaxUsers_InProgress(1);

//////////////////////////////////////////////////////////////////////////

this.InitNewGoal = function()
{
	this.Radius = this.MinRadius;
};

//////////////////////////////////////////////////////////////////////////

this.UpgradeVersion = function(Props)
{
	// version 0 is string,string key/values from the old waypoint format
	if(Props.Version==0)
	{
		// Version 1 Schema, upgrade from waypoint format
		Props.Version = 1;

		this.SetPosition(this.GetPosition() + Util.WaypointGoalOffset);
		this.SetBounds(Vec3(-5,-5,0),Vec3(5,5,96));
	}
	else if(Props.Version == this.Version)
	{
		this.CloseMines = {};
		tbl = {
			Name=this.GetName(),
			OnEnter = this.MineEntered,
			OnExit = this.MineExited,
			UpdateDelay = 0.5,
			CallbackObject = this,
			TriggerOnCategory = CAT.MINE,
		};

		rgnId = OnTriggerRegion(this.GetPosition(), 64.0, tbl);
		//todo: attach the life of this region to the mapgoal
	}
};

//////////////////////////////////////////////////////////////////////////

this.Render = function()
{
	offset2 = Vector3(0,0,64);

	while(this.RenderGoal == true)
	{
		goalBasePos = this.GetPosition();
		goalPos = goalBasePos + offset2;

		this.RenderDefault();

		if(this.IsDisabled())
		{
			DrawLine(goalPos,goalBasePos,COLOR.RED,2);
		}
		else
		{
			if ( this.InUse )
			{
				DrawLine(goalPos,goalBasePos,COLOR.ORANGE,2);
			}
			else
			{
				DrawLine(goalPos,goalBasePos,COLOR.GREEN,2);
			}
		}

		sleep(2);
	}
};

this.MineEntered = function(ent)
{
	this.CloseMines[ent] = 1;
	this.InUse = true;
};
this.MineExited = function(ent)
{
	this.CloseMines[ent] = null;
	if ( tableCount(this.CloseMines) == 0 )
	{
		this.InUse = false;
	}
};
