Rename ResourceType trait fields for consistency.
This commit is contained in:
@@ -17,11 +17,12 @@ namespace OpenRA.Traits
|
||||
public class ResourceTypeInfo : ITraitInfo
|
||||
{
|
||||
[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.")]
|
||||
public readonly string[] Variants = { };
|
||||
public readonly string[] Sequences = { };
|
||||
|
||||
[PaletteReference]
|
||||
[Desc("Palette used for rendering the resource sprites.")]
|
||||
@@ -38,10 +39,15 @@ namespace OpenRA.Traits
|
||||
|
||||
[FieldLoader.Require]
|
||||
[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;
|
||||
|
||||
[FieldLoader.Require]
|
||||
[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.")]
|
||||
public readonly HashSet<string> AllowedTerrainTypes = new HashSet<string>();
|
||||
@@ -71,9 +77,9 @@ namespace OpenRA.Traits
|
||||
{
|
||||
Info = info;
|
||||
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));
|
||||
Variants.Add(v, sprites);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace OpenRA.Mods.Common
|
||||
return false;
|
||||
|
||||
// Can the harvester collect this kind of resource?
|
||||
if (!harvInfo.Resources.Contains(resType.Info.Name))
|
||||
if (!harvInfo.Resources.Contains(resType.Info.Type))
|
||||
return false;
|
||||
|
||||
if (territory != null)
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
if (underCursor != null)
|
||||
editorWidget.SetTooltip(underCursor.Tooltip);
|
||||
else if (mapResources.Contains(cell) && resources.TryGetValue(mapResources[cell].Type, out type))
|
||||
editorWidget.SetTooltip(type.Info.Name);
|
||||
editorWidget.SetTooltip(type.Info.Type);
|
||||
else
|
||||
editorWidget.SetTooltip(null);
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
preview.GetScale = () => worldRenderer.Viewport.Zoom;
|
||||
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 sprite = sequence.GetSprite(resource.MaxDensity - 1);
|
||||
preview.GetSprite = () => sprite;
|
||||
|
||||
@@ -478,7 +478,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var res = self.World.WorldActor.Trait<ResourceLayer>().GetRenderedResource(location);
|
||||
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;
|
||||
|
||||
cursor = "harvest";
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
this.info = info;
|
||||
|
||||
resourceType = self.World.WorldActor.TraitsImplementing<ResourceType>()
|
||||
.FirstOrDefault(t => t.Info.Name == info.ResourceType);
|
||||
.FirstOrDefault(t => t.Info.Type == info.ResourceType);
|
||||
|
||||
if (resourceType == null)
|
||||
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));
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Warheads
|
||||
var allCells = world.Map.FindTilesInAnnulus(targetTile, minRange, Size[0]);
|
||||
|
||||
var resourceType = world.WorldActor.TraitsImplementing<ResourceType>()
|
||||
.FirstOrDefault(t => t.Info.Name == AddsResourceType);
|
||||
.FirstOrDefault(t => t.Info.Type == AddsResourceType);
|
||||
|
||||
if (resourceType == null)
|
||||
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.GetPalette = () => resource.Palette;
|
||||
|
||||
var variant = resource.Variants.FirstOrDefault();
|
||||
var variant = resource.Sequences.FirstOrDefault();
|
||||
var sequence = rules.Sequences.GetSequence("resources", variant);
|
||||
var frame = sequence.Frames != null ? sequence.Frames.Last() : resource.MaxDensity - 1;
|
||||
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.IsVisible = () => true;
|
||||
newResourcePreviewTemplate.GetTooltipText = () => resource.Name;
|
||||
newResourcePreviewTemplate.GetTooltipText = () => resource.Type;
|
||||
|
||||
layerTemplateList.AddChild(newResourcePreviewTemplate);
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
self = init.Self;
|
||||
|
||||
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>();
|
||||
anim = new AnimationWithOffset(new Animation(init.Self.World, render.GetImage(self)), null, () => self.IsDead);
|
||||
|
||||
@@ -26,25 +26,27 @@
|
||||
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.
|
||||
ResourceType@green-tib:
|
||||
Type: Tiberium
|
||||
Name: Tiberium
|
||||
PipColor: Green
|
||||
ResourceType: 1
|
||||
Palette: staticterrain
|
||||
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
|
||||
ValuePerUnit: 35
|
||||
Name: Tiberium
|
||||
PipColor: Green
|
||||
AllowedTerrainTypes: Clear,Road
|
||||
AllowUnderActors: true
|
||||
ResourceType@blue-tib:
|
||||
Type: BlueTiberium
|
||||
Name: Tiberium
|
||||
PipColor: Blue
|
||||
ResourceType: 2
|
||||
Palette: 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
|
||||
ValuePerUnit: 60
|
||||
Name: BlueTiberium
|
||||
PipColor: Blue
|
||||
AllowedTerrainTypes: Clear,Road
|
||||
AllowUnderActors: true
|
||||
|
||||
|
||||
@@ -44,14 +44,15 @@
|
||||
InternalName: smuggler
|
||||
Selectable: false
|
||||
ResourceType@Spice:
|
||||
Type: Spice
|
||||
Name: Spice
|
||||
PipColor: green
|
||||
ResourceType: 1
|
||||
Palette: d2k
|
||||
TerrainType: Spice
|
||||
Variants: spice
|
||||
Sequences: spice
|
||||
MaxDensity: 20
|
||||
ValuePerUnit: 25
|
||||
Name: Spice
|
||||
PipColor: green
|
||||
AllowedTerrainTypes: SpiceSand
|
||||
AllowUnderActors: true
|
||||
|
||||
|
||||
@@ -65,27 +65,29 @@
|
||||
Side: Random
|
||||
Description: A random Soviet country.
|
||||
ResourceType@ore:
|
||||
Type: Ore
|
||||
Name: Valuable Minerals
|
||||
PipColor: Yellow
|
||||
ResourceType: 1
|
||||
TerrainType: Ore
|
||||
Palette: player
|
||||
Variants: gold01,gold02,gold03,gold04
|
||||
Sequences: gold01,gold02,gold03,gold04
|
||||
MaxDensity: 12
|
||||
ValuePerUnit: 25
|
||||
Name: Ore
|
||||
PipColor: Yellow
|
||||
AllowedTerrainTypes: Clear,Road
|
||||
AllowUnderActors: true
|
||||
TerrainType: Ore
|
||||
ResourceType@gem:
|
||||
Type: Gems
|
||||
Name: Valuable Minerals
|
||||
PipColor: Red
|
||||
ResourceType: 2
|
||||
TerrainType: Gems
|
||||
Palette: player
|
||||
Variants: gem01,gem02,gem03,gem04
|
||||
Sequences: gem01,gem02,gem03,gem04
|
||||
MaxDensity: 3
|
||||
ValuePerUnit: 50
|
||||
Name: Gems
|
||||
PipColor: Red
|
||||
AllowedTerrainTypes: Clear,Road
|
||||
AllowUnderActors: true
|
||||
TerrainType: Gems
|
||||
|
||||
World:
|
||||
Inherits: ^BaseWorld
|
||||
|
||||
@@ -22,35 +22,38 @@
|
||||
Name: Nod
|
||||
InternalName: nod
|
||||
ResourceType@Tiberium:
|
||||
ResourceType: 1
|
||||
Palette: greentiberium
|
||||
Variants: tib01, tib02, tib03, tib04, tib05, tib06, tib07, tib08, tib09, tib10, tib11, tib12
|
||||
MaxDensity: 12
|
||||
ValuePerUnit: 50
|
||||
Type: Tiberium
|
||||
Name: Tiberium
|
||||
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
|
||||
AllowUnderActors: true
|
||||
TerrainType: Tiberium
|
||||
ResourceType@BlueTiberium:
|
||||
Type: BlueTiberium
|
||||
Name: Tiberium
|
||||
PipColor: Blue
|
||||
ResourceType: 2
|
||||
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
|
||||
ValuePerUnit: 100
|
||||
Name: BlueTiberium
|
||||
PipColor: Blue
|
||||
AllowedTerrainTypes: Clear, Rough, DirtRoad
|
||||
AllowUnderActors: true
|
||||
TerrainType: BlueTiberium
|
||||
ResourceType@Veins:
|
||||
ResourceType: 3
|
||||
Palette: player
|
||||
Variants: veins
|
||||
MaxDensity: 1
|
||||
ValuePerUnit: 0
|
||||
Type: Veins
|
||||
Name: Veins
|
||||
PipColor: Red
|
||||
ResourceType: 3
|
||||
Palette: player
|
||||
Sequences: veins
|
||||
MaxDensity: 1
|
||||
ValuePerUnit: 0
|
||||
AllowedTerrainTypes: Clear
|
||||
AllowUnderActors: true
|
||||
TerrainType: Veins
|
||||
|
||||
Reference in New Issue
Block a user