Rename ResourceType trait fields for consistency.

This commit is contained in:
Paul Chote
2016-09-25 13:36:06 +01:00
parent fdc6ea4564
commit 365bd5b9bd
14 changed files with 78 additions and 45 deletions

View File

@@ -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)

View File

@@ -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);

View File

@@ -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;

View File

@@ -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";

View File

@@ -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));

View File

@@ -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);
}

View File

@@ -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));

View File

@@ -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);
}