Flesh out guided-dock concept; regress on animation continuity in RA mod
This commit is contained in:
@@ -2,11 +2,12 @@
|
||||
|
||||
namespace OpenRa.Traits.Activities
|
||||
{
|
||||
class DeliverOre : IActivity
|
||||
public class DeliverOre : IActivity
|
||||
{
|
||||
public IActivity NextActivity { get; set; }
|
||||
|
||||
bool isDone;
|
||||
bool isDocking;
|
||||
Actor refinery;
|
||||
|
||||
public DeliverOre() { }
|
||||
@@ -15,29 +16,19 @@ namespace OpenRa.Traits.Activities
|
||||
{
|
||||
this.refinery = refinery;
|
||||
}
|
||||
|
||||
// TODO: This belongs on the refinery itself
|
||||
static readonly int2 refineryDeliverOffset = new int2( 1, 2 );
|
||||
|
||||
public IActivity Tick( Actor self )
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var mobile = self.traits.Get<Mobile>();
|
||||
|
||||
if( isDone )
|
||||
{
|
||||
self.traits.Get<Harvester>().Deliver( self, refinery );
|
||||
|
||||
refinery.traits.Get<IAcceptOre>().OnDock(self);
|
||||
return NextActivity ?? new Harvest();
|
||||
}
|
||||
else if( NextActivity != null )
|
||||
if( NextActivity != null )
|
||||
return NextActivity;
|
||||
|
||||
if( refinery != null && refinery.IsDead )
|
||||
refinery = null;
|
||||
|
||||
if( refinery == null || self.Location != refinery.Location + refineryDeliverOffset )
|
||||
if( refinery == null || self.Location != refinery.Location + refinery.traits.Get<IAcceptOre>().DeliverOffset )
|
||||
{
|
||||
var search = new PathSearch
|
||||
{
|
||||
@@ -49,25 +40,27 @@ namespace OpenRa.Traits.Activities
|
||||
.Where(x => x.traits.Contains<IAcceptOre>())
|
||||
.ToList();
|
||||
if( refinery != null )
|
||||
search.AddInitialCell( self.World, refinery.Location + refineryDeliverOffset );
|
||||
search.AddInitialCell(self.World, refinery.Location + refinery.traits.Get<IAcceptOre>().DeliverOffset);
|
||||
else
|
||||
foreach( var r in refineries )
|
||||
search.AddInitialCell( self.World, r.Location + refineryDeliverOffset );
|
||||
search.AddInitialCell(self.World, r.Location + r.traits.Get<IAcceptOre>().DeliverOffset);
|
||||
|
||||
var path = self.World.PathFinder.FindPath( search );
|
||||
path.Reverse();
|
||||
if( path.Count != 0 )
|
||||
{
|
||||
refinery = refineries.FirstOrDefault( x => x.Location + refineryDeliverOffset == path[ 0 ] );
|
||||
refinery = refineries.FirstOrDefault(x => x.Location + x.traits.Get<IAcceptOre>().DeliverOffset == path[0]);
|
||||
return new Move( () => path ) { NextActivity = this };
|
||||
}
|
||||
else
|
||||
// no refineries reachable?
|
||||
return this;
|
||||
}
|
||||
// TODO: This belongs in the refinery trait
|
||||
else if( unit.Facing != 64 )
|
||||
return new Turn( 64 ) { NextActivity = this };
|
||||
else if (!isDocking)
|
||||
{
|
||||
isDocking = true;
|
||||
refinery.traits.Get<IAcceptOre>().OnDock(self, this);
|
||||
}
|
||||
|
||||
var renderUnit = self.traits.Get<RenderUnit>();
|
||||
if( renderUnit.anim.CurrentSequence.Name != "empty" )
|
||||
|
||||
@@ -9,8 +9,10 @@ namespace OpenRa.Traits
|
||||
|
||||
class OreRefinery : IAcceptOre
|
||||
{
|
||||
Actor self;
|
||||
public OreRefinery(Actor self)
|
||||
{
|
||||
this.self = self;
|
||||
self.World.AddFrameEndTask(
|
||||
w =>
|
||||
{ /* create the free harvester! */
|
||||
@@ -21,7 +23,16 @@ namespace OpenRa.Traits
|
||||
harvester.QueueActivity(new Harvest());
|
||||
});
|
||||
}
|
||||
|
||||
public void OnDock(Actor harv) {}
|
||||
public int2 DeliverOffset { get { return new int2(1, 2); } }
|
||||
public void OnDock(Actor harv, DeliverOre dockOrder)
|
||||
{
|
||||
var unit = harv.traits.Get<Unit>();
|
||||
if (unit.Facing != 64)
|
||||
harv.QueueActivity(new Turn(64));
|
||||
|
||||
// TODO: This should be delayed until the turn order is complete
|
||||
harv.traits.Get<Harvester>().Deliver(harv, self);
|
||||
harv.QueueActivity(new Harvest());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace OpenRa.Traits
|
||||
() => anim.PlayRepeating(GetPrefix(self) + "idle"));
|
||||
}
|
||||
|
||||
public void PlayCustomAnim(Actor self, string name, Action a)
|
||||
public void PlayCustomAnimThen(Actor self, string name, Action a)
|
||||
{
|
||||
anim.PlayThen(GetPrefix(self) + name,
|
||||
() => { anim.PlayRepeating(GetPrefix(self) + "idle"); a(); });
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace OpenRa.Traits
|
||||
self.World.AddFrameEndTask(
|
||||
w =>
|
||||
{ /* create the free harvester! */
|
||||
var harvester = w.CreateActor("harv", self.Location + new int2(1, 2), self.Owner);
|
||||
var harvester = w.CreateActor("harv", self.Location + new int2(0, 2), self.Owner);
|
||||
var unit = harvester.traits.Get<Unit>();
|
||||
var mobile = harvester.traits.Get<Mobile>();
|
||||
unit.Facing = 64;
|
||||
@@ -24,9 +24,19 @@ namespace OpenRa.Traits
|
||||
});
|
||||
}
|
||||
|
||||
public void OnDock(Actor harv)
|
||||
public int2 DeliverOffset { get { return new int2(0, 2); } }
|
||||
public void OnDock(Actor harv, DeliverOre dockOrder)
|
||||
{
|
||||
self.traits.Get<RenderBuilding>().PlayCustomAnim(self, "active");
|
||||
var unit = harv.traits.Get<Unit>();
|
||||
harv.QueueActivity(new Move(self.Location + DeliverOffset, self));
|
||||
harv.QueueActivity(new Turn(96));
|
||||
|
||||
// TODO: This should be delayed until the turn order is complete
|
||||
self.traits.Get<RenderBuilding>().PlayCustomAnimThen(self, "active", () => {
|
||||
harv.traits.Get<Harvester>().Deliver(harv, self);
|
||||
harv.QueueActivity(new Move(self.Location + DeliverOffset, self));
|
||||
harv.QueueActivity(new Harvest());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Drawing;
|
||||
using IjwFramework.Types;
|
||||
using OpenRa.GameRules;
|
||||
using OpenRa.Graphics;
|
||||
using OpenRa.Traits.Activities;
|
||||
|
||||
namespace OpenRa.Traits
|
||||
{
|
||||
@@ -21,7 +22,11 @@ namespace OpenRa.Traits
|
||||
public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); }
|
||||
public interface INotifyBuildComplete { void BuildingComplete(Actor self); }
|
||||
public interface INotifyProduction { void UnitProduced(Actor self, Actor other); }
|
||||
public interface IAcceptOre { void OnDock(Actor harv); }
|
||||
public interface IAcceptOre
|
||||
{
|
||||
void OnDock(Actor harv, DeliverOre dockOrder);
|
||||
int2 DeliverOffset { get; }
|
||||
}
|
||||
public interface IAcceptThief { void OnSteal(Actor self, Actor thief); }
|
||||
public interface IAcceptSpy { void OnInfiltrate(Actor self, Actor spy); }
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ RefundPercent=50% ; percent of original cost to refund when building/unit
|
||||
RepairRate=.016 ; minutes between applying repair step
|
||||
URepairPercent=20% ; [units only] percent cost to fully repair as ratio of full cost
|
||||
URepairStep=10 ; [units only] hit points to heal per repair 'tick' for units
|
||||
BuildSpeed=.8 ; general build speed [time (in minutes) to produce a 1000 credit cost item]
|
||||
BuildSpeed=.1 ; general build speed [time (in minutes) to produce a 1000 credit cost item]
|
||||
|
||||
OreGrows=yes ; Does ore grow denser over time?
|
||||
OreSpreads=yes ; Does ore spread into adjacent areas
|
||||
|
||||
@@ -46,7 +46,7 @@ PROC:
|
||||
LongDesc: Processes Tiberium into useable resources
|
||||
Building:
|
||||
Power: -30
|
||||
Footprint: ___ xxx x=x
|
||||
Footprint: ___ xxx ===
|
||||
Dimensions: 3,3
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
|
||||
Reference in New Issue
Block a user