Make crates not suck
* allow for crates without any associated CrateActions * allow for crates to not auto-remove
This commit is contained in:
@@ -20,8 +20,9 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
class CrateInfo : ITraitInfo, IOccupySpaceInfo, Requires<RenderSpritesInfo>
|
class CrateInfo : ITraitInfo, IOccupySpaceInfo, Requires<RenderSpritesInfo>
|
||||||
{
|
{
|
||||||
[Desc("Seconds")]
|
[Desc("Length of time (in seconds) until the crate gets removed automatically. " +
|
||||||
public readonly int Lifetime = 5;
|
"A value of zero disables auto-removal.")]
|
||||||
|
public readonly int Lifetime = 0;
|
||||||
|
|
||||||
[Desc("Allowed to land on.")]
|
[Desc("Allowed to land on.")]
|
||||||
public readonly string[] TerrainTypes = { };
|
public readonly string[] TerrainTypes = { };
|
||||||
@@ -57,24 +58,27 @@ namespace OpenRA.Mods.RA
|
|||||||
if (collected)
|
if (collected)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var shares = self.TraitsImplementing<CrateAction>()
|
var crateActions = self.TraitsImplementing<CrateAction>();
|
||||||
.Select(a => Pair.New(a, a.GetSelectionSharesOuter(crusher)));
|
|
||||||
|
|
||||||
var totalShares = shares.Sum(a => a.Second);
|
|
||||||
var n = self.World.SharedRandom.Next(totalShares);
|
|
||||||
|
|
||||||
self.Destroy();
|
self.Destroy();
|
||||||
collected = true;
|
collected = true;
|
||||||
|
|
||||||
foreach (var s in shares)
|
if (crateActions.Any())
|
||||||
{
|
{
|
||||||
if (n < s.Second)
|
var shares = crateActions.Select(a => Pair.New(a, a.GetSelectionSharesOuter(crusher)));
|
||||||
|
|
||||||
|
var totalShares = shares.Sum(a => a.Second);
|
||||||
|
var n = self.World.SharedRandom.Next(totalShares);
|
||||||
|
|
||||||
|
foreach (var s in shares)
|
||||||
{
|
{
|
||||||
s.First.Activate(crusher);
|
if (n < s.Second)
|
||||||
return;
|
{
|
||||||
|
s.First.Activate(crusher);
|
||||||
|
return;
|
||||||
|
} else
|
||||||
|
n -= s.Second;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
n -= s.Second;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +111,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (++ticks >= info.Lifetime * 25)
|
if (info.Lifetime != 0 && ++ticks >= info.Lifetime * 25)
|
||||||
self.Destroy();
|
self.Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -646,4 +646,18 @@
|
|||||||
DestroyedSound: xplobig4.aud
|
DestroyedSound: xplobig4.aud
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
ScriptTriggers:
|
ScriptTriggers:
|
||||||
|
^Crate:
|
||||||
|
Tooltip:
|
||||||
|
Name: Crate
|
||||||
|
GenericName: Crate
|
||||||
|
Crate:
|
||||||
|
TerrainTypes: Clear, Rough, Road, Tiberium, BlueTiberium, Beach
|
||||||
|
RenderSprites:
|
||||||
|
Palette: effect
|
||||||
|
WithCrateBody:
|
||||||
|
XmasImages: xcratea, xcrateb, xcratec, xcrated
|
||||||
|
Selectable:
|
||||||
|
Selectable: false
|
||||||
|
Bounds: 15,15,-1,-1
|
||||||
|
BodyOrientation:
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
|
CRATE.plain:
|
||||||
|
Inherits: ^Crate
|
||||||
|
ScriptTriggers:
|
||||||
|
|
||||||
CRATE:
|
CRATE:
|
||||||
Tooltip:
|
Inherits: ^Crate
|
||||||
Name: Crate
|
|
||||||
Crate:
|
Crate:
|
||||||
Lifetime: 240
|
Lifetime: 240
|
||||||
TerrainTypes: Clear, Rough, Road, Tiberium, BlueTiberium, Beach
|
|
||||||
GiveCashCrateAction:
|
GiveCashCrateAction:
|
||||||
Amount: 1000
|
Amount: 1000
|
||||||
SelectionShares: 20
|
SelectionShares: 20
|
||||||
@@ -27,14 +29,6 @@ CRATE:
|
|||||||
SelectionShares: 0
|
SelectionShares: 0
|
||||||
NoBaseSelectionShares: 120
|
NoBaseSelectionShares: 120
|
||||||
Units: mcv
|
Units: mcv
|
||||||
RenderSprites:
|
|
||||||
Palette: effect
|
|
||||||
WithCrateBody:
|
|
||||||
XmasImages: xcratea, xcrateb, xcratec, xcrated
|
|
||||||
Selectable:
|
|
||||||
Selectable: false
|
|
||||||
Bounds: 15,15,-1,-1
|
|
||||||
BodyOrientation:
|
|
||||||
|
|
||||||
mpspawn:
|
mpspawn:
|
||||||
Immobile:
|
Immobile:
|
||||||
|
|||||||
Reference in New Issue
Block a user