Add ore capping to MissionUtils. Add world.CreateActor extension in MissionUtils.

This commit is contained in:
Scott_NZ
2013-02-04 21:38:44 +13:00
parent 9013e8376c
commit 3c5967a623
3 changed files with 21 additions and 28 deletions

View File

@@ -147,7 +147,7 @@ namespace OpenRA.Mods.RA.Missions
else if (einstein != null && einstein.Destroyed)
MissionFailed("Einstein was killed.");
ManageSovietOre();
MissionUtils.CapOre(soviets);
}
void LabSecured()
@@ -173,14 +173,6 @@ namespace OpenRA.Mods.RA.Missions
}
}
void ManageSovietOre()
{
var res = soviets.PlayerActor.Trait<PlayerResources>();
if (res.Ore > res.OreCapacity * 0.8)
res.TakeOre(res.OreCapacity / 10);
}
void SpawnSignalFlare()
{
world.CreateActor(SignalFlareName, new TypeDictionary { new OwnerInit(allies), new LocationInit(extractionLZ.Location) });

View File

@@ -167,7 +167,7 @@ namespace OpenRA.Mods.RA.Missions
foreach (var patrol in patrols)
patrol.DoPatrol();
ManageSovietOre();
MissionUtils.CapOre(soviets);
BaseGuardTick();
@@ -218,13 +218,6 @@ namespace OpenRA.Mods.RA.Missions
MissionFailed("The Soviet research laboratory was not secured in time.");
}
void ManageSovietOre()
{
var res = soviets.PlayerActor.Trait<PlayerResources>();
if (res.Ore > res.OreCapacity * 0.8)
res.TakeOre(res.OreCapacity / 10);
}
void BaseGuardTick()
{
if (baseGuardTicks <= 0 || baseGuard.IsDead() || !baseGuard.IsInWorld) return;

View File

@@ -205,18 +205,26 @@ namespace OpenRA.Mods.RA.Missions
Sound.Play("misnlst1.aud");
}
public static void SpawnAndMoveActors(World world, Player player, string[] actorNames, CPos entry, CPos move, int facing)
public static Actor CreateActor(this World world, bool addToWorld, string name, Player owner, CPos? location, int? facing)
{
foreach (var actor in actorNames)
{
world.CreateActor(actor, new TypeDictionary
{
new LocationInit(entry),
new OwnerInit(player),
new FacingInit(facing)
})
.QueueActivity(new Move.Move(move));
}
var td = new TypeDictionary { new OwnerInit(owner) };
if (location.HasValue)
td.Add(new LocationInit(location.Value));
if (facing.HasValue)
td.Add(new FacingInit(facing.Value));
return world.CreateActor(addToWorld, name, td);
}
public static Actor CreateActor(this World world, string name, Player owner, CPos? location, int? facing)
{
return CreateActor(world, true, name, owner, location, facing);
}
public static void CapOre(Player player)
{
var res = player.PlayerActor.Trait<PlayerResources>();
if (res.Ore > res.OreCapacity * 0.8)
res.Ore = (int)(res.OreCapacity * 0.8);
}
}