Replace TerrainType.CustomCursor with Mobile.TerrainCursors.

This commit is contained in:
Paul Chote
2021-05-03 11:25:10 +01:00
committed by abcdefg30
parent 01371f2c65
commit 8d2ec78713
8 changed files with 25 additions and 18 deletions

View File

@@ -54,7 +54,6 @@ namespace OpenRA
public readonly HashSet<string> AcceptsSmudgeType = new HashSet<string>(); public readonly HashSet<string> AcceptsSmudgeType = new HashSet<string>();
public readonly Color Color; public readonly Color Color;
public readonly bool RestrictPlayerColor = false; public readonly bool RestrictPlayerColor = false;
public readonly string CustomCursor;
public TerrainTypeInfo(MiniYaml my) { FieldLoader.Load(this, my); } public TerrainTypeInfo(MiniYaml my) { FieldLoader.Load(this, my); }
} }

View File

@@ -1293,8 +1293,7 @@ namespace OpenRA.Mods.Common.Traits
var explored = self.Owner.Shroud.IsExplored(location); var explored = self.Owner.Shroud.IsExplored(location);
cursor = !aircraft.IsTraitPaused && (explored || aircraft.Info.MoveIntoShroud) && self.World.Map.Contains(location) ? cursor = !aircraft.IsTraitPaused && (explored || aircraft.Info.MoveIntoShroud) && self.World.Map.Contains(location) ?
(self.World.Map.GetTerrainInfo(location).CustomCursor ?? aircraft.Info.Cursor) : aircraft.Info.Cursor : aircraft.Info.BlockedCursor;
aircraft.Info.BlockedCursor;
return true; return true;
} }

View File

@@ -207,8 +207,7 @@ namespace OpenRA.Mods.Common.Traits
var location = self.World.Map.CellContaining(target.CenterPosition); var location = self.World.Map.CellContaining(target.CenterPosition);
var explored = self.Owner.Shroud.IsExplored(location); var explored = self.Owner.Shroud.IsExplored(location);
cursor = self.World.Map.Contains(location) ? cursor = self.World.Map.Contains(location) ? aircraft.Info.Cursor : aircraft.Info.BlockedCursor;
self.World.Map.GetTerrainInfo(location).CustomCursor ?? aircraft.Info.Cursor : aircraft.Info.BlockedCursor;
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue); IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

View File

@@ -29,6 +29,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Cursor to display when a move order can be issued at target location.")] [Desc("Cursor to display when a move order can be issued at target location.")]
public readonly string Cursor = "move"; public readonly string Cursor = "move";
[CursorReference(dictionaryReference: LintDictionaryReference.Values)]
[Desc("Cursor overrides to display for specific terrain types.",
"A dictionary of [terrain type]: [cursor name].")]
public readonly Dictionary<string, string> TerrainCursors = new Dictionary<string, string>();
[CursorReference] [CursorReference]
[Desc("Cursor to display when a move order cannot be issued at target location.")] [Desc("Cursor to display when a move order cannot be issued at target location.")]
public readonly string BlockedCursor = "move-blocked"; public readonly string BlockedCursor = "move-blocked";
@@ -192,13 +197,13 @@ namespace OpenRA.Mods.Common.Traits
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue); IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
var explored = self.Owner.Shroud.IsExplored(location); var explored = self.Owner.Shroud.IsExplored(location);
cursor = self.World.Map.Contains(location) ? if (!self.World.Map.Contains(location) ||
(self.World.Map.GetTerrainInfo(location).CustomCursor ?? mobile.Info.Cursor) : mobile.Info.BlockedCursor; !(self.CurrentActivity is Transform || mobile.transforms.Any(t => !t.IsTraitDisabled && !t.IsTraitPaused))
|| (!explored && !mobile.locomotor.Info.MoveIntoShroud)
if (!(self.CurrentActivity is Transform || mobile.transforms.Any(t => !t.IsTraitDisabled && !t.IsTraitPaused)) || (explored && !CanEnterCell(self, location)))
|| (!explored && !mobile.locomotor.Info.MoveIntoShroud)
|| (explored && !CanEnterCell(self, location)))
cursor = mobile.Info.BlockedCursor; cursor = mobile.Info.BlockedCursor;
else if (!explored || !mobile.Info.TerrainCursors.TryGetValue(self.World.Map.GetTerrainInfo(location).Type, out cursor))
cursor = mobile.Info.Cursor;
return true; return true;
} }

View File

@@ -432,9 +432,7 @@ namespace OpenRA.Mods.Common.Traits
var location = self.World.Map.CellContaining(target.CenterPosition); var location = self.World.Map.CellContaining(target.CenterPosition);
var explored = self.Owner.Shroud.IsExplored(location); var explored = self.Owner.Shroud.IsExplored(location);
cursor = self.World.Map.Contains(location) ? cursor = self.World.Map.Contains(location) ? info.DropOffCursor : info.DropOffBlockedCursor;
(self.World.Map.GetTerrainInfo(location).CustomCursor ?? info.DropOffCursor) :
info.DropOffBlockedCursor;
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue); IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

View File

@@ -45,6 +45,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Cursor to display when a move order can be issued at target location.")] [Desc("Cursor to display when a move order can be issued at target location.")]
public readonly string Cursor = "move"; public readonly string Cursor = "move";
[CursorReference(dictionaryReference: LintDictionaryReference.Values)]
[Desc("Cursor overrides to display for specific terrain types.",
"A dictionary of [terrain type]: [cursor name].")]
public readonly Dictionary<string, string> TerrainCursors = new Dictionary<string, string>();
[CursorReference] [CursorReference]
[Desc("Cursor to display when a move order cannot be issued at target location.")] [Desc("Cursor to display when a move order cannot be issued at target location.")]
public readonly string BlockedCursor = "move-blocked"; public readonly string BlockedCursor = "move-blocked";
@@ -996,13 +1001,14 @@ namespace OpenRA.Mods.Common.Traits
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue); IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
var explored = self.Owner.Shroud.IsExplored(location); var explored = self.Owner.Shroud.IsExplored(location);
cursor = self.World.Map.Contains(location) ?
(self.World.Map.GetTerrainInfo(location).CustomCursor ?? mobile.Info.Cursor) : mobile.Info.BlockedCursor;
if (mobile.IsTraitPaused if (!self.World.Map.Contains(location)
|| mobile.IsTraitPaused
|| (!explored && !locomotorInfo.MoveIntoShroud) || (!explored && !locomotorInfo.MoveIntoShroud)
|| (explored && mobile.Locomotor.MovementCostForCell(location) == short.MaxValue)) || (explored && mobile.Locomotor.MovementCostForCell(location) == short.MaxValue))
cursor = mobile.Info.BlockedCursor; cursor = mobile.Info.BlockedCursor;
else if (!explored || !mobile.Info.TerrainCursors.TryGetValue(self.World.Map.GetTerrainInfo(location).Type, out cursor))
cursor = mobile.Info.Cursor;
return true; return true;
} }

View File

@@ -319,6 +319,8 @@
Mobile: Mobile:
AlwaysTurnInPlace: true AlwaysTurnInPlace: true
Locomotor: foot Locomotor: foot
TerrainCursors:
Rough: move-rough
Selectable: Selectable:
Bounds: 768, 768, 0, -128 Bounds: 768, 768, 0, -128
DecorationBounds: 384, 640, 0, -128 DecorationBounds: 384, 640, 0, -128

View File

@@ -38,7 +38,6 @@ Terrain:
Type: Rough Type: Rough
TargetTypes: Ground TargetTypes: Ground
Color: 587474 Color: 587474
CustomCursor: move-rough
TerrainType@Sand: TerrainType@Sand:
Type: Sand Type: Sand
TargetTypes: Ground TargetTypes: Ground