ore growth -> trait on world
This commit is contained in:
@@ -24,7 +24,7 @@ namespace OpenRA.Server
|
|||||||
const int DownloadChunkInterval = 20000;
|
const int DownloadChunkInterval = 20000;
|
||||||
const int DownloadChunkSize = 16384;
|
const int DownloadChunkSize = 16384;
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static int Main(string[] args)
|
||||||
{
|
{
|
||||||
if (args.Length > 0) defaultMods = args;
|
if (args.Length > 0) defaultMods = args;
|
||||||
lobbyInfo = new Session();
|
lobbyInfo = new Session();
|
||||||
@@ -39,10 +39,10 @@ namespace OpenRA.Server
|
|||||||
listener.Start();
|
listener.Start();
|
||||||
Console.WriteLine("Server started.");
|
Console.WriteLine("Server started.");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Server failed to start.");
|
Console.WriteLine("Server failed to start.");
|
||||||
Environment.Exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; ; )
|
for (; ; )
|
||||||
|
|||||||
@@ -356,10 +356,8 @@ namespace OpenRa
|
|||||||
while (!PaletteAvailable(newIndex) && newIndex != (int)Game.world.LocalPlayer.PaletteIndex)
|
while (!PaletteAvailable(newIndex) && newIndex != (int)Game.world.LocalPlayer.PaletteIndex)
|
||||||
newIndex = (newIndex + d) % Player.PlayerColors.Count();
|
newIndex = (newIndex + d) % Player.PlayerColors.Count();
|
||||||
|
|
||||||
Game.world.Minimap.InvalidateSpawnPoints();
|
|
||||||
Game.IssueOrder(
|
Game.IssueOrder(
|
||||||
Order.Chat("/pal " + newIndex));
|
Order.Chat("/pal " + newIndex));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CycleRace(bool left)
|
void CycleRace(bool left)
|
||||||
|
|||||||
@@ -46,9 +46,6 @@ namespace OpenRa.GameRules
|
|||||||
public readonly float BuildupTime = 0;
|
public readonly float BuildupTime = 0;
|
||||||
public readonly int GemValue = 0;
|
public readonly int GemValue = 0;
|
||||||
public readonly int GoldValue = 0;
|
public readonly int GoldValue = 0;
|
||||||
public readonly float GrowthRate = 0;
|
|
||||||
public readonly bool OreGrows = true;
|
|
||||||
public readonly bool OreSpreads = true;
|
|
||||||
public readonly float OreTruckRate = 0;
|
public readonly float OreTruckRate = 0;
|
||||||
public readonly bool SeparateAircraft = true;
|
public readonly bool SeparateAircraft = true;
|
||||||
public readonly float SurvivorRate = 0;
|
public readonly float SurvivorRate = 0;
|
||||||
@@ -90,7 +87,6 @@ namespace OpenRa.GameRules
|
|||||||
public readonly bool FineDiffControl = false;
|
public readonly bool FineDiffControl = false;
|
||||||
|
|
||||||
/* OpenRA-specific */
|
/* OpenRA-specific */
|
||||||
public readonly float OreChance = 0; /* chance of spreading to a particular eligible cell */
|
|
||||||
public readonly int LowPowerSlowdown = 3; /* build time multiplier */
|
public readonly int LowPowerSlowdown = 3; /* build time multiplier */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace OpenRa.Graphics
|
|||||||
SpriteRenderer rgbaRenderer;
|
SpriteRenderer rgbaRenderer;
|
||||||
LineRenderer lineRenderer;
|
LineRenderer lineRenderer;
|
||||||
Sprite sprite, mapOnlySprite, mapSpawnPointSprite;
|
Sprite sprite, mapOnlySprite, mapSpawnPointSprite;
|
||||||
Bitmap terrain, oreLayer, spawnPointsLayer;
|
Bitmap terrain, oreLayer;
|
||||||
Rectangle bounds;
|
Rectangle bounds;
|
||||||
|
|
||||||
Sprite ownedSpawnPoint;
|
Sprite ownedSpawnPoint;
|
||||||
@@ -74,7 +74,6 @@ namespace OpenRa.Graphics
|
|||||||
static Color shroudColor;
|
static Color shroudColor;
|
||||||
|
|
||||||
public void InvalidateOre() { oreLayer = null; }
|
public void InvalidateOre() { oreLayer = null; }
|
||||||
public void InvalidateSpawnPoints() { spawnPointsLayer = null; }
|
|
||||||
|
|
||||||
public static Bitmap RenderTerrainBitmap(Map map, TileSet tileset)
|
public static Bitmap RenderTerrainBitmap(Map map, TileSet tileset)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -118,6 +118,7 @@
|
|||||||
<Compile Include="Support\PerfHistory.cs" />
|
<Compile Include="Support\PerfHistory.cs" />
|
||||||
<Compile Include="Sync.cs" />
|
<Compile Include="Sync.cs" />
|
||||||
<Compile Include="Traits\CrateSpawner.cs" />
|
<Compile Include="Traits\CrateSpawner.cs" />
|
||||||
|
<Compile Include="Traits\OreGrowth.cs" />
|
||||||
<Compile Include="Traits\OreRefinery.cs" />
|
<Compile Include="Traits\OreRefinery.cs" />
|
||||||
<Compile Include="Traits\Activities\Attack.cs" />
|
<Compile Include="Traits\Activities\Attack.cs" />
|
||||||
<Compile Include="Traits\Activities\CallFunc.cs" />
|
<Compile Include="Traits\Activities\CallFunc.cs" />
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ namespace OpenRa
|
|||||||
{
|
{
|
||||||
public static void AddOre(this Map map, int i, int j)
|
public static void AddOre(this Map map, int i, int j)
|
||||||
{
|
{
|
||||||
if (Rules.General.OreSpreads)
|
|
||||||
if (map.ContainsOre(i, j) && map.MapTiles[i, j].density < 12)
|
if (map.ContainsOre(i, j) && map.MapTiles[i, j].density < 12)
|
||||||
map.MapTiles[i, j].density++;
|
map.MapTiles[i, j].density++;
|
||||||
else if (map.MapTiles[i, j].overlay == 0xff)
|
else if (map.MapTiles[i, j].overlay == 0xff)
|
||||||
@@ -37,17 +36,14 @@ namespace OpenRa
|
|||||||
< double.PositiveInfinity;
|
< double.PositiveInfinity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GrowOre(this World world, Random r)
|
public static void SpreadOre(this World world, Random r, float chance)
|
||||||
{
|
{
|
||||||
var map = world.Map;
|
var map = world.Map;
|
||||||
|
|
||||||
var mini = map.XOffset; var maxi = map.XOffset + map.Width;
|
var mini = map.XOffset; var maxi = map.XOffset + map.Width;
|
||||||
var minj = map.YOffset; var maxj = map.YOffset + map.Height;
|
var minj = map.YOffset; var maxj = map.YOffset + map.Height;
|
||||||
var chance = Rules.General.OreChance;
|
|
||||||
|
|
||||||
/* phase 1: grow into neighboring regions */
|
/* phase 1: grow into neighboring regions */
|
||||||
if (Rules.General.OreSpreads)
|
|
||||||
{
|
|
||||||
var newOverlay = new byte[128, 128];
|
var newOverlay = new byte[128, 128];
|
||||||
for (int j = minj; j < maxj; j++)
|
for (int j = minj; j < maxj; j++)
|
||||||
for (int i = mini; i < maxi; i++)
|
for (int i = mini; i < maxi; i++)
|
||||||
@@ -66,9 +62,14 @@ namespace OpenRa
|
|||||||
map.MapTiles[i, j].overlay = newOverlay[i, j];
|
map.MapTiles[i, j].overlay = newOverlay[i, j];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* phase 2: increase density of existing areas */
|
public static void GrowOre(this World world, Random r)
|
||||||
if (Rules.General.OreGrows)
|
|
||||||
{
|
{
|
||||||
|
var map = world.Map;
|
||||||
|
|
||||||
|
var mini = map.XOffset; var maxi = map.XOffset + map.Width;
|
||||||
|
var minj = map.YOffset; var maxj = map.YOffset + map.Height;
|
||||||
|
|
||||||
|
/* phase 2: increase density of existing areas */
|
||||||
var newDensity = new byte[128, 128];
|
var newDensity = new byte[128, 128];
|
||||||
for (int j = minj; j < maxj; j++)
|
for (int j = minj; j < maxj; j++)
|
||||||
for (int i = mini; i < maxi; i++)
|
for (int i = mini; i < maxi; i++)
|
||||||
@@ -79,7 +80,6 @@ namespace OpenRa
|
|||||||
if (map.MapTiles[i, j].density < newDensity[i, j])
|
if (map.MapTiles[i, j].density < newDensity[i, j])
|
||||||
++map.MapTiles[i, j].density;
|
++map.MapTiles[i, j].density;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void InitOreDensity( this Map map )
|
public static void InitOreDensity( this Map map )
|
||||||
{
|
{
|
||||||
|
|||||||
42
OpenRa.Game/Traits/OreGrowth.cs
Normal file
42
OpenRa.Game/Traits/OreGrowth.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using OpenRa.Graphics;
|
||||||
|
|
||||||
|
namespace OpenRa.Traits
|
||||||
|
{
|
||||||
|
class OreGrowthInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
public readonly float Interval = 1f;
|
||||||
|
public readonly float Chance = .02f;
|
||||||
|
public readonly bool Spreads = true;
|
||||||
|
public readonly bool Grows = true;
|
||||||
|
|
||||||
|
public object Create(Actor self) { return new OreGrowth(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
class OreGrowth : ITick
|
||||||
|
{
|
||||||
|
int remainingTicks;
|
||||||
|
|
||||||
|
public void Tick(Actor self)
|
||||||
|
{
|
||||||
|
if (--remainingTicks <= 0)
|
||||||
|
{
|
||||||
|
var info = self.Info.Traits.Get<OreGrowthInfo>();
|
||||||
|
|
||||||
|
if (info.Spreads)
|
||||||
|
Ore.SpreadOre(self.World,
|
||||||
|
Game.SharedRandom,
|
||||||
|
info.Chance);
|
||||||
|
|
||||||
|
if (info.Grows)
|
||||||
|
Ore.GrowOre(self.World, Game.SharedRandom);
|
||||||
|
|
||||||
|
self.World.Minimap.InvalidateOre();
|
||||||
|
remainingTicks = (int)(info.Interval * 60 * 25);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,9 +50,6 @@ namespace OpenRa
|
|||||||
public readonly WorldRenderer WorldRenderer;
|
public readonly WorldRenderer WorldRenderer;
|
||||||
internal readonly Minimap Minimap;
|
internal readonly Minimap Minimap;
|
||||||
|
|
||||||
readonly int oreFrequency;
|
|
||||||
int oreTicks;
|
|
||||||
|
|
||||||
public World()
|
public World()
|
||||||
{
|
{
|
||||||
Timer.Time( "----World.ctor" );
|
Timer.Time( "----World.ctor" );
|
||||||
@@ -66,9 +63,6 @@ namespace OpenRa
|
|||||||
WorldRenderer = new WorldRenderer(this, Game.renderer);
|
WorldRenderer = new WorldRenderer(this, Game.renderer);
|
||||||
Timer.Time("renderer: {0}");
|
Timer.Time("renderer: {0}");
|
||||||
|
|
||||||
|
|
||||||
oreFrequency = (int)(Rules.General.GrowthRate * 60 * 25);
|
|
||||||
oreTicks = oreFrequency;
|
|
||||||
Map.InitOreDensity();
|
Map.InitOreDensity();
|
||||||
Timer.Time( "Ore: {0}" );
|
Timer.Time( "Ore: {0}" );
|
||||||
|
|
||||||
@@ -124,14 +118,6 @@ namespace OpenRa
|
|||||||
|
|
||||||
public void Tick()
|
public void Tick()
|
||||||
{
|
{
|
||||||
if (--oreTicks == 0)
|
|
||||||
using( new PerfSample( "ore" ) )
|
|
||||||
{
|
|
||||||
this.GrowOre( Game.SharedRandom );
|
|
||||||
Minimap.InvalidateOre();
|
|
||||||
oreTicks = oreFrequency;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var a in actors) a.Tick();
|
foreach (var a in actors) a.Tick();
|
||||||
Queries.WithTraitMultiple<ITick>().Do( x => x.Trait.Tick( x.Actor ) );
|
Queries.WithTraitMultiple<ITick>().Do( x => x.Trait.Tick( x.Actor ) );
|
||||||
|
|
||||||
|
|||||||
@@ -10,14 +10,11 @@ URepairPercent=20% ; [units only] percent cost to fully repair as ratio of
|
|||||||
URepairStep=10 ; [units only] hit points to heal per repair 'tick' for units
|
URepairStep=10 ; [units only] hit points to heal per repair 'tick' for units
|
||||||
BuildSpeed=.1 ; general build speed [time (in minutes) to produce a 1000 credit cost item]
|
BuildSpeed=.1 ; general build speed [time (in minutes) to produce a 1000 credit cost item]
|
||||||
|
|
||||||
OreGrows=yes ; Does ore grow denser over time?
|
|
||||||
OreSpreads=yes ; Does ore spread into adjacent areas
|
|
||||||
GemValue=50 ; gem credits per 'bail' carried by a harvester
|
GemValue=50 ; gem credits per 'bail' carried by a harvester
|
||||||
GoldValue=25 ; gold credits per 'bail' carried by a harvester
|
GoldValue=25 ; gold credits per 'bail' carried by a harvester
|
||||||
GrowthRate=.3 ; minutes between ore (Tiberium) growth
|
GrowthRate=.3 ; minutes between ore (Tiberium) growth
|
||||||
BailCount=28 ; number of 'bails' carried by a harvester
|
BailCount=28 ; number of 'bails' carried by a harvester
|
||||||
;; OreChance is missing from rules.ini but referenced
|
LowPowerSlowdown=3 ; slowdown factor for low power
|
||||||
;; LowPowerSlowdown is missing from rules.ini but referenced
|
|
||||||
|
|
||||||
GapRegenInterval=.1 ; gap generators will regenerate their shroud at this time interval
|
GapRegenInterval=.1 ; gap generators will regenerate their shroud at this time interval
|
||||||
SubmergeDelay=.02 ; forced delay that subs will remain on surface before allowing to submerge
|
SubmergeDelay=.02 ; forced delay that subs will remain on surface before allowing to submerge
|
||||||
|
|||||||
@@ -105,3 +105,8 @@ World:
|
|||||||
B: 0
|
B: 0
|
||||||
A: 180
|
A: 180
|
||||||
ShroudPalette:
|
ShroudPalette:
|
||||||
|
OreGrowth:
|
||||||
|
Interval: .3
|
||||||
|
Chance: .02
|
||||||
|
Spreads: yes
|
||||||
|
Grows: yes
|
||||||
@@ -69,9 +69,6 @@ BuildSpeed=.8 ; general build speed [time (in minutes) to produce a 10
|
|||||||
BuildupTime=.06 ; average minutes that building build-up animation runs
|
BuildupTime=.06 ; average minutes that building build-up animation runs
|
||||||
GemValue=50 ; gem credits per 'bail' carried by a harvester
|
GemValue=50 ; gem credits per 'bail' carried by a harvester
|
||||||
GoldValue=25 ; gold credits per 'bail' carried by a harvester
|
GoldValue=25 ; gold credits per 'bail' carried by a harvester
|
||||||
GrowthRate=.3 ; minutes between ore (Tiberium) growth
|
|
||||||
OreGrows=yes ; Does ore grow denser over time?
|
|
||||||
OreSpreads=yes ; Does ore spread into adjacent areas?
|
|
||||||
OreTruckRate=1 ; speed that harvester truck manages ore [larger means slower]
|
OreTruckRate=1 ; speed that harvester truck manages ore [larger means slower]
|
||||||
SeparateAircraft=no ; Is first helicopter to be purchased separately from helipad?
|
SeparateAircraft=no ; Is first helicopter to be purchased separately from helipad?
|
||||||
SurvivorRate=.4 ; fraction of building cost to be converted to survivors when sold
|
SurvivorRate=.4 ; fraction of building cost to be converted to survivors when sold
|
||||||
@@ -110,6 +107,7 @@ TeamDelay=.6 ; interval between checking for and creating teams
|
|||||||
|
|
||||||
; misc
|
; misc
|
||||||
FineDiffControl=no ; Allow 5 difficulty settings instead of only 3 settings?
|
FineDiffControl=no ; Allow 5 difficulty settings instead of only 3 settings?
|
||||||
|
LowPowerSlowdown=3
|
||||||
|
|
||||||
|
|
||||||
; ******* Weapon Statistics *******
|
; ******* Weapon Statistics *******
|
||||||
@@ -1011,10 +1009,6 @@ Verses=100%,100%,100%,100%,100%
|
|||||||
ImpactSound=kaboom25
|
ImpactSound=kaboom25
|
||||||
Explosion=7
|
Explosion=7
|
||||||
|
|
||||||
[General]
|
|
||||||
OreChance=.02
|
|
||||||
LowPowerSlowdown=3
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[VoiceTypes]
|
[VoiceTypes]
|
||||||
|
|||||||
@@ -158,6 +158,11 @@ World:
|
|||||||
B: 0
|
B: 0
|
||||||
A: 180
|
A: 180
|
||||||
ShroudPalette:
|
ShroudPalette:
|
||||||
|
OreGrowth:
|
||||||
|
Interval: .3
|
||||||
|
Chance: .02
|
||||||
|
Spreads: yes
|
||||||
|
Grows: yes
|
||||||
|
|
||||||
MGG:
|
MGG:
|
||||||
GeneratesGap:
|
GeneratesGap:
|
||||||
|
|||||||
Reference in New Issue
Block a user