no nonlocal shroud; beginning of Shroud trait; fog switch on shroud palette hack
This commit is contained in:
@@ -24,6 +24,9 @@ namespace OpenRA.FileFormats
|
|||||||
{
|
{
|
||||||
public class ShroudPaletteRemap : IPaletteRemap
|
public class ShroudPaletteRemap : IPaletteRemap
|
||||||
{
|
{
|
||||||
|
bool isFog;
|
||||||
|
|
||||||
|
public ShroudPaletteRemap(bool isFog) { this.isFog = isFog; }
|
||||||
public Color GetRemappedColor(Color original, int index)
|
public Color GetRemappedColor(Color original, int index)
|
||||||
{
|
{
|
||||||
// false-color version for debug
|
// false-color version for debug
|
||||||
@@ -36,13 +39,22 @@ namespace OpenRA.FileFormats
|
|||||||
// Color.Purple,
|
// Color.Purple,
|
||||||
// Color.Cyan}[index % 8];
|
// Color.Cyan}[index % 8];
|
||||||
|
|
||||||
return new[] {
|
if (isFog)
|
||||||
Color.Transparent, Color.Green,
|
return new[] {
|
||||||
Color.Blue, Color.Yellow,
|
Color.Transparent, Color.Green,
|
||||||
Color.Black,
|
Color.Blue, Color.Yellow,
|
||||||
Color.FromArgb(192,0,0,0),
|
Color.Transparent,
|
||||||
Color.FromArgb(128,0,0,0),
|
Color.Transparent,
|
||||||
Color.FromArgb(64,0,0,0)}[index % 8];
|
Color.FromArgb(128,0,0,0),
|
||||||
|
Color.FromArgb(64,0,0,0)}[index % 8];
|
||||||
|
else
|
||||||
|
return new[] {
|
||||||
|
Color.Transparent, Color.Green,
|
||||||
|
Color.Blue, Color.Yellow,
|
||||||
|
Color.Black,
|
||||||
|
Color.FromArgb(128,0,0,0),
|
||||||
|
Color.Transparent,
|
||||||
|
Color.Transparent}[index % 8];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,7 @@
|
|||||||
<Compile Include="Chat.cs" />
|
<Compile Include="Chat.cs" />
|
||||||
<Compile Include="Chrome.cs" />
|
<Compile Include="Chrome.cs" />
|
||||||
<Compile Include="Traits\AI\ReturnOnIdle.cs" />
|
<Compile Include="Traits\AI\ReturnOnIdle.cs" />
|
||||||
|
<Compile Include="Traits\World\Shroud.cs" />
|
||||||
<Compile Include="Widgets\Delegates\ConnectionDialogsDelegate.cs" />
|
<Compile Include="Widgets\Delegates\ConnectionDialogsDelegate.cs" />
|
||||||
<Compile Include="Widgets\Delegates\CreateServerMenuDelegate.cs" />
|
<Compile Include="Widgets\Delegates\CreateServerMenuDelegate.cs" />
|
||||||
<Compile Include="Widgets\Delegates\MainMenuButtonsDelegate.cs" />
|
<Compile Include="Widgets\Delegates\MainMenuButtonsDelegate.cs" />
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ using System.Linq;
|
|||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Traits;
|
|
||||||
using OpenRA.Support;
|
using OpenRA.Support;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA
|
namespace OpenRA
|
||||||
{
|
{
|
||||||
@@ -64,6 +64,8 @@ namespace OpenRA
|
|||||||
|
|
||||||
public void Tick( World world )
|
public void Tick( World world )
|
||||||
{
|
{
|
||||||
|
if (owner != owner.World.LocalPlayer) return;
|
||||||
|
|
||||||
if (gapTicks > 0) { --gapTicks; return; }
|
if (gapTicks > 0) { --gapTicks; return; }
|
||||||
|
|
||||||
// Clear active flags
|
// Clear active flags
|
||||||
@@ -102,6 +104,8 @@ namespace OpenRA
|
|||||||
|
|
||||||
public void ResetExplored()
|
public void ResetExplored()
|
||||||
{
|
{
|
||||||
|
if (owner != owner.World.LocalPlayer) return;
|
||||||
|
|
||||||
explored = new bool[map.MapSize, map.MapSize];
|
explored = new bool[map.MapSize, map.MapSize];
|
||||||
dirty = true;
|
dirty = true;
|
||||||
}
|
}
|
||||||
@@ -113,6 +117,8 @@ namespace OpenRA
|
|||||||
|
|
||||||
public void Explore(World w, int2 center, int range)
|
public void Explore(World w, int2 center, int range)
|
||||||
{
|
{
|
||||||
|
if (owner != owner.World.LocalPlayer) return;
|
||||||
|
|
||||||
using (new PerfSample("explore"))
|
using (new PerfSample("explore"))
|
||||||
{
|
{
|
||||||
if (range == 0)
|
if (range == 0)
|
||||||
@@ -133,6 +139,8 @@ namespace OpenRA
|
|||||||
|
|
||||||
public void Explore(Actor a)
|
public void Explore(Actor a)
|
||||||
{
|
{
|
||||||
|
if (owner != owner.World.LocalPlayer) return;
|
||||||
|
|
||||||
var sight = a.Info.Traits.Get<OwnedActorInfo>().Sight;
|
var sight = a.Info.Traits.Get<OwnedActorInfo>().Sight;
|
||||||
|
|
||||||
// Buildings: explore from each cell in the footprint
|
// Buildings: explore from each cell in the footprint
|
||||||
|
|||||||
54
OpenRA.Game/Traits/World/Shroud.cs
Normal file
54
OpenRA.Game/Traits/World/Shroud.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
|
* This file is part of OpenRA.
|
||||||
|
*
|
||||||
|
* OpenRA is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* OpenRA is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using OpenRA.FileFormats;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace OpenRA.Traits
|
||||||
|
{
|
||||||
|
class ShroudInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
public object Create(Actor self) { return new Shroud(self, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
class Shroud
|
||||||
|
{
|
||||||
|
Map map;
|
||||||
|
int[,] visibleCells;
|
||||||
|
|
||||||
|
public Shroud(Actor self, ShroudInfo info)
|
||||||
|
{
|
||||||
|
map = self.World.Map;
|
||||||
|
visibleCells = new int[map.MapSize, map.MapSize];
|
||||||
|
|
||||||
|
self.World.ActorAdded += AddActor;
|
||||||
|
self.World.ActorRemoved += RemoveActor;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ActorVisibility
|
||||||
|
{
|
||||||
|
int range;
|
||||||
|
int2[] vis;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddActor(Actor a) { }
|
||||||
|
void RemoveActor(Actor a) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,18 +24,19 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
class ShroudPaletteInfo : ITraitInfo
|
class ShroudPaletteInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
public object Create(Actor self) { return new ShroudPalette(self); }
|
public readonly string Name = "shroud";
|
||||||
|
public readonly bool IsFog = false;
|
||||||
|
public object Create(Actor self) { return new ShroudPalette(self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class ShroudPalette
|
class ShroudPalette
|
||||||
{
|
{
|
||||||
public ShroudPalette(Actor self)
|
public ShroudPalette(Actor self, ShroudPaletteInfo info)
|
||||||
{
|
{
|
||||||
// TODO: This shouldn't rely on a base palette
|
// TODO: This shouldn't rely on a base palette
|
||||||
var wr = self.World.WorldRenderer;
|
var wr = self.World.WorldRenderer;
|
||||||
var pal = wr.GetPalette("terrain");
|
var pal = wr.GetPalette("terrain");
|
||||||
|
wr.AddPalette(info.Name, new Palette(pal, new ShroudPaletteRemap(info.IsFog)));
|
||||||
wr.AddPalette("shroud", new Palette(pal, new ShroudPaletteRemap()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user