Merge pull request #6152 from Mailaender/money-crate

Added money crates to be spawned by destroyed supply trucks
This commit is contained in:
Chris Forbes
2014-08-04 10:39:29 +12:00
8 changed files with 45 additions and 34 deletions

View File

@@ -1,30 +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;
namespace OpenRA.Mods.RA
{
[Desc("Leave a \"crate\" actor after destruction.")]
public class ContainsCrateInfo : TraitInfo<ContainsCrate> { }
public class ContainsCrate : INotifyKilled
{
public void Killed(Actor self, AttackInfo e)
{
self.World.AddFrameEndTask(w => w.CreateActor("crate", new TypeDictionary
{
new LocationInit(self.Location),
new OwnerInit(self.World.WorldActor.Owner),
}));
}
}
}

View File

@@ -22,12 +22,15 @@ namespace OpenRA.Mods.RA
[Desc("Seconds")] [Desc("Seconds")]
public readonly int Lifetime = 5; public readonly int Lifetime = 5;
[Desc("Allowed to land on.")]
public readonly string[] TerrainTypes = { }; public readonly string[] TerrainTypes = { };
[Desc("Define actors that can collect crates by setting this into the Crushes field from the Mobile trait.")]
public readonly string CrushClass = "crate";
public object Create(ActorInitializer init) { return new Crate(init, this); } public object Create(ActorInitializer init) { return new Crate(init, this); }
} }
// ITeleportable is required for paradrop
class Crate : ITick, IPositionable, ICrushable, ISync, INotifyParachuteLanded, INotifyAddedToWorld, INotifyRemovedFromWorld class Crate : ITick, IPositionable, ICrushable, ISync, INotifyParachuteLanded, INotifyAddedToWorld, INotifyRemovedFromWorld
{ {
readonly Actor self; readonly Actor self;
@@ -128,7 +131,7 @@ namespace OpenRA.Mods.RA
public bool CrushableBy(string[] crushClasses, Player owner) public bool CrushableBy(string[] crushClasses, Player owner)
{ {
return crushClasses.Contains("crate"); return crushClasses.Contains(info.CrushClass);
} }
public void AddedToWorld(Actor self) public void AddedToWorld(Actor self)

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA.Crates
public SupportPowerCrateAction(Actor self, SupportPowerCrateActionInfo info) public SupportPowerCrateAction(Actor self, SupportPowerCrateActionInfo info)
: base(self, info) { Info = info; } : base(self, info) { Info = info; }
// The free unit crate requires same race, and the actor to be at least ITeleportable. // The free unit crate requires same race and the actor needs to be mobile.
// We want neither of these properties for crate power proxies. // We want neither of these properties for crate power proxies.
public override void Activate(Actor collector) public override void Activate(Actor collector)
{ {

View File

@@ -190,7 +190,6 @@
<Compile Include="Chronoshiftable.cs" /> <Compile Include="Chronoshiftable.cs" />
<Compile Include="Cloak.cs" /> <Compile Include="Cloak.cs" />
<Compile Include="ConquestVictoryConditions.cs" /> <Compile Include="ConquestVictoryConditions.cs" />
<Compile Include="ContainsCrate.cs" />
<Compile Include="Crate.cs" /> <Compile Include="Crate.cs" />
<Compile Include="CrateAction.cs" /> <Compile Include="CrateAction.cs" />
<Compile Include="CrateSpawner.cs" /> <Compile Include="CrateSpawner.cs" />

View File

@@ -354,6 +354,16 @@ namespace OpenRA.Utility
} }
} }
if (engineVersion < 20140803)
{
// ContainsCrate was removed (use LeavesHusk instead)
if (depth == 1 && node.Key == "ContainsCrate")
{
node.Key = "LeavesHusk";
node.Value.Nodes.Add(new MiniYamlNode("HuskActor", new MiniYaml("crate")));
}
}
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
} }
} }

View File

@@ -160,6 +160,28 @@ CRATE:
Passenger: Passenger:
BodyOrientation: BodyOrientation:
MONEYCRATE:
Tooltip:
Name: Money Crate
Crate:
Lifetime: 180
TerrainTypes: Clear, Rough, Road, Ore, Beach
GiveCashCrateAction:
Amount: 500
SelectionShares: 1
UseCashTick: true
RenderSprites:
Palette: effect
WithCrateBody:
Images: wcrate
XmasImages: xcratea, xcrateb, xcratec, xcrated
Selectable:
Selectable: false
Bounds: 15,15,-1,-1
ProximityCaptor:
Types: Crate
BodyOrientation:
CAMERA: CAMERA:
Immobile: Immobile:
OccupiesSpace: false OccupiesSpace: false

View File

@@ -480,6 +480,8 @@ TRUK:
Explodes: Explodes:
Weapon: UnitExplodeSmall Weapon: UnitExplodeSmall
EmptyWeapon: UnitExplodeSmall EmptyWeapon: UnitExplodeSmall
LeavesHusk:
HuskActor: moneycrate
MGG: MGG:
Inherits: ^Vehicle Inherits: ^Vehicle

View File

@@ -268,6 +268,11 @@ scrate:
Tick: 500 Tick: 500
ZOffset: -511 ZOffset: -511
wcrate:
idle:
Start: 0
ZOffset: -511
xcratea: xcratea:
idle: idle:
Start: 0 Start: 0