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