Reimplement Bibs
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#region Copyright & License Information
|
||||
#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.
|
||||
@@ -32,7 +32,8 @@ namespace OpenRA.GameRules
|
||||
var dim = buildingInfo.Dimensions;
|
||||
|
||||
var footprint = buildingInfo.Footprint.Where(x => !char.IsWhiteSpace(x));
|
||||
if (buildingInfo.Bib)
|
||||
|
||||
if (Rules.Info[ name ].Traits.Contains<BibInfo>())
|
||||
{
|
||||
dim.Y += 1;
|
||||
footprint = footprint.Concat(new char[dim.X]);
|
||||
|
||||
@@ -292,6 +292,7 @@
|
||||
<Compile Include="Effects\CrateEffect.cs" />
|
||||
<Compile Include="Traits\World\GlobalDefaults.cs" />
|
||||
<Compile Include="Traits\RepairsUnits.cs" />
|
||||
<Compile Include="Traits\World\BibLayer.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
@@ -42,7 +42,6 @@ namespace OpenRA.Traits
|
||||
public readonly int Power = 0;
|
||||
public readonly bool BaseNormal = true;
|
||||
public readonly int Adjacent = 2;
|
||||
public readonly bool Bib = false;
|
||||
public readonly bool Capturable = false;
|
||||
public readonly bool Repairable = true;
|
||||
public readonly string Footprint = "x";
|
||||
|
||||
@@ -31,8 +31,6 @@ namespace OpenRA.Traits
|
||||
|
||||
public class RenderBuilding : RenderSimple, INotifyDamage, INotifySold
|
||||
{
|
||||
static readonly int[] bibStarts = { 0, 0, 1, 5, 11 };
|
||||
|
||||
public RenderBuilding( Actor self )
|
||||
: this( self, () => 0 )
|
||||
{
|
||||
@@ -45,8 +43,6 @@ namespace OpenRA.Traits
|
||||
Complete( self );
|
||||
else
|
||||
anim.PlayThen( "make", () => self.World.AddFrameEndTask( _ => Complete( self ) ) );
|
||||
|
||||
DoBib(self, false);
|
||||
}
|
||||
|
||||
void Complete( Actor self )
|
||||
@@ -56,31 +52,6 @@ namespace OpenRA.Traits
|
||||
x.BuildingComplete( self );
|
||||
}
|
||||
|
||||
void DoBib(Actor self, bool isRemove)
|
||||
{
|
||||
/*
|
||||
var buildingInfo = self.Info.Traits.Get<BuildingInfo>();
|
||||
if (buildingInfo.Bib)
|
||||
{
|
||||
var size = buildingInfo.Dimensions.X;
|
||||
var bibOffset = buildingInfo.Dimensions.Y - 1;
|
||||
var startIndex = bibStarts[size];
|
||||
|
||||
for (int i = 0; i < 2 * size; i++)
|
||||
{
|
||||
var p = self.Location + new int2(i % size, i / size + bibOffset);
|
||||
if (isRemove)
|
||||
{
|
||||
if (self.World.Map.MapTiles[p.X, p.Y].smudge == (byte)(i + startIndex))
|
||||
self.World.Map.MapTiles[ p.X, p.Y ].smudge = 0;
|
||||
}
|
||||
else
|
||||
self.World.Map.MapTiles[p.X, p.Y].smudge = (byte)(i + startIndex);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
protected string GetPrefix(Actor self)
|
||||
{
|
||||
return self.GetDamageState() == DamageState.Half ? "damaged-" : "";
|
||||
@@ -119,7 +90,6 @@ namespace OpenRA.Traits
|
||||
Sound.Play(self.Info.Traits.Get<BuildingInfo>().DamagedSound);
|
||||
break;
|
||||
case DamageState.Dead:
|
||||
DoBib(self, true);
|
||||
self.World.AddFrameEndTask(w => w.Add(new Explosion(w, self.CenterLocation.ToInt2(), 7, false)));
|
||||
break;
|
||||
}
|
||||
@@ -134,6 +104,6 @@ namespace OpenRA.Traits
|
||||
Sound.PlayToPlayer(self.Owner, s);
|
||||
}
|
||||
|
||||
public void Sold(Actor self) { DoBib(self, true); }
|
||||
public void Sold(Actor self) {}
|
||||
}
|
||||
}
|
||||
|
||||
108
OpenRA.Game/Traits/World/BibLayer.cs
Normal file
108
OpenRA.Game/Traits/World/BibLayer.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
#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 System.Drawing;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class BibLayerInfo : ITraitInfo
|
||||
{
|
||||
public readonly string[] BibTypes = {"bib3", "bib2", "bib1"};
|
||||
public readonly int[] BibWidths = {2,3,4};
|
||||
public object Create(Actor self) { return new BibLayer(self, this); }
|
||||
}
|
||||
|
||||
class BibLayer: IRenderOverlay, ILoadWorldHook
|
||||
{
|
||||
SpriteRenderer spriteRenderer;
|
||||
World world;
|
||||
BibLayerInfo info;
|
||||
|
||||
TileReference<byte,byte>[,] tiles;
|
||||
Sprite[][] bibSprites;
|
||||
|
||||
public BibLayer(Actor self, BibLayerInfo info)
|
||||
{
|
||||
spriteRenderer = new SpriteRenderer( Game.renderer, true );
|
||||
this.info = info;
|
||||
bibSprites = info.BibTypes.Select(x => SpriteSheetBuilder.LoadAllSprites(x)).ToArray();
|
||||
|
||||
self.World.ActorAdded +=
|
||||
a => { if (a.traits.Contains<Bib>()) DoBib(a,true); };
|
||||
self.World.ActorRemoved +=
|
||||
a => { if (a.traits.Contains<Bib>()) DoBib(a,false); };
|
||||
}
|
||||
|
||||
public void WorldLoaded(World w)
|
||||
{
|
||||
world = w;
|
||||
tiles = new TileReference<byte,byte>[w.Map.MapSize.X,w.Map.MapSize.Y];
|
||||
}
|
||||
|
||||
public void DoBib(Actor b, bool isAdd)
|
||||
{
|
||||
var buildingInfo = b.Info.Traits.Get<BuildingInfo>();
|
||||
var size = buildingInfo.Dimensions.X;
|
||||
var bibOffset = buildingInfo.Dimensions.Y - 1;
|
||||
|
||||
int bib = Array.IndexOf(info.BibWidths,size);
|
||||
if (bib < 0)
|
||||
{
|
||||
Log.Write("Cannot bib {0}-wide building {1}",size,b.Info.Name);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2 * size; i++)
|
||||
{
|
||||
var p = b.Location + new int2(i % size, i / size + bibOffset);
|
||||
byte type = (byte)((isAdd) ? bib+1 : 0);
|
||||
byte index = (byte)i;
|
||||
|
||||
tiles[p.X,p.Y] = new TileReference<byte,byte>(type,index);
|
||||
}
|
||||
}
|
||||
|
||||
public void Render()
|
||||
{
|
||||
var shroud = world.LocalPlayer.Shroud;
|
||||
var tl = world.Map.TopLeft;
|
||||
var br = world.Map.BottomRight;
|
||||
|
||||
for (int x = tl.X; x < br.X; x++)
|
||||
for (int y = tl.Y; y < br.Y; y++)
|
||||
{
|
||||
var t = new int2(x, y);
|
||||
if (!shroud.IsExplored(t) || tiles[x,y].type == 0) continue;
|
||||
|
||||
spriteRenderer.DrawSprite(bibSprites[tiles[x,y].type- 1][tiles[x,y].image],
|
||||
Game.CellSize * (float2)t, "terrain");
|
||||
}
|
||||
|
||||
spriteRenderer.Flush();
|
||||
}
|
||||
}
|
||||
|
||||
class BibInfo : StatelessTraitInfo<Bib> { }
|
||||
public class Bib { }
|
||||
}
|
||||
@@ -152,8 +152,10 @@ namespace OpenRA
|
||||
|
||||
public static bool IsCloseEnoughToBase(this World world, Player p, string buildingName, BuildingInfo bi, int2 topLeft)
|
||||
{
|
||||
|
||||
|
||||
var buildingMaxBounds = bi.Dimensions;
|
||||
if( bi.Bib )
|
||||
if( Rules.Info[ buildingName ].Traits.Contains<BibInfo>() )
|
||||
buildingMaxBounds.Y += 1;
|
||||
|
||||
var scanStart = world.ClampToWorld( topLeft - new int2( bi.Adjacent, bi.Adjacent ) );
|
||||
|
||||
@@ -70,7 +70,6 @@
|
||||
BuildSounds: hvydoor1.aud
|
||||
SellSounds: cashturn.aud
|
||||
Capturable: false
|
||||
Bib: no
|
||||
BaseNormal: no
|
||||
Crewed: no
|
||||
Sight: 0
|
||||
|
||||
@@ -5,11 +5,11 @@ FACT:
|
||||
Footprint: xxx xxx xxx
|
||||
Dimensions: 3,3
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 400
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 3
|
||||
Bib:
|
||||
Production:
|
||||
Produces: Building,Defense
|
||||
ConstructionYard:
|
||||
@@ -30,11 +30,11 @@ NUKE:
|
||||
Footprint: x_ xx
|
||||
Dimensions: 2,2
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 200
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 2
|
||||
Bib:
|
||||
|
||||
PROC:
|
||||
Inherits: ^Building
|
||||
@@ -51,11 +51,11 @@ PROC:
|
||||
Footprint: ___ xxx ===
|
||||
Dimensions: 3,3
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 450
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 4
|
||||
Bib:
|
||||
TiberiumRefinery:
|
||||
StoresOre:
|
||||
Pips: 17
|
||||
@@ -108,11 +108,11 @@ PYLE:
|
||||
Footprint: xx xx
|
||||
Dimensions: 2,2
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 400
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 3
|
||||
Bib:
|
||||
RallyPoint:
|
||||
Production:
|
||||
Produces: Infantry
|
||||
@@ -133,11 +133,11 @@ HAND:
|
||||
Footprint: __ xx xx
|
||||
Dimensions: 2,3
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 400
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 3
|
||||
Bib:
|
||||
RallyPoint:
|
||||
Production:
|
||||
Produces: Infantry
|
||||
@@ -157,11 +157,11 @@ AFLD:
|
||||
Footprint: xxxx xxxx
|
||||
Dimensions: 4,2
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 500
|
||||
Armor: heavy
|
||||
Crewed: yes
|
||||
Sight: 5
|
||||
Bib:
|
||||
RallyPoint:
|
||||
BelowUnits:
|
||||
ProductionAirdrop:
|
||||
@@ -182,11 +182,11 @@ WEAP:
|
||||
Footprint: ___ xxx ===
|
||||
Dimensions: 3,3
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 200
|
||||
Armor: light
|
||||
Crewed: yes
|
||||
Sight: 3
|
||||
Bib:
|
||||
RenderWarFactory:
|
||||
RallyPoint:
|
||||
Production:
|
||||
@@ -209,11 +209,11 @@ HQ:
|
||||
Footprint: __ xx
|
||||
Dimensions: 2,2
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 500
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 10
|
||||
Bib:
|
||||
ProvidesRadar:
|
||||
|
||||
NUK2:
|
||||
@@ -231,11 +231,11 @@ NUK2:
|
||||
Footprint: xx xx
|
||||
Dimensions: 2,2
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 700
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 2
|
||||
Bib:
|
||||
|
||||
FIX:
|
||||
Inherits: ^Building
|
||||
@@ -275,11 +275,11 @@ HPAD:
|
||||
Footprint: xx xx
|
||||
Dimensions: 2,2
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 400
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 3
|
||||
Bib:
|
||||
Production:
|
||||
SpawnOffset: 0,-4
|
||||
Produces: Plane
|
||||
@@ -304,11 +304,11 @@ EYE:
|
||||
Footprint: __ xx
|
||||
Dimensions: 2,2
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 500
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 10
|
||||
Bib:
|
||||
ProvidesRadar:
|
||||
IonControl:
|
||||
|
||||
@@ -330,11 +330,11 @@ TMPL:
|
||||
Footprint: __ xx
|
||||
Dimensions: 2,2
|
||||
Capturable: false
|
||||
Bib: yes
|
||||
HP: 1000
|
||||
Armor: light
|
||||
Crewed: yes
|
||||
Sight: 4
|
||||
Bib:
|
||||
NukeSilo:
|
||||
|
||||
OBLI:
|
||||
|
||||
@@ -189,6 +189,7 @@ World:
|
||||
SellButton:
|
||||
RepairButton:
|
||||
ChoosePaletteOnSelect:
|
||||
BibLayer:
|
||||
ResourceLayer:
|
||||
ResourceType@green-tib:
|
||||
ResourceType: 1
|
||||
|
||||
@@ -5,11 +5,11 @@ FCOM:
|
||||
Footprint: xx xx
|
||||
Dimensions: 2,2
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 400
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 10
|
||||
Bib:
|
||||
|
||||
V01:
|
||||
Inherits: ^Building
|
||||
@@ -387,9 +387,9 @@ MISS:
|
||||
Footprint: xxx xxx
|
||||
Dimensions: 3,2
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 400
|
||||
Armor: wood
|
||||
Bib:
|
||||
|
||||
BR1:
|
||||
Bridge:
|
||||
|
||||
@@ -57,7 +57,6 @@
|
||||
Footprint: x
|
||||
BuildSounds: placbldg.aud
|
||||
Capturable: false
|
||||
Bib: no
|
||||
BaseNormal: no
|
||||
Crewed: no
|
||||
Sight: 0
|
||||
|
||||
@@ -113,7 +113,7 @@ IRON:
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 10
|
||||
Bib: yes
|
||||
Bib:
|
||||
IronCurtainable:
|
||||
IronCurtain:
|
||||
|
||||
@@ -137,7 +137,7 @@ PDOX:
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 10
|
||||
Bib: yes
|
||||
Bib:
|
||||
Chronosphere:
|
||||
IronCurtainable:
|
||||
|
||||
@@ -217,11 +217,11 @@ DOME:
|
||||
Footprint: xx xx
|
||||
Dimensions: 2,2
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 1000
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 10
|
||||
Bib:
|
||||
ProvidesRadar:
|
||||
IronCurtainable:
|
||||
|
||||
@@ -358,11 +358,11 @@ ATEK:
|
||||
Footprint: xx xx
|
||||
Dimensions: 2,2
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 400
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 10
|
||||
Bib:
|
||||
IronCurtainable:
|
||||
GpsLaunchSite:
|
||||
|
||||
@@ -381,11 +381,11 @@ WEAP:
|
||||
Footprint: xxx xxx
|
||||
Dimensions: 3,2
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 1000
|
||||
Armor: light
|
||||
Crewed: yes
|
||||
Sight: 4
|
||||
Bib:
|
||||
RenderWarFactory:
|
||||
RallyPoint:
|
||||
Production:
|
||||
@@ -399,11 +399,11 @@ FACT:
|
||||
Footprint: xxx xxx xxx
|
||||
Dimensions: 3,3
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 1000
|
||||
Armor: heavy
|
||||
Crewed: yes
|
||||
Sight: 5
|
||||
Bib:
|
||||
Production:
|
||||
Produces: Building,Defense
|
||||
ConstructionYard:
|
||||
@@ -426,11 +426,11 @@ PROC:
|
||||
Footprint: _x_ xxx x==
|
||||
Dimensions: 3,3
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 900
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 6
|
||||
Bib:
|
||||
OreRefinery:
|
||||
StoresOre:
|
||||
Pips: 17
|
||||
@@ -480,11 +480,11 @@ HPAD:
|
||||
Footprint: xx xx
|
||||
Dimensions: 2,2
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 800
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 5
|
||||
Bib:
|
||||
Production:
|
||||
SpawnOffset: 0,-4
|
||||
Produces: Plane
|
||||
@@ -530,11 +530,11 @@ POWR:
|
||||
Footprint: xx xx
|
||||
Dimensions: 2,2
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 400
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 4
|
||||
Bib:
|
||||
IronCurtainable:
|
||||
|
||||
APWR:
|
||||
@@ -552,11 +552,11 @@ APWR:
|
||||
Footprint: ___ xxx xxx
|
||||
Dimensions: 3,3
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 700
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 4
|
||||
Bib:
|
||||
IronCurtainable:
|
||||
|
||||
STEK:
|
||||
@@ -574,11 +574,11 @@ STEK:
|
||||
Footprint: xxx xxx
|
||||
Dimensions: 3,2
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 600
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 4
|
||||
Bib:
|
||||
IronCurtainable:
|
||||
|
||||
BARR:
|
||||
@@ -596,11 +596,11 @@ BARR:
|
||||
Footprint: xx xx
|
||||
Dimensions: 2,2
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 800
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 5
|
||||
Bib:
|
||||
RallyPoint:
|
||||
Production:
|
||||
Produces: Infantry
|
||||
@@ -621,11 +621,11 @@ TENT:
|
||||
Footprint: xx xx
|
||||
Dimensions: 2,2
|
||||
Capturable: true
|
||||
Bib: yes
|
||||
HP: 800
|
||||
Armor: wood
|
||||
Crewed: yes
|
||||
Sight: 5
|
||||
Bib:
|
||||
RallyPoint:
|
||||
Production:
|
||||
Produces: Infantry
|
||||
@@ -687,9 +687,9 @@ FACF:
|
||||
Dimensions: 3,3
|
||||
Capturable: true
|
||||
BaseNormal: no
|
||||
Bib: yes
|
||||
HP: 30
|
||||
Sight: 4
|
||||
Bib:
|
||||
RenderBuilding:
|
||||
Image: FACT
|
||||
Fake:
|
||||
@@ -711,9 +711,9 @@ WEAF:
|
||||
Dimensions: 3,2
|
||||
Capturable: true
|
||||
BaseNormal: no
|
||||
Bib: yes
|
||||
HP: 30
|
||||
Sight: 4
|
||||
Bib:
|
||||
RenderWarFactory:
|
||||
RenderBuilding:
|
||||
Image: WEAP
|
||||
@@ -776,9 +776,9 @@ DOMF:
|
||||
Dimensions: 2,2
|
||||
Capturable: true
|
||||
BaseNormal: no
|
||||
Bib: yes
|
||||
HP: 30
|
||||
Sight: 4
|
||||
Bib:
|
||||
RenderBuilding:
|
||||
Image: DOME
|
||||
Fake:
|
||||
|
||||
@@ -212,6 +212,7 @@ World:
|
||||
SellButton:
|
||||
RepairButton:
|
||||
PowerDownButton:
|
||||
BibLayer:
|
||||
ResourceLayer:
|
||||
ResourceType@ore:
|
||||
ResourceType: 1
|
||||
|
||||
Reference in New Issue
Block a user