62 lines
1.8 KiB
C#
62 lines
1.8 KiB
C#
using System;
|
|
|
|
public partial class AI
|
|
{
|
|
public Structure Parent { get; private set; }
|
|
|
|
private Random RandomGenerator;
|
|
|
|
public AI(Structure parent)
|
|
{
|
|
this.Parent = parent;
|
|
|
|
this.RandomGenerator = new Random();
|
|
}
|
|
|
|
public Order Think()
|
|
{
|
|
// Change of MOVE order, if mobile and in space
|
|
if (this.Parent.IsMobile && !this.Parent.IsLanded && Helpers.GetChance(30))
|
|
{
|
|
// Chance of local movement
|
|
if (Helpers.GetChance(95))
|
|
{
|
|
// Chance of aimless movement
|
|
if (Helpers.GetChance(100))
|
|
{
|
|
CoordinateVector deltaCoordinates = Helpers.GetRandomCoordinatesFromAU(
|
|
-0.5M, 0.5M,
|
|
-0.5M, 0.5M
|
|
);
|
|
CoordinateVector newCoordinates = Helpers.CalculateNewCoordinates(this.Parent, deltaCoordinates);
|
|
|
|
return new DestinationOrder(Order.OrderType.MOVE_THRUSTERS, newCoordinates);
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Chance of aimless movement
|
|
if (Helpers.GetChance(100))
|
|
{
|
|
CoordinateVector deltaCoordinates = Helpers.GetRandomCoordinatesFromLY(
|
|
-500M, 500M,
|
|
-500M, 500M
|
|
);
|
|
CoordinateVector newCoordinates = Helpers.CalculateNewCoordinates(this.Parent, deltaCoordinates);
|
|
|
|
return new DestinationOrder(Order.OrderType.MOVE_WARP, newCoordinates);
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
return new TickOrder(Order.OrderType.IDLE, 10);
|
|
}
|
|
}
|