Fix CursorForOrderString to work with orders + preliminary e6 fixes

This commit is contained in:
Paul Chote
2010-07-23 17:11:52 +12:00
parent 5019bb8b6e
commit 71420df0f3
25 changed files with 179 additions and 93 deletions

View File

@@ -56,8 +56,8 @@ namespace OpenRA.Orders
public string GetCursor( World world, int2 xy, MouseInput mi )
{
var c = Order(world, xy, mi)
.Select(o => o.Subject.traits.WithInterface<IProvideCursor>()
.Select(pc => pc.CursorForOrderString(o.OrderString, o.Subject, o.TargetLocation)).FirstOrDefault(a => a != null))
.Select(o => o.Subject.traits.WithInterface<IOrderCursor>()
.Select(pc => pc.CursorForOrder(o.Subject, o)).FirstOrDefault(a => a != null))
.FirstOrDefault(a => a != null);
return c ??

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Traits
public virtual object Create(ActorInitializer init) { return new Mobile(init, this); }
}
public class Mobile : IIssueOrder, IResolveOrder, IOccupySpace, IMove, IProvideCursor, INudge
public class Mobile : IIssueOrder, IResolveOrder, IOccupySpace, IMove, IOrderCursor, INudge
{
public readonly Actor self;
public readonly MobileInfo Info;
@@ -112,12 +112,12 @@ namespace OpenRA.Traits
}
}
public string CursorForOrderString(string s, Actor a, int2 location)
public string CursorForOrder(Actor self, Order order)
{
if (s != "Move")
if (order.OrderString != "Move")
return null;
return (CanEnterCell(location)) ? "move" : "move-blocked";
return (CanEnterCell(order.TargetLocation)) ? "move" : "move-blocked";
}
public int2 TopLeft { get { return toCell; } }

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Traits
public readonly string[] Produces = { };
}
public class Production : IIssueOrder, IResolveOrder, ITags, IProvideCursor
public class Production : IIssueOrder, IResolveOrder, ITags, IOrderCursor
{
public virtual int2? CreationLocation( Actor self, ActorInfo producee )
{
@@ -99,9 +99,9 @@ namespace OpenRA.Traits
return null;
}
public string CursorForOrderString(string s, Actor a, int2 location)
public string CursorForOrder(Actor self, Order order)
{
return (s == "Deploy") ? "deploy" : null;
return (order.OrderString == "Deploy") ? "deploy" : null;
}
public void ResolveOrder(Actor self, Order order)

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Traits
public interface IRender { IEnumerable<Renderable> Render(Actor self); }
public interface IIssueOrder { Order IssueOrder( Actor self, int2 xy, MouseInput mi, Actor underCursor ); }
public interface IResolveOrder { void ResolveOrder(Actor self, Order order); }
public interface IProvideCursor { string CursorForOrderString(string s, Actor a, int2 location); }
public interface IOrderCursor { string CursorForOrder(Actor self, Order order); }
public interface INotifySold { void Selling( Actor self ); void Sold( Actor self ); }
public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); }