Merge pull request #6837 from obrakmann/mission-polish

Another mission polish PR
This commit is contained in:
Matthias Mailänder
2014-10-26 07:47:47 +01:00
20 changed files with 114 additions and 101 deletions

View File

@@ -20,8 +20,9 @@ namespace OpenRA.Mods.RA
{
class CrateInfo : ITraitInfo, IOccupySpaceInfo, Requires<RenderSpritesInfo>
{
[Desc("Seconds")]
public readonly int Lifetime = 5;
[Desc("Length of time (in seconds) until the crate gets removed automatically. " +
"A value of zero disables auto-removal.")]
public readonly int Lifetime = 0;
[Desc("Allowed to land on.")]
public readonly string[] TerrainTypes = { };
@@ -57,24 +58,27 @@ namespace OpenRA.Mods.RA
if (collected)
return;
var shares = 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);
var crateActions = self.TraitsImplementing<CrateAction>();
self.Destroy();
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);
return;
if (n < s.Second)
{
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)
{
if (++ticks >= info.Lifetime * 25)
if (info.Lifetime != 0 && ++ticks >= info.Lifetime * 25)
self.Destroy();
}

View File

@@ -202,7 +202,8 @@ namespace OpenRA.Mods.RA.Scripting
"The function will return true if production could be started, false otherwise. " +
"If an actionFunc is given, it will be called as actionFunc(Actor[] actors) once " +
"production of all actors has been completed. The actors array is guaranteed to " +
"only contain alive actors.")]
"only contain alive actors. Note: This function will fail to work when called " +
"during the first tick")]
public bool Build(string[] actorTypes, LuaFunction actionFunc = null)
{
var typeToQueueMap = new Dictionary<string, string>();