renamed OpenRa.Game.* to OpenRa.*; a few other bits
This commit is contained in:
53
OpenRa.Mods.RA/Minelayer.cs
Normal file
53
OpenRa.Mods.RA/Minelayer.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Traits;
|
||||
using OpenRa;
|
||||
|
||||
namespace OpenRa.Mods.RA
|
||||
{
|
||||
class MinelayerInfo : ITraitInfo
|
||||
{
|
||||
public readonly string Mine = "minv";
|
||||
|
||||
public object Create(Actor self)
|
||||
{
|
||||
return new Minelayer();
|
||||
}
|
||||
}
|
||||
|
||||
class Minelayer : IIssueOrder, IResolveOrder
|
||||
{
|
||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||
{
|
||||
var limitedAmmo = self.traits.GetOrDefault<LimitedAmmo>();
|
||||
if (limitedAmmo != null && !limitedAmmo.HasAmmo())
|
||||
return null;
|
||||
|
||||
// Ensure that the cell is empty except for the minelayer
|
||||
if (Game.UnitInfluence.GetUnitsAt(xy).Any(a => a != self))
|
||||
return null;
|
||||
|
||||
if (mi.Button == MouseButton.Right && underCursor == self)
|
||||
return new Order("Deploy", self, null, int2.Zero, null);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "Deploy")
|
||||
{
|
||||
var limitedAmmo = self.traits.GetOrDefault<LimitedAmmo>();
|
||||
if (limitedAmmo != null)
|
||||
limitedAmmo.Attacking(self);
|
||||
|
||||
// todo: delay a bit? (req making deploy-mine an activity)
|
||||
|
||||
Game.world.AddFrameEndTask(
|
||||
w => w.Add(new Actor(self.Info.Traits.Get<MinelayerInfo>().Mine, self.Location, self.Owner)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user