Fix cnc afld
This commit is contained in:
@@ -41,43 +41,15 @@ namespace OpenRA.Traits
|
||||
Spawns.Add(new float2(info.SpawnOffsets[i],info.SpawnOffsets[i+1]), new int2(info.ExitCells[i], info.ExitCells[i+1]));
|
||||
}
|
||||
|
||||
public virtual bool Produce( Actor self, ActorInfo producee )
|
||||
public void DoProduction(Actor self, Actor newUnit, int2 exit, float2 spawn)
|
||||
{
|
||||
var newUnit = self.World.CreateActor(false, producee.Name, new TypeDictionary
|
||||
{
|
||||
new OwnerInit( self.Owner ),
|
||||
});
|
||||
Game.Debug("Creating actor {0}".F(newUnit.Info.Name));
|
||||
|
||||
// Todo: remove assumption on Mobile
|
||||
var mobile = newUnit.traits.Get<Mobile>();
|
||||
|
||||
// Pick an exit that we can move to
|
||||
var exit = int2.Zero;
|
||||
var spawn = float2.Zero;
|
||||
var success = false;
|
||||
|
||||
// Pick a spawn/exit point
|
||||
// Todo: Reorder in a synced random way
|
||||
foreach (var s in Spawns)
|
||||
{
|
||||
exit = self.Location + s.Value;
|
||||
spawn = self.CenterLocation + s.Key;
|
||||
if (mobile.CanEnterCell(exit,self,true))
|
||||
{
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!success)
|
||||
{
|
||||
// Hack around mobile being a tard; remove from UIM (we shouldn't be there in the first place)
|
||||
newUnit.traits.Get<Mobile>().RemoveInfluence();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Unit can be built; add to the world
|
||||
self.World.Add(newUnit);
|
||||
Game.Debug("Added to world");
|
||||
|
||||
// Set the physical position of the unit as the exit cell
|
||||
mobile.SetPosition(newUnit,exit);
|
||||
@@ -113,7 +85,44 @@ namespace OpenRA.Traits
|
||||
t.UnitProduced(self, newUnit);
|
||||
|
||||
Log.Write("debug", "{0} #{1} produced by {2} #{3}", newUnit.Info.Name, newUnit.ActorID, self.Info.Name, self.ActorID);
|
||||
}
|
||||
|
||||
public virtual bool Produce( Actor self, ActorInfo producee )
|
||||
{
|
||||
var newUnit = self.World.CreateActor(false, producee.Name, new TypeDictionary
|
||||
{
|
||||
new OwnerInit( self.Owner ),
|
||||
});
|
||||
|
||||
// Todo: remove assumption on Mobile
|
||||
var mobile = newUnit.traits.Get<Mobile>();
|
||||
|
||||
// Pick an exit that we can move to
|
||||
var exit = int2.Zero;
|
||||
var spawn = float2.Zero;
|
||||
var success = false;
|
||||
|
||||
// Pick a spawn/exit point
|
||||
// Todo: Reorder in a synced random way
|
||||
foreach (var s in Spawns)
|
||||
{
|
||||
exit = self.Location + s.Value;
|
||||
spawn = self.CenterLocation + s.Key;
|
||||
if (mobile.CanEnterCell(exit,self,true))
|
||||
{
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!success)
|
||||
{
|
||||
// Hack around mobile being a tard; remove from UIM (we shouldn't be there in the first place)
|
||||
newUnit.traits.Get<Mobile>().RemoveInfluence();
|
||||
return false;
|
||||
}
|
||||
|
||||
DoProduction(self, newUnit, exit, spawn);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,12 +33,14 @@ namespace OpenRA.Mods.Cnc
|
||||
var owner = self.Owner;
|
||||
|
||||
// Start and end beyond the edge of the map, to give a finite delay, and ability to land when AFLD is on map edge
|
||||
var startPos = new int2(owner.World.Map.XOffset + owner.World.Map.Width+15, self.Location.Y);
|
||||
var endPos = new int2(owner.World.Map.XOffset-15, self.Location.Y);
|
||||
var unloadOffset = new int2(1,1);
|
||||
var exitOffset = new int2(3,1);
|
||||
var startPos = new int2(owner.World.Map.XOffset + owner.World.Map.Width+5, self.Location.Y);
|
||||
var endPos = new int2(owner.World.Map.XOffset-5, self.Location.Y);
|
||||
|
||||
|
||||
// Assume a single exit point for simplicity
|
||||
var spawn = self.CenterLocation + Spawns.First().Key;
|
||||
var exit = self.Location + Spawns.First().Value;
|
||||
|
||||
var rp = self.traits.GetOrDefault<RallyPoint>();
|
||||
owner.World.AddFrameEndTask(w =>
|
||||
{
|
||||
var a = w.CreateActor("C17", new TypeDictionary
|
||||
@@ -50,37 +52,20 @@ namespace OpenRA.Mods.Cnc
|
||||
});
|
||||
|
||||
var cargo = a.traits.Get<Cargo>();
|
||||
|
||||
var newUnit = self.World.CreateActor(false, producee.Name, new TypeDictionary{ new OwnerInit( self.Owner ) });
|
||||
var newUnit = self.World.CreateActor(false, producee.Name, new TypeDictionary
|
||||
{
|
||||
new OwnerInit( self.Owner ),
|
||||
});
|
||||
cargo.Load(a, newUnit);
|
||||
|
||||
a.CancelActivity();
|
||||
|
||||
a.QueueActivity(new Land(Target.FromActor(self)));
|
||||
a.QueueActivity(new CallFunc(() =>
|
||||
{
|
||||
if (self.IsDead())
|
||||
return;
|
||||
|
||||
var actor = cargo.Unload(self);
|
||||
self.World.AddFrameEndTask(ww =>
|
||||
{
|
||||
ww.Add(actor);
|
||||
actor.traits.Get<IMove>().SetPosition(actor, self.Location + unloadOffset);
|
||||
newUnit.traits.Get<IFacing>().Facing = 192;
|
||||
actor.CancelActivity();
|
||||
actor.QueueActivity(new Move(self.Location + exitOffset, self));
|
||||
actor.QueueActivity(new Move(rp.rallyPoint, 0));
|
||||
if (actor.Owner == self.World.LocalPlayer)
|
||||
{
|
||||
var line = actor.traits.GetOrDefault<DrawLineToTarget>();
|
||||
if (line != null)
|
||||
line.SetTargetSilently(actor, Target.FromCell(rp.rallyPoint), Color.Green);
|
||||
}
|
||||
|
||||
foreach (var t in self.traits.WithInterface<INotifyProduction>())
|
||||
t.UnitProduced(self, actor);
|
||||
});
|
||||
Game.Debug("Creating");
|
||||
self.World.AddFrameEndTask(ww => DoProduction(self, cargo.Unload(self), exit, spawn));
|
||||
}));
|
||||
a.QueueActivity(new Fly(endPos));
|
||||
a.QueueActivity(new RemoveSelf());
|
||||
|
||||
@@ -46,6 +46,9 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
}
|
||||
|
||||
if (!success)
|
||||
return false;
|
||||
|
||||
// Todo: Once Helicopter supports it, update UIM if its docked/landed
|
||||
var newUnit = self.World.CreateActor( producee.Name, new TypeDictionary
|
||||
{
|
||||
|
||||
@@ -215,7 +215,8 @@ AFLD:
|
||||
BelowUnits:
|
||||
ProductionAirdrop:
|
||||
Produces: Vehicle
|
||||
|
||||
SpawnOffsets: -24,0
|
||||
ExitCells:3,1
|
||||
WEAP:
|
||||
Inherits: ^Building
|
||||
Buildable:
|
||||
|
||||
Reference in New Issue
Block a user