Gap generators
This commit is contained in:
@@ -481,9 +481,7 @@ namespace OpenRa.Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TickPaletteAnimation()
|
void TickPaletteAnimation()
|
||||||
{
|
{
|
||||||
Log.Write("{0} {1} {2} {3}", paletteAnimationFrame, paletteOrigin.X, paletteAnimating, paletteOpen);
|
|
||||||
|
|
||||||
if (!paletteAnimating)
|
if (!paletteAnimating)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -227,6 +227,7 @@
|
|||||||
<Compile Include="Traits\Explodes.cs" />
|
<Compile Include="Traits\Explodes.cs" />
|
||||||
<Compile Include="Traits\ChronoshiftDeploy.cs" />
|
<Compile Include="Traits\ChronoshiftDeploy.cs" />
|
||||||
<Compile Include="Traits\Fake.cs" />
|
<Compile Include="Traits\Fake.cs" />
|
||||||
|
<Compile Include="Traits\GeneratesGap.cs" />
|
||||||
<Compile Include="Traits\GpsLaunchSite.cs" />
|
<Compile Include="Traits\GpsLaunchSite.cs" />
|
||||||
<Compile Include="Traits\Harvester.cs" />
|
<Compile Include="Traits\Harvester.cs" />
|
||||||
<Compile Include="Traits\Helicopter.cs" />
|
<Compile Include="Traits\Helicopter.cs" />
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
UpdatePower();
|
UpdatePower();
|
||||||
UpdateOreCapacity();
|
UpdateOreCapacity();
|
||||||
|
Shroud.Tick();
|
||||||
|
|
||||||
foreach (var sp in SupportPowers.Values)
|
foreach (var sp in SupportPowers.Values)
|
||||||
sp.Tick();
|
sp.Tick();
|
||||||
|
|||||||
@@ -4,12 +4,14 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using IjwFramework.Types;
|
using IjwFramework.Types;
|
||||||
using OpenRa.Game.Graphics;
|
using OpenRa.Game.Graphics;
|
||||||
|
using OpenRa.Game.Traits;
|
||||||
|
|
||||||
namespace OpenRa.Game
|
namespace OpenRa.Game
|
||||||
{
|
{
|
||||||
class Shroud
|
class Shroud
|
||||||
{
|
{
|
||||||
bool[,] explored = new bool[128, 128];
|
bool[,] explored = new bool[128, 128];
|
||||||
|
int[,] gapField = new int[128, 128];
|
||||||
Sprite[] shadowBits = SpriteSheetBuilder.LoadAllSprites("shadow");
|
Sprite[] shadowBits = SpriteSheetBuilder.LoadAllSprites("shadow");
|
||||||
Sprite[,] sprites = new Sprite[128, 128];
|
Sprite[,] sprites = new Sprite[128, 128];
|
||||||
bool dirty;
|
bool dirty;
|
||||||
@@ -21,9 +23,35 @@ namespace OpenRa.Game
|
|||||||
set { hasGPS = value; dirty = true;}
|
set { hasGPS = value; dirty = true;}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Tick()
|
||||||
|
{
|
||||||
|
// This is probably slow
|
||||||
|
bool[,] gapActive = new bool[128, 128];
|
||||||
|
foreach (var a in Game.world.Actors.Where(a => a.traits.Contains<GeneratesGap>()))
|
||||||
|
{
|
||||||
|
foreach (var t in a.traits.Get<GeneratesGap>().GetShroudedTiles())
|
||||||
|
gapActive[t.X, t.Y] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 1; j < 127; j++)
|
||||||
|
for (int i = 1; i < 127; i++)
|
||||||
|
{
|
||||||
|
if (gapField[i, j] > 0 && !gapActive[i, j]) /*0 >= --gapField[i, j]*/
|
||||||
|
{
|
||||||
|
gapField[i, j] = 0;
|
||||||
|
dirty = true;
|
||||||
|
}
|
||||||
|
if (gapActive[i, j] && 0 == gapField[i, j]++)
|
||||||
|
dirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsExplored(int2 xy) { return IsExplored(xy.X, xy.Y); }
|
public bool IsExplored(int2 xy) { return IsExplored(xy.X, xy.Y); }
|
||||||
public bool IsExplored(int x, int y)
|
public bool IsExplored(int x, int y)
|
||||||
{
|
{
|
||||||
|
if (gapField[ x, y ] >= Rules.General.GapRegenInterval * 25 * 60)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (hasGPS)
|
if (hasGPS)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -33,8 +61,10 @@ namespace OpenRa.Game
|
|||||||
public void Explore(Actor a)
|
public void Explore(Actor a)
|
||||||
{
|
{
|
||||||
foreach (var t in Game.FindTilesInCircle((1f / Game.CellSize * a.CenterLocation).ToInt2(), a.Info.Sight))
|
foreach (var t in Game.FindTilesInCircle((1f / Game.CellSize * a.CenterLocation).ToInt2(), a.Info.Sight))
|
||||||
|
{
|
||||||
explored[t.X, t.Y] = true;
|
explored[t.X, t.Y] = true;
|
||||||
|
gapField[t.X, t.Y] = 0;
|
||||||
|
}
|
||||||
dirty = true;
|
dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
29
OpenRa.Game/Traits/GeneratesGap.cs
Normal file
29
OpenRa.Game/Traits/GeneratesGap.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using OpenRa.FileFormats;
|
||||||
|
using OpenRa.Game.Support;
|
||||||
|
using OpenRa.Game.Traits;
|
||||||
|
|
||||||
|
namespace OpenRa.Game.Traits
|
||||||
|
{
|
||||||
|
class GeneratesGap
|
||||||
|
{
|
||||||
|
Actor self;
|
||||||
|
public GeneratesGap(Actor self)
|
||||||
|
{
|
||||||
|
this.self = self;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<int2>GetShroudedTiles()
|
||||||
|
{
|
||||||
|
// Gap Generator building; powered down
|
||||||
|
if (self.traits.Contains<Building>() && self.traits.Get<Building>().Disabled)
|
||||||
|
yield break;
|
||||||
|
|
||||||
|
// It won't let me return Game.FindTilesInCircle directly...?
|
||||||
|
foreach (var t in Game.FindTilesInCircle(self.Location, Rules.General.GapRadius))
|
||||||
|
yield return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -77,7 +77,7 @@ Voice=VehicleVoice
|
|||||||
LongDesc=Hides nearby units on the enemy's minimap.\n Unarmed
|
LongDesc=Hides nearby units on the enemy's minimap.\n Unarmed
|
||||||
[MGG]
|
[MGG]
|
||||||
Description=Mobile Gap Generator
|
Description=Mobile Gap Generator
|
||||||
Traits=Unit, Mobile, RenderUnitSpinner, Repairable, Chronoshiftable, Passenger, IronCurtainable
|
Traits=Unit, Mobile, RenderUnitSpinner, Repairable, Chronoshiftable, Passenger, IronCurtainable, GeneratesGap
|
||||||
PrimaryOffset=0,6,0,-3
|
PrimaryOffset=0,6,0,-3
|
||||||
SelectionPriority=3
|
SelectionPriority=3
|
||||||
Voice=VehicleVoice
|
Voice=VehicleVoice
|
||||||
@@ -303,7 +303,7 @@ SelectionPriority=3
|
|||||||
LongDesc=Teleports a unit from one place \nto another, for a limited time.\n Special Ability: Chronoshift
|
LongDesc=Teleports a unit from one place \nto another, for a limited time.\n Special Ability: Chronoshift
|
||||||
[GAP]
|
[GAP]
|
||||||
Description=Gap Generator
|
Description=Gap Generator
|
||||||
Traits=Building, RenderBuilding, IronCurtainable
|
Traits=Building, RenderBuilding, IronCurtainable, GeneratesGap
|
||||||
Dimensions=1,2
|
Dimensions=1,2
|
||||||
Footprint=_ x
|
Footprint=_ x
|
||||||
SelectionPriority=3
|
SelectionPriority=3
|
||||||
|
|||||||
Reference in New Issue
Block a user