Merge pull request #5696 from Mailaender/emit-cargo-on-sell
Finished EmitCargoOnSell
This commit is contained in:
@@ -23,11 +23,12 @@ namespace OpenRA.Mods.RA
|
|||||||
public readonly int PipCount = 0;
|
public readonly int PipCount = 0;
|
||||||
public readonly string[] Types = { };
|
public readonly string[] Types = { };
|
||||||
public readonly string[] InitialUnits = { };
|
public readonly string[] InitialUnits = { };
|
||||||
|
public readonly bool EjectOnSell = true;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new Cargo(init, this); }
|
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;
|
readonly Actor self;
|
||||||
public readonly CargoInfo Info;
|
public readonly CargoInfo Info;
|
||||||
@@ -190,6 +191,26 @@ namespace OpenRA.Mods.RA
|
|||||||
cargo.Clear();
|
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)
|
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
|
||||||
{
|
{
|
||||||
if (cargo == null)
|
if (cargo == null)
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2011 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.Traits;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
|
||||||
{
|
|
||||||
// for some reason I get yelled at for pbox.e1 not having Cargo, but that's a lie?
|
|
||||||
class EmitCargoOnSellInfo : TraitInfo<EmitCargoOnSell>//, Requires<Cargo>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
class EmitCargoOnSell : INotifySold
|
|
||||||
{
|
|
||||||
static void Emit(Actor self)
|
|
||||||
{
|
|
||||||
// TODO: would like to spill all actors out similar to how we call Unload
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Selling(Actor self) { Emit(self); }
|
|
||||||
public void Sold(Actor self) { }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public readonly string[] ActorTypes = { "e1" };
|
public readonly string[] ActorTypes = { "e1" };
|
||||||
}
|
}
|
||||||
|
|
||||||
class EmitInfantryOnSell : INotifySold, INotifyKilled
|
class EmitInfantryOnSell : INotifySold
|
||||||
{
|
{
|
||||||
public void Selling(Actor self) { }
|
public void Selling(Actor self) { }
|
||||||
|
|
||||||
@@ -54,17 +54,12 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
self.World.AddFrameEndTask(w => w.CreateActor(at.Name, new TypeDictionary
|
self.World.AddFrameEndTask(w => w.CreateActor(at.Name, new TypeDictionary
|
||||||
{
|
{
|
||||||
new LocationInit( loc ),
|
new LocationInit(loc),
|
||||||
new OwnerInit( self.Owner ),
|
new OwnerInit(self.Owner),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Sold(Actor self) { Emit(self); }
|
public void Sold(Actor self) { Emit(self); }
|
||||||
|
|
||||||
public void Killed(Actor self, AttackInfo e)
|
|
||||||
{
|
|
||||||
Emit(self);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -229,7 +229,6 @@
|
|||||||
<Compile Include="Effects\SatelliteLaunch.cs" />
|
<Compile Include="Effects\SatelliteLaunch.cs" />
|
||||||
<Compile Include="Effects\Smoke.cs" />
|
<Compile Include="Effects\Smoke.cs" />
|
||||||
<Compile Include="Effects\TeslaZap.cs" />
|
<Compile Include="Effects\TeslaZap.cs" />
|
||||||
<Compile Include="EmitCargoOnSell.cs" />
|
|
||||||
<Compile Include="EmitInfantryOnSell.cs" />
|
<Compile Include="EmitInfantryOnSell.cs" />
|
||||||
<Compile Include="EngineerRepair.cs" />
|
<Compile Include="EngineerRepair.cs" />
|
||||||
<Compile Include="Explodes.cs" />
|
<Compile Include="Explodes.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user