Rename ResourceType trait fields for consistency.
This commit is contained in:
@@ -17,11 +17,12 @@ namespace OpenRA.Traits
|
|||||||
public class ResourceTypeInfo : ITraitInfo
|
public class ResourceTypeInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
[Desc("Sequence image that holds the different variants.")]
|
[Desc("Sequence image that holds the different variants.")]
|
||||||
public readonly string Sequence = "resources";
|
public readonly string Image = "resources";
|
||||||
|
|
||||||
[SequenceReference("Sequence")]
|
[FieldLoader.Require]
|
||||||
|
[SequenceReference("Image")]
|
||||||
[Desc("Randomly chosen image sequences.")]
|
[Desc("Randomly chosen image sequences.")]
|
||||||
public readonly string[] Variants = { };
|
public readonly string[] Sequences = { };
|
||||||
|
|
||||||
[PaletteReference]
|
[PaletteReference]
|
||||||
[Desc("Palette used for rendering the resource sprites.")]
|
[Desc("Palette used for rendering the resource sprites.")]
|
||||||
@@ -38,10 +39,15 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
[FieldLoader.Require]
|
[FieldLoader.Require]
|
||||||
[Desc("Resource identifier used by other traits.")]
|
[Desc("Resource identifier used by other traits.")]
|
||||||
|
public readonly string Type = null;
|
||||||
|
|
||||||
|
[FieldLoader.Require]
|
||||||
|
[Desc("Resource name used by tooltips.")]
|
||||||
public readonly string Name = null;
|
public readonly string Name = null;
|
||||||
|
|
||||||
|
[FieldLoader.Require]
|
||||||
[Desc("Terrain type used to determine unit movement and minimap colors.")]
|
[Desc("Terrain type used to determine unit movement and minimap colors.")]
|
||||||
public readonly string TerrainType = "Ore";
|
public readonly string TerrainType = null;
|
||||||
|
|
||||||
[Desc("Terrain types that this resource can spawn on.")]
|
[Desc("Terrain types that this resource can spawn on.")]
|
||||||
public readonly HashSet<string> AllowedTerrainTypes = new HashSet<string>();
|
public readonly HashSet<string> AllowedTerrainTypes = new HashSet<string>();
|
||||||
@@ -71,9 +77,9 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
Info = info;
|
Info = info;
|
||||||
Variants = new Dictionary<string, Sprite[]>();
|
Variants = new Dictionary<string, Sprite[]>();
|
||||||
foreach (var v in info.Variants)
|
foreach (var v in info.Sequences)
|
||||||
{
|
{
|
||||||
var seq = world.Map.Rules.Sequences.GetSequence(Info.Sequence, v);
|
var seq = world.Map.Rules.Sequences.GetSequence(Info.Image, v);
|
||||||
var sprites = Exts.MakeArray(seq.Length, x => seq.GetSprite(x));
|
var sprites = Exts.MakeArray(seq.Length, x => seq.GetSprite(x));
|
||||||
Variants.Add(v, sprites);
|
Variants.Add(v, sprites);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ namespace OpenRA.Mods.Common
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Can the harvester collect this kind of resource?
|
// Can the harvester collect this kind of resource?
|
||||||
if (!harvInfo.Resources.Contains(resType.Info.Name))
|
if (!harvInfo.Resources.Contains(resType.Info.Type))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (territory != null)
|
if (territory != null)
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
if (underCursor != null)
|
if (underCursor != null)
|
||||||
editorWidget.SetTooltip(underCursor.Tooltip);
|
editorWidget.SetTooltip(underCursor.Tooltip);
|
||||||
else if (mapResources.Contains(cell) && resources.TryGetValue(mapResources[cell].Type, out type))
|
else if (mapResources.Contains(cell) && resources.TryGetValue(mapResources[cell].Type, out type))
|
||||||
editorWidget.SetTooltip(type.Info.Name);
|
editorWidget.SetTooltip(type.Info.Type);
|
||||||
else
|
else
|
||||||
editorWidget.SetTooltip(null);
|
editorWidget.SetTooltip(null);
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
preview.GetScale = () => worldRenderer.Viewport.Zoom;
|
preview.GetScale = () => worldRenderer.Viewport.Zoom;
|
||||||
preview.IsVisible = () => editorWidget.CurrentBrush == this;
|
preview.IsVisible = () => editorWidget.CurrentBrush == this;
|
||||||
|
|
||||||
var variant = resource.Variants.FirstOrDefault();
|
var variant = resource.Sequences.FirstOrDefault();
|
||||||
var sequence = wr.World.Map.Rules.Sequences.GetSequence("resources", variant);
|
var sequence = wr.World.Map.Rules.Sequences.GetSequence("resources", variant);
|
||||||
var sprite = sequence.GetSprite(resource.MaxDensity - 1);
|
var sprite = sequence.GetSprite(resource.MaxDensity - 1);
|
||||||
preview.GetSprite = () => sprite;
|
preview.GetSprite = () => sprite;
|
||||||
|
|||||||
@@ -478,7 +478,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
var res = self.World.WorldActor.Trait<ResourceLayer>().GetRenderedResource(location);
|
var res = self.World.WorldActor.Trait<ResourceLayer>().GetRenderedResource(location);
|
||||||
var info = self.Info.TraitInfo<HarvesterInfo>();
|
var info = self.Info.TraitInfo<HarvesterInfo>();
|
||||||
|
|
||||||
if (res == null || !info.Resources.Contains(res.Info.Name))
|
if (res == null || !info.Resources.Contains(res.Info.Type))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
cursor = "harvest";
|
cursor = "harvest";
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
this.info = info;
|
this.info = info;
|
||||||
|
|
||||||
resourceType = self.World.WorldActor.TraitsImplementing<ResourceType>()
|
resourceType = self.World.WorldActor.TraitsImplementing<ResourceType>()
|
||||||
.FirstOrDefault(t => t.Info.Name == info.ResourceType);
|
.FirstOrDefault(t => t.Info.Type == info.ResourceType);
|
||||||
|
|
||||||
if (resourceType == null)
|
if (resourceType == null)
|
||||||
throw new InvalidOperationException("No such resource type `{0}`".F(info.ResourceType));
|
throw new InvalidOperationException("No such resource type `{0}`".F(info.ResourceType));
|
||||||
|
|||||||
@@ -367,6 +367,25 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
Console.WriteLine("Actor type `{0}` is denoted as a RearmBuilding. Consider adding the `WithRearmAnimation` trait to it.".F(host));
|
Console.WriteLine("Actor type `{0}` is denoted as a RearmBuilding. Consider adding the `WithRearmAnimation` trait to it.".F(host));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resource type properties were renamed, and support for tooltips added
|
||||||
|
if (engineVersion < 20160925)
|
||||||
|
{
|
||||||
|
if (node.Key.StartsWith("ResourceType"))
|
||||||
|
{
|
||||||
|
var image = node.Value.Nodes.FirstOrDefault(n => n.Key == "Sequence");
|
||||||
|
if (image != null)
|
||||||
|
image.Key = "Image";
|
||||||
|
|
||||||
|
var sequences = node.Value.Nodes.FirstOrDefault(n => n.Key == "Variants");
|
||||||
|
if (sequences != null)
|
||||||
|
sequences.Key = "Sequences";
|
||||||
|
|
||||||
|
var name = node.Value.Nodes.FirstOrDefault(n => n.Key == "Name");
|
||||||
|
if (name != null)
|
||||||
|
node.Value.Nodes.Add(new MiniYamlNode("Type", name.Value.Value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Warheads
|
|||||||
var allCells = world.Map.FindTilesInAnnulus(targetTile, minRange, Size[0]);
|
var allCells = world.Map.FindTilesInAnnulus(targetTile, minRange, Size[0]);
|
||||||
|
|
||||||
var resourceType = world.WorldActor.TraitsImplementing<ResourceType>()
|
var resourceType = world.WorldActor.TraitsImplementing<ResourceType>()
|
||||||
.FirstOrDefault(t => t.Info.Name == AddsResourceType);
|
.FirstOrDefault(t => t.Info.Type == AddsResourceType);
|
||||||
|
|
||||||
if (resourceType == null)
|
if (resourceType == null)
|
||||||
Log.Write("debug", "Warhead defines an invalid resource type '{0}'".F(AddsResourceType));
|
Log.Write("debug", "Warhead defines an invalid resource type '{0}'".F(AddsResourceType));
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
layerPreview.IsVisible = () => true;
|
layerPreview.IsVisible = () => true;
|
||||||
layerPreview.GetPalette = () => resource.Palette;
|
layerPreview.GetPalette = () => resource.Palette;
|
||||||
|
|
||||||
var variant = resource.Variants.FirstOrDefault();
|
var variant = resource.Sequences.FirstOrDefault();
|
||||||
var sequence = rules.Sequences.GetSequence("resources", variant);
|
var sequence = rules.Sequences.GetSequence("resources", variant);
|
||||||
var frame = sequence.Frames != null ? sequence.Frames.Last() : resource.MaxDensity - 1;
|
var frame = sequence.Frames != null ? sequence.Frames.Last() : resource.MaxDensity - 1;
|
||||||
layerPreview.GetSprite = () => sequence.GetSprite(frame);
|
layerPreview.GetSprite = () => sequence.GetSprite(frame);
|
||||||
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
newResourcePreviewTemplate.Bounds.Height = tileSize.Height + (layerPreview.Bounds.Y * 2);
|
newResourcePreviewTemplate.Bounds.Height = tileSize.Height + (layerPreview.Bounds.Y * 2);
|
||||||
|
|
||||||
newResourcePreviewTemplate.IsVisible = () => true;
|
newResourcePreviewTemplate.IsVisible = () => true;
|
||||||
newResourcePreviewTemplate.GetTooltipText = () => resource.Name;
|
newResourcePreviewTemplate.GetTooltipText = () => resource.Type;
|
||||||
|
|
||||||
layerTemplateList.AddChild(newResourcePreviewTemplate);
|
layerTemplateList.AddChild(newResourcePreviewTemplate);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.D2k.Traits
|
|||||||
self = init.Self;
|
self = init.Self;
|
||||||
|
|
||||||
resLayer = self.World.WorldActor.Trait<ResourceLayer>();
|
resLayer = self.World.WorldActor.Trait<ResourceLayer>();
|
||||||
resType = self.World.WorldActor.TraitsImplementing<ResourceType>().First(t => t.Info.Name == info.ResourceType);
|
resType = self.World.WorldActor.TraitsImplementing<ResourceType>().First(t => t.Info.Type == info.ResourceType);
|
||||||
|
|
||||||
var render = self.Trait<RenderSprites>();
|
var render = self.Trait<RenderSprites>();
|
||||||
anim = new AnimationWithOffset(new Animation(init.Self.World, render.GetImage(self)), null, () => self.IsDead);
|
anim = new AnimationWithOffset(new Animation(init.Self.World, render.GetImage(self)), null, () => self.IsDead);
|
||||||
|
|||||||
@@ -26,25 +26,27 @@
|
|||||||
InternalName: nod
|
InternalName: nod
|
||||||
Description: Brotherhood of Nod\nThe Brotherhood is a religious cult centered around their leader Kane\nand the alien substance Tiberium. They utilize stealth technology\nand guerilla tactics to defeat those who oppose them.
|
Description: Brotherhood of Nod\nThe Brotherhood is a religious cult centered around their leader Kane\nand the alien substance Tiberium. They utilize stealth technology\nand guerilla tactics to defeat those who oppose them.
|
||||||
ResourceType@green-tib:
|
ResourceType@green-tib:
|
||||||
|
Type: Tiberium
|
||||||
|
Name: Tiberium
|
||||||
|
PipColor: Green
|
||||||
ResourceType: 1
|
ResourceType: 1
|
||||||
Palette: staticterrain
|
Palette: staticterrain
|
||||||
TerrainType: Tiberium
|
TerrainType: Tiberium
|
||||||
Variants: ti1,ti2,ti3,ti4,ti5,ti6,ti7,ti8,ti9,ti10,ti11,ti12
|
Sequences: ti1,ti2,ti3,ti4,ti5,ti6,ti7,ti8,ti9,ti10,ti11,ti12
|
||||||
MaxDensity: 12
|
MaxDensity: 12
|
||||||
ValuePerUnit: 35
|
ValuePerUnit: 35
|
||||||
Name: Tiberium
|
|
||||||
PipColor: Green
|
|
||||||
AllowedTerrainTypes: Clear,Road
|
AllowedTerrainTypes: Clear,Road
|
||||||
AllowUnderActors: true
|
AllowUnderActors: true
|
||||||
ResourceType@blue-tib:
|
ResourceType@blue-tib:
|
||||||
|
Type: BlueTiberium
|
||||||
|
Name: Tiberium
|
||||||
|
PipColor: Blue
|
||||||
ResourceType: 2
|
ResourceType: 2
|
||||||
Palette: bluetiberium
|
Palette: bluetiberium
|
||||||
TerrainType: BlueTiberium
|
TerrainType: BlueTiberium
|
||||||
Variants: bti1,bti2,bti3,bti4,bti5,bti6,bti7,bti8,bti9,bti10,bti11,bti12
|
Sequences: bti1,bti2,bti3,bti4,bti5,bti6,bti7,bti8,bti9,bti10,bti11,bti12
|
||||||
MaxDensity: 12
|
MaxDensity: 12
|
||||||
ValuePerUnit: 60
|
ValuePerUnit: 60
|
||||||
Name: BlueTiberium
|
|
||||||
PipColor: Blue
|
|
||||||
AllowedTerrainTypes: Clear,Road
|
AllowedTerrainTypes: Clear,Road
|
||||||
AllowUnderActors: true
|
AllowUnderActors: true
|
||||||
|
|
||||||
|
|||||||
@@ -44,14 +44,15 @@
|
|||||||
InternalName: smuggler
|
InternalName: smuggler
|
||||||
Selectable: false
|
Selectable: false
|
||||||
ResourceType@Spice:
|
ResourceType@Spice:
|
||||||
|
Type: Spice
|
||||||
|
Name: Spice
|
||||||
|
PipColor: green
|
||||||
ResourceType: 1
|
ResourceType: 1
|
||||||
Palette: d2k
|
Palette: d2k
|
||||||
TerrainType: Spice
|
TerrainType: Spice
|
||||||
Variants: spice
|
Sequences: spice
|
||||||
MaxDensity: 20
|
MaxDensity: 20
|
||||||
ValuePerUnit: 25
|
ValuePerUnit: 25
|
||||||
Name: Spice
|
|
||||||
PipColor: green
|
|
||||||
AllowedTerrainTypes: SpiceSand
|
AllowedTerrainTypes: SpiceSand
|
||||||
AllowUnderActors: true
|
AllowUnderActors: true
|
||||||
|
|
||||||
|
|||||||
@@ -65,27 +65,29 @@
|
|||||||
Side: Random
|
Side: Random
|
||||||
Description: A random Soviet country.
|
Description: A random Soviet country.
|
||||||
ResourceType@ore:
|
ResourceType@ore:
|
||||||
|
Type: Ore
|
||||||
|
Name: Valuable Minerals
|
||||||
|
PipColor: Yellow
|
||||||
ResourceType: 1
|
ResourceType: 1
|
||||||
|
TerrainType: Ore
|
||||||
Palette: player
|
Palette: player
|
||||||
Variants: gold01,gold02,gold03,gold04
|
Sequences: gold01,gold02,gold03,gold04
|
||||||
MaxDensity: 12
|
MaxDensity: 12
|
||||||
ValuePerUnit: 25
|
ValuePerUnit: 25
|
||||||
Name: Ore
|
|
||||||
PipColor: Yellow
|
|
||||||
AllowedTerrainTypes: Clear,Road
|
AllowedTerrainTypes: Clear,Road
|
||||||
AllowUnderActors: true
|
AllowUnderActors: true
|
||||||
TerrainType: Ore
|
|
||||||
ResourceType@gem:
|
ResourceType@gem:
|
||||||
|
Type: Gems
|
||||||
|
Name: Valuable Minerals
|
||||||
|
PipColor: Red
|
||||||
ResourceType: 2
|
ResourceType: 2
|
||||||
|
TerrainType: Gems
|
||||||
Palette: player
|
Palette: player
|
||||||
Variants: gem01,gem02,gem03,gem04
|
Sequences: gem01,gem02,gem03,gem04
|
||||||
MaxDensity: 3
|
MaxDensity: 3
|
||||||
ValuePerUnit: 50
|
ValuePerUnit: 50
|
||||||
Name: Gems
|
|
||||||
PipColor: Red
|
|
||||||
AllowedTerrainTypes: Clear,Road
|
AllowedTerrainTypes: Clear,Road
|
||||||
AllowUnderActors: true
|
AllowUnderActors: true
|
||||||
TerrainType: Gems
|
|
||||||
|
|
||||||
World:
|
World:
|
||||||
Inherits: ^BaseWorld
|
Inherits: ^BaseWorld
|
||||||
|
|||||||
@@ -22,35 +22,38 @@
|
|||||||
Name: Nod
|
Name: Nod
|
||||||
InternalName: nod
|
InternalName: nod
|
||||||
ResourceType@Tiberium:
|
ResourceType@Tiberium:
|
||||||
ResourceType: 1
|
Type: Tiberium
|
||||||
Palette: greentiberium
|
|
||||||
Variants: tib01, tib02, tib03, tib04, tib05, tib06, tib07, tib08, tib09, tib10, tib11, tib12
|
|
||||||
MaxDensity: 12
|
|
||||||
ValuePerUnit: 50
|
|
||||||
Name: Tiberium
|
Name: Tiberium
|
||||||
PipColor: Green
|
PipColor: Green
|
||||||
|
ResourceType: 1
|
||||||
|
Palette: greentiberium
|
||||||
|
Sequences: tib01, tib02, tib03, tib04, tib05, tib06, tib07, tib08, tib09, tib10, tib11, tib12
|
||||||
|
MaxDensity: 12
|
||||||
|
ValuePerUnit: 50
|
||||||
AllowedTerrainTypes: Clear, Rough, DirtRoad
|
AllowedTerrainTypes: Clear, Rough, DirtRoad
|
||||||
AllowUnderActors: true
|
AllowUnderActors: true
|
||||||
TerrainType: Tiberium
|
TerrainType: Tiberium
|
||||||
ResourceType@BlueTiberium:
|
ResourceType@BlueTiberium:
|
||||||
|
Type: BlueTiberium
|
||||||
|
Name: Tiberium
|
||||||
|
PipColor: Blue
|
||||||
ResourceType: 2
|
ResourceType: 2
|
||||||
Palette: bluetiberium
|
Palette: bluetiberium
|
||||||
Variants: tib01, tib02, tib03, tib04, tib05, tib06, tib07, tib08, tib09, tib10, tib11, tib12
|
Sequences: tib01, tib02, tib03, tib04, tib05, tib06, tib07, tib08, tib09, tib10, tib11, tib12
|
||||||
MaxDensity: 12
|
MaxDensity: 12
|
||||||
ValuePerUnit: 100
|
ValuePerUnit: 100
|
||||||
Name: BlueTiberium
|
|
||||||
PipColor: Blue
|
|
||||||
AllowedTerrainTypes: Clear, Rough, DirtRoad
|
AllowedTerrainTypes: Clear, Rough, DirtRoad
|
||||||
AllowUnderActors: true
|
AllowUnderActors: true
|
||||||
TerrainType: BlueTiberium
|
TerrainType: BlueTiberium
|
||||||
ResourceType@Veins:
|
ResourceType@Veins:
|
||||||
ResourceType: 3
|
Type: Veins
|
||||||
Palette: player
|
|
||||||
Variants: veins
|
|
||||||
MaxDensity: 1
|
|
||||||
ValuePerUnit: 0
|
|
||||||
Name: Veins
|
Name: Veins
|
||||||
PipColor: Red
|
PipColor: Red
|
||||||
|
ResourceType: 3
|
||||||
|
Palette: player
|
||||||
|
Sequences: veins
|
||||||
|
MaxDensity: 1
|
||||||
|
ValuePerUnit: 0
|
||||||
AllowedTerrainTypes: Clear
|
AllowedTerrainTypes: Clear
|
||||||
AllowUnderActors: true
|
AllowUnderActors: true
|
||||||
TerrainType: Veins
|
TerrainType: Veins
|
||||||
|
|||||||
Reference in New Issue
Block a user