lots of experimental bits
This commit is contained in:
@@ -72,18 +72,18 @@ namespace OpenRA.Graphics
|
||||
Game.CellSize * (float2)location, "terrain");
|
||||
}
|
||||
|
||||
var o = tr.overlay;
|
||||
if (o < overlaySprites.Length)
|
||||
{
|
||||
var location = new int2(x, y);
|
||||
var sprites = overlaySprites[o];
|
||||
var spriteIndex = 0;
|
||||
if (Ore.overlayIsFence[o]) spriteIndex = NearbyFences(x, y);
|
||||
else if (Ore.overlayIsOre[o]) spriteIndex = map.MapTiles[x,y].density - 1;
|
||||
else if (Ore.overlayIsGems[o]) spriteIndex = map.MapTiles[x,y].density - 1;
|
||||
spriteRenderer.DrawSprite(sprites[spriteIndex],
|
||||
Game.CellSize * (float2)location, "terrain");
|
||||
}
|
||||
//var o = tr.overlay;
|
||||
//if (o < overlaySprites.Length)
|
||||
//{
|
||||
// var location = new int2(x, y);
|
||||
// var sprites = overlaySprites[o];
|
||||
// var spriteIndex = 0;
|
||||
// if (Ore.overlayIsFence[o]) spriteIndex = NearbyFences(x, y);
|
||||
// else if (Ore.overlayIsOre[o]) spriteIndex = map.MapTiles[x,y].density - 1;
|
||||
// else if (Ore.overlayIsGems[o]) spriteIndex = map.MapTiles[x,y].density - 1;
|
||||
// spriteRenderer.DrawSprite(sprites[spriteIndex],
|
||||
// Game.CellSize * (float2)location, "terrain");
|
||||
//}
|
||||
}
|
||||
|
||||
spriteRenderer.Flush();
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
using System.Drawing;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.FileFormats.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Graphics
|
||||
{
|
||||
@@ -104,6 +105,9 @@ namespace OpenRA.Graphics
|
||||
new Range<int>(indicesPerRow * firstRow, indicesPerRow * lastRow),
|
||||
terrainSheet.Texture, PrimitiveType.TriangleList, renderer.SpriteShader));
|
||||
|
||||
foreach (var r in Game.world.WorldActor.traits.WithInterface<IRenderOverlay>())
|
||||
r.Render();
|
||||
|
||||
overlayRenderer.Draw();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -216,6 +216,7 @@
|
||||
<Compile Include="Traits\Passenger.cs" />
|
||||
<Compile Include="Traits\Player\PlaceBuilding.cs" />
|
||||
<Compile Include="Traits\World\PlayerColorPalette.cs" />
|
||||
<Compile Include="Traits\World\ResourceLayer.cs" />
|
||||
<Compile Include="Traits\World\ShroudPalette.cs" />
|
||||
<Compile Include="Traits\SupportPowers\SupportPower.cs" />
|
||||
<Compile Include="Traits\ProvidesRadar.cs" />
|
||||
@@ -253,6 +254,7 @@
|
||||
<Compile Include="Traits\Turreted.cs" />
|
||||
<Compile Include="Traits\Unit.cs" />
|
||||
<Compile Include="Traits\World\UnitInfluence.cs" />
|
||||
<Compile Include="Traits\World\WallLoadHook.cs" />
|
||||
<Compile Include="Traits\World\WaterPaletteRotation.cs" />
|
||||
<Compile Include="Traits\Modifiers\WithShadow.cs" />
|
||||
<Compile Include="Network\UnitOrders.cs" />
|
||||
|
||||
@@ -140,4 +140,6 @@ namespace OpenRA.Traits
|
||||
bool Pressed { get; }
|
||||
void OnClick();
|
||||
}
|
||||
|
||||
public interface IRenderOverlay { void Render(); }
|
||||
}
|
||||
|
||||
88
OpenRA.Game/Traits/World/ResourceLayer.cs
Normal file
88
OpenRA.Game/Traits/World/ResourceLayer.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
#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 System;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class ResourceLayerInfo : ITraitInfo
|
||||
{
|
||||
public readonly string[] SpriteNames = { };
|
||||
public readonly int[] OverlayIndices = { };
|
||||
public readonly string Palette = "terrain";
|
||||
public object Create(Actor self) { return new ResourceLayer(self, this); }
|
||||
}
|
||||
|
||||
class ResourceLayer : IRenderOverlay, ILoadWorldHook
|
||||
{
|
||||
ResourceLayerInfo info;
|
||||
Sprite[][] sprites;
|
||||
CellContents[,] content = new CellContents[128,128];
|
||||
SpriteRenderer sr;
|
||||
|
||||
public ResourceLayer(Actor self, ResourceLayerInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
sprites = info.SpriteNames.Select( f => SpriteSheetBuilder.LoadAllSprites(f)).ToArray();
|
||||
sr = new SpriteRenderer( Game.renderer, true );
|
||||
}
|
||||
|
||||
public void Render()
|
||||
{
|
||||
var shroud = Game.world.LocalPlayer.Shroud;
|
||||
var map = Game.world.Map;
|
||||
|
||||
for (int y = map.YOffset; y < map.YOffset + map.Height; y++)
|
||||
for (int x = map.XOffset; x < map.XOffset + map.Width; x++)
|
||||
{
|
||||
if (!shroud.IsExplored(new int2(x, y))) continue;
|
||||
if (content[x, y].contents != null)
|
||||
sr.DrawSprite(content[x, y].contents[content[x, y].density],
|
||||
Game.CellSize * new int2(x, y),
|
||||
info.Palette);
|
||||
}
|
||||
|
||||
sr.Flush();
|
||||
}
|
||||
|
||||
public void WorldLoaded(World w)
|
||||
{
|
||||
var map = w.Map;
|
||||
|
||||
for (int y = map.YOffset; y < map.YOffset + map.Height; y++)
|
||||
for (int x = map.XOffset; x < map.XOffset + map.Width; x++)
|
||||
if (info.OverlayIndices.Contains(w.Map.MapTiles[x, y].overlay))
|
||||
content[x, y].contents = ChooseContent(w, w.Map.MapTiles[x, y].overlay);
|
||||
}
|
||||
|
||||
Sprite[] ChooseContent(World w, int overlay)
|
||||
{
|
||||
return sprites[w.SharedRandom.Next(sprites.Length)];
|
||||
}
|
||||
|
||||
public struct CellContents
|
||||
{
|
||||
public Sprite[] contents;
|
||||
public int density;
|
||||
}
|
||||
}
|
||||
}
|
||||
34
OpenRA.Game/Traits/World/WallLoadHook.cs
Normal file
34
OpenRA.Game/Traits/World/WallLoadHook.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class WallLoadHookInfo : ITraitInfo
|
||||
{
|
||||
public readonly int[] OverlayIndices = { };
|
||||
public readonly string ActorType = "brik";
|
||||
|
||||
public object Create(Actor self) { return new WallLoadHook( self, this ); }
|
||||
}
|
||||
|
||||
class WallLoadHook : ILoadWorldHook
|
||||
{
|
||||
WallLoadHookInfo info;
|
||||
public WallLoadHook(Actor self, WallLoadHookInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void WorldLoaded(World w)
|
||||
{
|
||||
var map = w.Map;
|
||||
|
||||
for (int y = map.YOffset; y < map.YOffset + map.Height; y++)
|
||||
for (int x = map.XOffset; x < map.XOffset + map.Width; x++)
|
||||
if (info.OverlayIndices.Contains(w.Map.MapTiles[x, y].overlay))
|
||||
w.CreateActor(info.ActorType, new int2(x, y), w.players[0]); // todo: neutral player or null?
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
mods/cnc/chem.shp
Normal file
BIN
mods/cnc/chem.shp
Normal file
Binary file not shown.
BIN
mods/cnc/flame.shp
Normal file
BIN
mods/cnc/flame.shp
Normal file
Binary file not shown.
@@ -166,3 +166,7 @@ World:
|
||||
Race: nod
|
||||
SellButton:
|
||||
RepairButton:
|
||||
ResourceLayer:
|
||||
OverlayIndices: 5,6,7,8,9,10,11,12
|
||||
Palette: player
|
||||
SpriteNames: ti1,ti2,ti3,ti4,ti5,ti6,ti7,ti8,ti9,ti10,ti11,ti12
|
||||
|
||||
BIN
mods/cnc/ti1.tem
Normal file
BIN
mods/cnc/ti1.tem
Normal file
Binary file not shown.
BIN
mods/cnc/ti10.tem
Normal file
BIN
mods/cnc/ti10.tem
Normal file
Binary file not shown.
BIN
mods/cnc/ti11.tem
Normal file
BIN
mods/cnc/ti11.tem
Normal file
Binary file not shown.
BIN
mods/cnc/ti12.tem
Normal file
BIN
mods/cnc/ti12.tem
Normal file
Binary file not shown.
BIN
mods/cnc/ti2.tem
Normal file
BIN
mods/cnc/ti2.tem
Normal file
Binary file not shown.
BIN
mods/cnc/ti3.tem
Normal file
BIN
mods/cnc/ti3.tem
Normal file
Binary file not shown.
BIN
mods/cnc/ti4.tem
Normal file
BIN
mods/cnc/ti4.tem
Normal file
Binary file not shown.
BIN
mods/cnc/ti5.tem
Normal file
BIN
mods/cnc/ti5.tem
Normal file
Binary file not shown.
BIN
mods/cnc/ti6.tem
Normal file
BIN
mods/cnc/ti6.tem
Normal file
Binary file not shown.
BIN
mods/cnc/ti7.tem
Normal file
BIN
mods/cnc/ti7.tem
Normal file
Binary file not shown.
BIN
mods/cnc/ti8.tem
Normal file
BIN
mods/cnc/ti8.tem
Normal file
Binary file not shown.
BIN
mods/cnc/ti9.tem
Normal file
BIN
mods/cnc/ti9.tem
Normal file
Binary file not shown.
@@ -216,6 +216,24 @@ World:
|
||||
SellButton:
|
||||
RepairButton:
|
||||
PowerDownButton:
|
||||
WallLoadHook@sbag:
|
||||
ActorType: sbag
|
||||
OverlayIndices: 0,24
|
||||
WallLoadHook@cycl:
|
||||
ActorType: cycl
|
||||
OverlayIndices: 1
|
||||
WallLoadHook@brik:
|
||||
ActorType: brik
|
||||
OverlayIndices: 2
|
||||
WallLoadHook@fenc:
|
||||
ActorType: fenc
|
||||
OverlayIndices: 3
|
||||
WallLoadHook@wood:
|
||||
ActorType: wood
|
||||
OverlayIndices: 4
|
||||
WallLoadHook@barb:
|
||||
ActorType: barb
|
||||
OverlayIndices: 23
|
||||
|
||||
MGG:
|
||||
GeneratesGap:
|
||||
|
||||
Reference in New Issue
Block a user