diff --git a/OpenRA.Game/Map/TerrainInfo.cs b/OpenRA.Game/Map/TerrainInfo.cs index 9c865ce148..48b597c9b4 100644 --- a/OpenRA.Game/Map/TerrainInfo.cs +++ b/OpenRA.Game/Map/TerrainInfo.cs @@ -54,7 +54,6 @@ namespace OpenRA public readonly HashSet AcceptsSmudgeType = new HashSet(); public readonly Color Color; public readonly bool RestrictPlayerColor = false; - public readonly string CustomCursor; public TerrainTypeInfo(MiniYaml my) { FieldLoader.Load(this, my); } } diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index 110aec0b98..8be528607b 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -1293,8 +1293,7 @@ namespace OpenRA.Mods.Common.Traits var explored = self.Owner.Shroud.IsExplored(location); cursor = !aircraft.IsTraitPaused && (explored || aircraft.Info.MoveIntoShroud) && self.World.Map.Contains(location) ? - (self.World.Map.GetTerrainInfo(location).CustomCursor ?? aircraft.Info.Cursor) : - aircraft.Info.BlockedCursor; + aircraft.Info.Cursor : aircraft.Info.BlockedCursor; return true; } diff --git a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoAircraft.cs b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoAircraft.cs index 45447a6ade..401d6974c5 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoAircraft.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoAircraft.cs @@ -207,8 +207,7 @@ namespace OpenRA.Mods.Common.Traits var location = self.World.Map.CellContaining(target.CenterPosition); var explored = self.Owner.Shroud.IsExplored(location); - cursor = self.World.Map.Contains(location) ? - self.World.Map.GetTerrainInfo(location).CustomCursor ?? aircraft.Info.Cursor : aircraft.Info.BlockedCursor; + cursor = self.World.Map.Contains(location) ? aircraft.Info.Cursor : aircraft.Info.BlockedCursor; IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue); diff --git a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoMobile.cs b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoMobile.cs index c58f89cbee..492f814835 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoMobile.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoMobile.cs @@ -29,6 +29,11 @@ namespace OpenRA.Mods.Common.Traits [Desc("Cursor to display when a move order can be issued at target location.")] 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 TerrainCursors = new Dictionary(); + [CursorReference] [Desc("Cursor to display when a move order cannot be issued at target location.")] public readonly string BlockedCursor = "move-blocked"; @@ -192,13 +197,13 @@ namespace OpenRA.Mods.Common.Traits IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue); 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 (!(self.CurrentActivity is Transform || mobile.transforms.Any(t => !t.IsTraitDisabled && !t.IsTraitPaused)) - || (!explored && !mobile.locomotor.Info.MoveIntoShroud) - || (explored && !CanEnterCell(self, location))) + if (!self.World.Map.Contains(location) || + !(self.CurrentActivity is Transform || mobile.transforms.Any(t => !t.IsTraitDisabled && !t.IsTraitPaused)) + || (!explored && !mobile.locomotor.Info.MoveIntoShroud) + || (explored && !CanEnterCell(self, location))) 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; } diff --git a/OpenRA.Mods.Common/Traits/Carryall.cs b/OpenRA.Mods.Common/Traits/Carryall.cs index f1663032ad..75bc126054 100644 --- a/OpenRA.Mods.Common/Traits/Carryall.cs +++ b/OpenRA.Mods.Common/Traits/Carryall.cs @@ -432,9 +432,7 @@ namespace OpenRA.Mods.Common.Traits var location = self.World.Map.CellContaining(target.CenterPosition); var explored = self.Owner.Shroud.IsExplored(location); - cursor = self.World.Map.Contains(location) ? - (self.World.Map.GetTerrainInfo(location).CustomCursor ?? info.DropOffCursor) : - info.DropOffBlockedCursor; + cursor = self.World.Map.Contains(location) ? info.DropOffCursor : info.DropOffBlockedCursor; IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue); diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs index 1b8a33270b..cb05662534 100644 --- a/OpenRA.Mods.Common/Traits/Mobile.cs +++ b/OpenRA.Mods.Common/Traits/Mobile.cs @@ -45,6 +45,11 @@ namespace OpenRA.Mods.Common.Traits [Desc("Cursor to display when a move order can be issued at target location.")] 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 TerrainCursors = new Dictionary(); + [CursorReference] [Desc("Cursor to display when a move order cannot be issued at target location.")] public readonly string BlockedCursor = "move-blocked"; @@ -996,13 +1001,14 @@ namespace OpenRA.Mods.Common.Traits IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue); 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 && mobile.Locomotor.MovementCostForCell(location) == short.MaxValue)) 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; } diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml index 787926e2f3..20ff7b66bf 100644 --- a/mods/d2k/rules/defaults.yaml +++ b/mods/d2k/rules/defaults.yaml @@ -319,6 +319,8 @@ Mobile: AlwaysTurnInPlace: true Locomotor: foot + TerrainCursors: + Rough: move-rough Selectable: Bounds: 768, 768, 0, -128 DecorationBounds: 384, 640, 0, -128 diff --git a/mods/d2k/tilesets/arrakis.yaml b/mods/d2k/tilesets/arrakis.yaml index c6570dcd59..78d5ef57f7 100644 --- a/mods/d2k/tilesets/arrakis.yaml +++ b/mods/d2k/tilesets/arrakis.yaml @@ -38,7 +38,6 @@ Terrain: Type: Rough TargetTypes: Ground Color: 587474 - CustomCursor: move-rough TerrainType@Sand: Type: Sand TargetTypes: Ground