replace EmitCargoOnSell with Cargo.EjectOnSell
This commit is contained in:
@@ -23,11 +23,12 @@ namespace OpenRA.Mods.RA
|
||||
public readonly int PipCount = 0;
|
||||
public readonly string[] Types = { };
|
||||
public readonly string[] InitialUnits = { };
|
||||
public readonly bool EjectOnSell = true;
|
||||
|
||||
public object Create(ActorInitializer init) { return new Cargo(init, this); }
|
||||
}
|
||||
|
||||
public class Cargo : IPips, IIssueOrder, IResolveOrder, IOrderVoice, INotifyKilled, INotifyCapture, ITick
|
||||
public class Cargo : IPips, IIssueOrder, IResolveOrder, IOrderVoice, INotifyKilled, INotifyCapture, ITick, INotifySold
|
||||
{
|
||||
readonly Actor self;
|
||||
public readonly CargoInfo Info;
|
||||
@@ -190,6 +191,26 @@ namespace OpenRA.Mods.RA
|
||||
cargo.Clear();
|
||||
}
|
||||
|
||||
public void Selling(Actor self) { }
|
||||
public void Sold(Actor self)
|
||||
{
|
||||
if (!Info.EjectOnSell || cargo == null)
|
||||
return;
|
||||
|
||||
while (!IsEmpty(self))
|
||||
SpawnPassenger(Unload(self));
|
||||
}
|
||||
|
||||
void SpawnPassenger(Actor passenger)
|
||||
{
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
w.Add(passenger);
|
||||
passenger.Trait<IPositionable>().SetPosition(passenger, self.Location);
|
||||
// TODO: this won't work well for >1 actor as they should move towards the next enterable (sub) cell instead
|
||||
});
|
||||
}
|
||||
|
||||
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
|
||||
{
|
||||
if (cargo == null)
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class EmitCargoOnSellInfo : ITraitInfo//, Requires<Cargo> // TODO: this breaks for no apparent reason
|
||||
{
|
||||
public object Create(ActorInitializer init) { return new EmitCargoOnSell(init); }
|
||||
}
|
||||
|
||||
class EmitCargoOnSell : INotifySold
|
||||
{
|
||||
readonly Cargo cargo;
|
||||
Actor passenger;
|
||||
|
||||
public EmitCargoOnSell(ActorInitializer init)
|
||||
{
|
||||
cargo = init.self.Trait<Cargo>();
|
||||
}
|
||||
|
||||
public void Selling(Actor self)
|
||||
{
|
||||
// TODO: support more than one passenger
|
||||
passenger = cargo.Unload(self);
|
||||
}
|
||||
|
||||
public void Sold(Actor self)
|
||||
{
|
||||
if (passenger == null)
|
||||
return;
|
||||
|
||||
self.World.AddFrameEndTask(w => w.CreateActor(passenger.Info.Name, new TypeDictionary
|
||||
{
|
||||
new LocationInit(self.Location),
|
||||
new OwnerInit(self.Owner),
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -229,7 +229,6 @@
|
||||
<Compile Include="Effects\SatelliteLaunch.cs" />
|
||||
<Compile Include="Effects\Smoke.cs" />
|
||||
<Compile Include="Effects\TeslaZap.cs" />
|
||||
<Compile Include="EmitCargoOnSell.cs" />
|
||||
<Compile Include="EmitInfantryOnSell.cs" />
|
||||
<Compile Include="EngineerRepair.cs" />
|
||||
<Compile Include="Explodes.cs" />
|
||||
|
||||
@@ -439,7 +439,6 @@ PBOX:
|
||||
PipCount: 1
|
||||
InitialUnits: e1
|
||||
-EmitInfantryOnSell:
|
||||
EmitCargoOnSell:
|
||||
DrawLineToTarget:
|
||||
AttackGarrisoned:
|
||||
Armaments: garrisoned
|
||||
@@ -486,7 +485,6 @@ HBOX:
|
||||
PipCount: 1
|
||||
InitialUnits: e1
|
||||
-EmitInfantryOnSell:
|
||||
EmitCargoOnSell:
|
||||
DrawLineToTarget:
|
||||
DetectCloaked:
|
||||
Range: 6
|
||||
|
||||
Reference in New Issue
Block a user