Add bridges to cnc
This commit is contained in:
@@ -42,8 +42,6 @@ namespace OpenRA.Mods.RA
|
||||
public readonly ushort DestroyedPlusSouthTemplate;
|
||||
public readonly ushort DestroyedPlusBothTemplate;
|
||||
public readonly string[] ShorePieces = {"br1", "br2"};
|
||||
|
||||
public readonly bool UseAlternateNames = false;
|
||||
public readonly int[] NorthOffset = null;
|
||||
public readonly int[] SouthOffset = null;
|
||||
|
||||
@@ -82,25 +80,24 @@ namespace OpenRA.Mods.RA
|
||||
ushort currentTemplate;
|
||||
|
||||
Actor self;
|
||||
BridgeInfo info;
|
||||
Bridge northNeighbour, southNeighbour;
|
||||
|
||||
BridgeInfo Info;
|
||||
public string Type;
|
||||
|
||||
Bridge northNeighbour, southNeighbour;
|
||||
|
||||
public Bridge(Actor self, BridgeInfo info)
|
||||
{
|
||||
this.self = self;
|
||||
self.RemoveOnDeath = false;
|
||||
this.info = info;
|
||||
this.Info = info;
|
||||
this.Type = self.Info.Name;
|
||||
}
|
||||
|
||||
public void Create(ushort template, Dictionary<int2, byte> subtiles)
|
||||
{
|
||||
currentTemplate = template;
|
||||
if (template == info.DamagedTemplate)
|
||||
if (template == Info.DamagedTemplate)
|
||||
self.Health = (int)(self.World.Defaults.ConditionYellow*self.GetMaxHP());
|
||||
else if (template != info.Template)
|
||||
else if (template != Info.Template)
|
||||
self.Health = 0;
|
||||
|
||||
// Create a new cache to store the tile data
|
||||
@@ -113,7 +110,7 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
|
||||
// Cache templates and tiles for the different states
|
||||
foreach (var t in info.Templates)
|
||||
foreach (var t in Info.Templates)
|
||||
{
|
||||
Templates.Add(t,self.World.TileSet.Templates[t]);
|
||||
TileSprites.Add(t,subtiles.ToDictionary(
|
||||
@@ -132,11 +129,10 @@ namespace OpenRA.Mods.RA
|
||||
public void LinkNeighbouringBridges(World world, BridgeLayer bridges)
|
||||
{
|
||||
// go looking for our neighbors if this is a long bridge.
|
||||
var info = self.Info.Traits.Get<BridgeInfo>();
|
||||
if (info.NorthOffset != null)
|
||||
northNeighbour = GetNeighbor(info.NorthOffset, bridges);
|
||||
if (info.SouthOffset != null)
|
||||
southNeighbour = GetNeighbor(info.SouthOffset, bridges);
|
||||
if (Info.NorthOffset != null)
|
||||
northNeighbour = GetNeighbor(Info.NorthOffset, bridges);
|
||||
if (Info.SouthOffset != null)
|
||||
southNeighbour = GetNeighbor(Info.SouthOffset, bridges);
|
||||
}
|
||||
|
||||
public Bridge GetNeighbor(int[] offset, BridgeLayer bridges)
|
||||
@@ -156,28 +152,23 @@ namespace OpenRA.Mods.RA
|
||||
return b != null && b.self.IsInWorld && b.self.Health > 0;
|
||||
}
|
||||
|
||||
static bool IsLong(Bridge b)
|
||||
{
|
||||
return b != null && b.self.IsInWorld && b.self.Info.Traits.Get<BridgeInfo>().Long;
|
||||
}
|
||||
|
||||
void UpdateState()
|
||||
{
|
||||
var ds = self.GetDamageState();
|
||||
|
||||
// If this is a long bridge next to a destroyed shore piece, we need die to give clean edges to the break
|
||||
if (info.Long && ds != DamageState.Dead &&
|
||||
((southNeighbour != null && info.ShorePieces.Contains(southNeighbour.Type) && !IsIntact(southNeighbour)) ||
|
||||
(northNeighbour != null && info.ShorePieces.Contains(northNeighbour.Type) && !IsIntact(northNeighbour))))
|
||||
if (Info.Long && ds != DamageState.Dead &&
|
||||
((southNeighbour != null && Info.ShorePieces.Contains(southNeighbour.Type) && !IsIntact(southNeighbour)) ||
|
||||
(northNeighbour != null && Info.ShorePieces.Contains(northNeighbour.Type) && !IsIntact(northNeighbour))))
|
||||
{
|
||||
self.Health = 0;
|
||||
ds = DamageState.Dead;
|
||||
}
|
||||
|
||||
currentTemplate = (ds == DamageState.Half && info.DamagedTemplate > 0) ? info.DamagedTemplate :
|
||||
(ds == DamageState.Dead && info.DestroyedTemplate > 0) ? info.DestroyedTemplate : info.Template;
|
||||
currentTemplate = (ds == DamageState.Half && Info.DamagedTemplate > 0) ? Info.DamagedTemplate :
|
||||
(ds == DamageState.Dead && Info.DestroyedTemplate > 0) ? Info.DestroyedTemplate : Info.Template;
|
||||
|
||||
if (!(info.Long && ds == DamageState.Dead))
|
||||
if (!(Info.Long && ds == DamageState.Dead))
|
||||
return;
|
||||
|
||||
// Long bridges have custom art for multiple segments being destroyed
|
||||
@@ -185,11 +176,11 @@ namespace OpenRA.Mods.RA
|
||||
bool waterToNorth = !IsIntact(northNeighbour);
|
||||
|
||||
if (waterToSouth && waterToNorth)
|
||||
currentTemplate = info.DestroyedPlusBothTemplate;
|
||||
currentTemplate = Info.DestroyedPlusBothTemplate;
|
||||
else if (waterToNorth)
|
||||
currentTemplate = info.DestroyedPlusNorthTemplate;
|
||||
currentTemplate = Info.DestroyedPlusNorthTemplate;
|
||||
else if (waterToSouth)
|
||||
currentTemplate = info.DestroyedPlusSouthTemplate;
|
||||
currentTemplate = Info.DestroyedPlusSouthTemplate;
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
|
||||
@@ -33,23 +33,20 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
class BridgeLayer : ILoadWorldHook, ITerrainTypeModifier
|
||||
{
|
||||
// for tricky things like bridges.
|
||||
Bridge[,] Bridges;
|
||||
|
||||
readonly BridgeLayerInfo Info;
|
||||
readonly World world;
|
||||
Dictionary<ushort, string> BridgeTypes = new Dictionary<ushort, string>();
|
||||
Bridge[,] Bridges;
|
||||
|
||||
public BridgeLayer(Actor self, BridgeLayerInfo Info)
|
||||
{
|
||||
this.Info = Info;
|
||||
this.world = self.World;
|
||||
}
|
||||
|
||||
static Dictionary<ushort, string> BridgeTypes;
|
||||
|
||||
public void WorldLoaded(World w)
|
||||
{
|
||||
Bridges = new Bridge[w.Map.MapSize.X, w.Map.MapSize.Y];
|
||||
BridgeTypes = new Dictionary<ushort, string>();
|
||||
|
||||
// Build a list of templates that should be overlayed with bridges
|
||||
foreach(var bridge in Info.Bridges)
|
||||
|
||||
@@ -140,44 +140,44 @@ V18:
|
||||
Armor: wood
|
||||
|
||||
BRIDGE1:
|
||||
Inherits: ^Bridge
|
||||
Bridge:
|
||||
UseAlternateNames: yes
|
||||
Category: Building
|
||||
Selectable:
|
||||
BelowUnits:
|
||||
Template: 165
|
||||
DestroyedTemplate: 166
|
||||
Building:
|
||||
Footprint: _____ _____ _____
|
||||
Dimensions: 5,3
|
||||
HP: 1000
|
||||
Footprint: ____ ____ ____ ____
|
||||
Dimensions: 4,4
|
||||
Selectable:
|
||||
Bounds: 96,96
|
||||
|
||||
BRIDGE2:
|
||||
Inherits: ^Bridge
|
||||
Bridge:
|
||||
UseAlternateNames: yes
|
||||
Category: Building
|
||||
Selectable:
|
||||
BelowUnits:
|
||||
Template: 167
|
||||
DestroyedTemplate: 168
|
||||
Building:
|
||||
Footprint: _____ _____
|
||||
Dimensions: 5,2
|
||||
HP: 1000
|
||||
Footprint: _____ _____ _____ _____ _____
|
||||
Dimensions: 5,5
|
||||
Selectable:
|
||||
Bounds: 120,120
|
||||
BRIDGE3:
|
||||
Inherits: ^Bridge
|
||||
Bridge:
|
||||
UseAlternateNames: yes
|
||||
Category: Building
|
||||
Selectable:
|
||||
BelowUnits:
|
||||
Template: 169
|
||||
DestroyedTemplate: 170
|
||||
Building:
|
||||
Footprint: _____ _____ _____
|
||||
Dimensions: 5,3
|
||||
HP: 1000
|
||||
Footprint: ______ ______ ______ ______ ______
|
||||
Dimensions: 6,5
|
||||
Selectable:
|
||||
Bounds: 144,120
|
||||
|
||||
BRIDGE4:
|
||||
Inherits: ^Bridge
|
||||
Bridge:
|
||||
UseAlternateNames: yes
|
||||
Category: Building
|
||||
Selectable:
|
||||
BelowUnits:
|
||||
Template: 171
|
||||
DestroyedTemplate: 172
|
||||
Building:
|
||||
Footprint: _____ _____
|
||||
Dimensions: 5,2
|
||||
HP: 1000
|
||||
Footprint: ______ ______ ______ ______
|
||||
Dimensions: 6,4
|
||||
Selectable:
|
||||
Bounds: 144,96
|
||||
@@ -1,34 +0,0 @@
|
||||
BR1:
|
||||
Bridge:
|
||||
SouthOffset: 0,2
|
||||
Category: Building
|
||||
Selectable:
|
||||
BelowUnits:
|
||||
Building:
|
||||
Footprint: ____ ____
|
||||
Dimensions: 4,2
|
||||
HP: 1000
|
||||
|
||||
BR2:
|
||||
Bridge:
|
||||
NorthOffset: 3,0
|
||||
Category: Building
|
||||
Selectable:
|
||||
BelowUnits:
|
||||
Building:
|
||||
Footprint: ____ ____
|
||||
Dimensions: 4,2
|
||||
HP: 1000
|
||||
|
||||
BR3:
|
||||
Bridge:
|
||||
Long: yes
|
||||
NorthOffset: 2,0
|
||||
SouthOffset: 0,1
|
||||
Category: Building
|
||||
Selectable:
|
||||
BelowUnits:
|
||||
Building:
|
||||
Footprint: ____ ____
|
||||
Dimensions: 4,2
|
||||
HP: 1000
|
||||
@@ -143,4 +143,18 @@
|
||||
Priority: -1
|
||||
HiddenUnderFog:
|
||||
RevealsShroud:
|
||||
Burns:
|
||||
Burns:
|
||||
|
||||
^Bridge:
|
||||
Category: Building
|
||||
Valued:
|
||||
Description: Bridge
|
||||
Selectable:
|
||||
Bounds: 96,96
|
||||
BelowUnits:
|
||||
Building:
|
||||
DamagedSound: xplos.aud
|
||||
DestroyedSound: xplobig4.aud
|
||||
Footprint: ______ ______ ______ ______
|
||||
Dimensions: 6,4
|
||||
HP: 1000
|
||||
@@ -24,7 +24,6 @@ Rules:
|
||||
mods/cnc/vehicles.yaml:
|
||||
mods/cnc/trees.yaml:
|
||||
mods/cnc/civilian.yaml: Civilian structures and bridges
|
||||
mods/cnc/compat.yaml: Compatability tweaks for real-ra maps
|
||||
|
||||
Sequences:
|
||||
mods/cnc/sequences-structures.xml:
|
||||
|
||||
@@ -49,7 +49,8 @@ World:
|
||||
UnitInfluence:
|
||||
AircraftInfluence:
|
||||
HazardLayer:
|
||||
# BridgeLoadHook:
|
||||
BridgeLayer:
|
||||
Bridges: bridge1, bridge2, bridge3, bridge4
|
||||
PaletteFromFile@terrain_desert:
|
||||
Name: terrain
|
||||
Theater: desert
|
||||
|
||||
@@ -1218,7 +1218,6 @@ Templates:
|
||||
Id: 169
|
||||
Image: bridge3
|
||||
Size: 6,5
|
||||
Bridge: bridge3
|
||||
Tiles:
|
||||
4: Road
|
||||
7: Rock
|
||||
@@ -1241,7 +1240,6 @@ Templates:
|
||||
Id: 170
|
||||
Image: bridge3d
|
||||
Size: 6,5
|
||||
Bridge: bridge3
|
||||
Tiles:
|
||||
4: Road
|
||||
7: Rock
|
||||
@@ -1264,7 +1262,6 @@ Templates:
|
||||
Id: 171
|
||||
Image: bridge4
|
||||
Size: 6,4
|
||||
Bridge: bridge4
|
||||
Tiles:
|
||||
1: Road
|
||||
3: Tree
|
||||
@@ -1288,7 +1285,6 @@ Templates:
|
||||
Id: 172
|
||||
Image: bridge4d
|
||||
Size: 6,4
|
||||
Bridge: bridge4
|
||||
Tiles:
|
||||
1: Road
|
||||
3: Tree
|
||||
|
||||
@@ -1203,7 +1203,6 @@ Templates:
|
||||
Id: 165
|
||||
Image: bridge1
|
||||
Size: 4,4
|
||||
Bridge: bridge1
|
||||
Tiles:
|
||||
3: Road
|
||||
4: River
|
||||
@@ -1220,7 +1219,6 @@ Templates:
|
||||
Id: 166
|
||||
Image: bridge1d
|
||||
Size: 4,4
|
||||
Bridge: bridge1
|
||||
Tiles:
|
||||
3: Road
|
||||
4: River
|
||||
@@ -1237,7 +1235,6 @@ Templates:
|
||||
Id: 167
|
||||
Image: bridge2
|
||||
Size: 5,5
|
||||
Bridge: bridge2
|
||||
Tiles:
|
||||
0: Road
|
||||
5: Wall
|
||||
@@ -1256,7 +1253,6 @@ Templates:
|
||||
Id: 168
|
||||
Image: bridge2d
|
||||
Size: 5,5
|
||||
Bridge: bridge2
|
||||
Tiles:
|
||||
0: Road
|
||||
5: Wall
|
||||
|
||||
@@ -1184,7 +1184,6 @@ Templates:
|
||||
Id: 165
|
||||
Image: bridge1
|
||||
Size: 4,4
|
||||
Bridge: bridge1
|
||||
Tiles:
|
||||
3: Road
|
||||
4: River
|
||||
@@ -1201,7 +1200,6 @@ Templates:
|
||||
Id: 166
|
||||
Image: bridge1d
|
||||
Size: 4,4
|
||||
Bridge: bridge1
|
||||
Tiles:
|
||||
3: Road
|
||||
4: River
|
||||
@@ -1218,7 +1216,6 @@ Templates:
|
||||
Id: 167
|
||||
Image: bridge2
|
||||
Size: 5,5
|
||||
Bridge: bridge2
|
||||
Tiles:
|
||||
0: Road
|
||||
5: Wall
|
||||
@@ -1237,7 +1234,6 @@ Templates:
|
||||
Id: 168
|
||||
Image: bridge2d
|
||||
Size: 5,5
|
||||
Bridge: bridge2
|
||||
Tiles:
|
||||
0: Road
|
||||
5: Wall
|
||||
|
||||
@@ -427,7 +427,6 @@ BRIDGE1:
|
||||
Template: 131
|
||||
DamagedTemplate: 378
|
||||
DestroyedTemplate: 132
|
||||
UseAlternateNames: yes
|
||||
Building:
|
||||
Footprint: _____ _____ _____
|
||||
Dimensions: 5,3
|
||||
@@ -439,7 +438,6 @@ BRIDGE2:
|
||||
Template: 133
|
||||
DamagedTemplate: 379
|
||||
DestroyedTemplate: 134
|
||||
UseAlternateNames: yes
|
||||
Building:
|
||||
Footprint: _____ _____
|
||||
Dimensions: 5,2
|
||||
|
||||
Reference in New Issue
Block a user