Ditto Player, Shroud, and Smudge
This commit is contained in:
@@ -29,7 +29,7 @@ namespace OpenRa
|
||||
impactSound = warhead.WaterImpactSound;
|
||||
if (impactSound != null) Sound.Play(impactSound + ".aud");
|
||||
|
||||
if (!isWater) Smudge.AddSmudge(targetTile, warhead);
|
||||
if (!isWater) world.Map.AddSmudge(targetTile, warhead);
|
||||
if (warhead.Ore) world.Map.DestroyOre(targetTile.X, targetTile.Y);
|
||||
|
||||
var maxSpread = GetMaximumSpread(weapon, warhead);
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace OpenRa
|
||||
public int PowerProvided = 0;
|
||||
public int PowerDrained = 0;
|
||||
|
||||
public World World { get { return PlayerActor.World; } }
|
||||
|
||||
public Shroud Shroud;
|
||||
public Dictionary<string, SupportPower> SupportPowers;
|
||||
|
||||
@@ -52,7 +54,7 @@ namespace OpenRa
|
||||
PowerProvided = 0;
|
||||
PowerDrained = 0;
|
||||
|
||||
var myBuildings = Game.world.Actors
|
||||
var myBuildings = World.Actors
|
||||
.Where(a => a.Owner == this && a.traits.Contains<Building>());
|
||||
|
||||
foreach (var a in myBuildings)
|
||||
@@ -83,7 +85,7 @@ namespace OpenRa
|
||||
|
||||
void UpdateOreCapacity()
|
||||
{
|
||||
OreCapacity = Game.world.Actors
|
||||
OreCapacity = World.Actors
|
||||
.Where(a => a.Owner == this && a.traits.Contains<StoresOre>())
|
||||
.Select(a => a.Info.Traits.Get<StoresOreInfo>())
|
||||
.Sum(b => b.Capacity);
|
||||
@@ -91,7 +93,7 @@ namespace OpenRa
|
||||
|
||||
void GiveAdvice(string advice)
|
||||
{
|
||||
if (this != Game.world.LocalPlayer) return;
|
||||
if (this != World.LocalPlayer) return;
|
||||
// todo: store the condition or something.
|
||||
// repeat after Rules.General.SpeakDelay, as long as the condition holds.
|
||||
Sound.Play(advice);
|
||||
@@ -130,12 +132,12 @@ namespace OpenRa
|
||||
{
|
||||
UpdatePower();
|
||||
UpdateOreCapacity();
|
||||
Shroud.Tick();
|
||||
Shroud.Tick( World );
|
||||
|
||||
foreach (var sp in SupportPowers.Values)
|
||||
sp.Tick();
|
||||
|
||||
if (this == Game.world.LocalPlayer)
|
||||
if (this == World.LocalPlayer)
|
||||
{
|
||||
var totalMoney = Cash + Ore;
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@ namespace OpenRa
|
||||
set { hasGPS = value; dirty = true;}
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
public void Tick( World world )
|
||||
{
|
||||
// Clear active flags
|
||||
gapActive = new bool[128, 128];
|
||||
foreach (var a in Game.world.Actors.Where(a => a.traits.Contains<GeneratesGap>() && owner != a.Owner))
|
||||
foreach (var a in world.Actors.Where(a => a.traits.Contains<GeneratesGap>() && owner != a.Owner))
|
||||
{
|
||||
foreach (var t in a.traits.Get<GeneratesGap>().GetShroudedTiles())
|
||||
gapActive[t.X, t.Y] = true;
|
||||
@@ -81,7 +81,7 @@ namespace OpenRa
|
||||
|
||||
public void Explore(Actor a)
|
||||
{
|
||||
foreach (var t in Game.world.FindTilesInCircle(
|
||||
foreach (var t in a.World.FindTilesInCircle(
|
||||
(1f / Game.CellSize * a.CenterLocation).ToInt2(),
|
||||
a.Info.Traits.Get<OwnedActorInfo>().Sight))
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using OpenRa.GameRules;
|
||||
using OpenRa.FileFormats;
|
||||
|
||||
namespace OpenRa
|
||||
{
|
||||
@@ -8,11 +9,11 @@ namespace OpenRa
|
||||
const int firstCrater = 17;
|
||||
const int framesPerCrater = 5;
|
||||
|
||||
public static void AddSmudge(bool isCrater, int x, int y)
|
||||
public static void AddSmudge(this Map map, bool isCrater, int x, int y)
|
||||
{
|
||||
var smudge = Game.world.Map.MapTiles[x, y].smudge;
|
||||
var smudge = map.MapTiles[x, y].smudge;
|
||||
if (smudge == 0)
|
||||
Game.world.Map.MapTiles[x, y].smudge = (byte) (isCrater
|
||||
map.MapTiles[x, y].smudge = (byte) (isCrater
|
||||
? (firstCrater + framesPerCrater * ChooseSmudge())
|
||||
: (firstScorch + ChooseSmudge()));
|
||||
|
||||
@@ -21,21 +22,21 @@ namespace OpenRa
|
||||
/* deepen the crater */
|
||||
var amount = (smudge - firstCrater) % framesPerCrater;
|
||||
if (amount < framesPerCrater - 1)
|
||||
Game.world.Map.MapTiles[x, y].smudge++;
|
||||
map.MapTiles[x, y].smudge++;
|
||||
}
|
||||
|
||||
public static void AddSmudge(int2 targetTile, WarheadInfo warhead)
|
||||
public static void AddSmudge(this Map map, int2 targetTile, WarheadInfo warhead)
|
||||
{
|
||||
switch (warhead.Explosion) /* todo: push the scorch/crater behavior into data */
|
||||
{
|
||||
case 4:
|
||||
case 5:
|
||||
Smudge.AddSmudge(true, targetTile.X, targetTile.Y);
|
||||
map.AddSmudge(true, targetTile.X, targetTile.Y);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case 6:
|
||||
Smudge.AddSmudge(false, targetTile.X, targetTile.Y);
|
||||
map.AddSmudge(false, targetTile.X, targetTile.Y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user