From 1557a77fec4c80b995258ea9b6d5c612c292db39 Mon Sep 17 00:00:00 2001 From: Bob Date: Thu, 14 Jan 2010 16:26:53 +1300 Subject: [PATCH] new syntax in miniyaml: "-Key:" blocks inheritance of Key. --- OpenRa.FileFormats/MiniYaml.cs | 13 ++++- OpenRa.Game/Traits/Unit.cs | 4 +- RulesConverter/MiniYamlExts.cs | 19 ++++++-- aftermath.yaml | 3 +- aftermathUnits.ini | 2 +- defaults.yaml | 2 + ra.yaml | 89 ++++++++++++++++++++-------------- units.ini | 2 +- 8 files changed, 87 insertions(+), 47 deletions(-) diff --git a/OpenRa.FileFormats/MiniYaml.cs b/OpenRa.FileFormats/MiniYaml.cs index b26b69d9b1..6da0eec414 100755 --- a/OpenRa.FileFormats/MiniYaml.cs +++ b/OpenRa.FileFormats/MiniYaml.cs @@ -66,12 +66,23 @@ namespace OpenRa.FileFormats var keys = a.Keys.Union( b.Keys ).ToList(); + var noInherit = keys.Where( x => x.Length > 0 && x[ 0 ] == '-' ).Select( x => x.Substring( 1 ) ).ToList(); + foreach( var key in keys ) { MiniYaml aa, bb; a.TryGetValue( key, out aa ); b.TryGetValue( key, out bb ); - ret.Add( key, Merge( aa, bb ) ); + + if( key.Length > 0 && key[ 0 ] == '-' ) + continue; + else if( noInherit.Contains( key ) ) + { + if( aa != null ) + ret.Add( key, aa ); + } + else + ret.Add( key, Merge( aa, bb ) ); } return ret; diff --git a/OpenRa.Game/Traits/Unit.cs b/OpenRa.Game/Traits/Unit.cs index d0fe1b0ed6..9792f1da77 100755 --- a/OpenRa.Game/Traits/Unit.cs +++ b/OpenRa.Game/Traits/Unit.cs @@ -5,8 +5,8 @@ namespace OpenRa.Game.Traits class UnitInfo : OwnedActorInfo, ITraitInfo { public readonly int InitialFacing = 128; - public readonly int ROT = 0; - public readonly int Speed = 0; + public readonly int ROT = 255; + public readonly int Speed = 1; public object Create( Actor self ) { return new Unit( self ); } } diff --git a/RulesConverter/MiniYamlExts.cs b/RulesConverter/MiniYamlExts.cs index fcf0220e65..6b388fc99e 100755 --- a/RulesConverter/MiniYamlExts.cs +++ b/RulesConverter/MiniYamlExts.cs @@ -52,7 +52,10 @@ namespace RulesConverter if( parent == null ) continue; - y[ key ] = Diff( node, parent ); + bool remove; + y[ key ] = Diff( node, parent, out remove ); + if( remove ) + y.Add( "-" + key, new MiniYaml( null ) ); if( y[ key ] == null ) y.Remove( key ); } @@ -81,7 +84,11 @@ namespace RulesConverter MiniYaml aa, bb; a.TryGetValue( key, out aa ); b.TryGetValue( key, out bb ); - var diff = Diff( aa, bb ); + bool remove; + var diff = Diff( aa, bb, out remove ); + if( remove ) + ret.Add( "-" + key, new MiniYaml( null ) ); + if( diff != null ) ret.Add( key, diff ); } @@ -90,12 +97,16 @@ namespace RulesConverter return ret; } - public static MiniYaml Diff( MiniYaml a, MiniYaml b ) + public static MiniYaml Diff( MiniYaml a, MiniYaml b, out bool remove ) { + remove = false; if( a == null && b == null ) throw new InvalidOperationException( "can't happen" ); else if( a == null ) - throw new NotImplementedException( "parent has key not in child" ); + { + remove = true; + return a; + } else if( b == null ) return a; diff --git a/aftermath.yaml b/aftermath.yaml index 1532f1a6a6..6941b2caba 100644 --- a/aftermath.yaml +++ b/aftermath.yaml @@ -130,6 +130,7 @@ SHOK: AttackBase: PrimaryWeapon: PortaTesla TakeCover: + -SquishByTank: MECH: Inherits: ^Infantry @@ -151,5 +152,5 @@ MECH: AttackBase: PrimaryWeapon: GoodWrench TakeCover: - SquishByTank: + -AutoTarget: diff --git a/aftermathUnits.ini b/aftermathUnits.ini index 7a9879ecb2..a8f372e7da 100755 --- a/aftermathUnits.ini +++ b/aftermathUnits.ini @@ -54,7 +54,7 @@ MECH [SHOK] Description=Tesla Trooper -Traits=Unit, Mobile, AttackBase, RenderInfantry, TakeCover, Passenger +Traits=Unit, Mobile, AttackBase, RenderInfantry, TakeCover, AutoTarget, Passenger SquadSize=1 Voice=ShokVoice diff --git a/defaults.yaml b/defaults.yaml index 5e74903678..515857f7c5 100644 --- a/defaults.yaml +++ b/defaults.yaml @@ -20,6 +20,8 @@ MovementType: Foot Selectable: RenderInfantry: + SquishByTank: + AutoTarget: Passenger: ^Ship: diff --git a/ra.yaml b/ra.yaml index e35e4c6a97..8bee1c9b9a 100644 --- a/ra.yaml +++ b/ra.yaml @@ -1384,170 +1384,195 @@ DOMF: Fake: MINP: - Category: Building + Inherits: ^Building Unit: HP: 1 RenderUnit: APMine: BelowUnits: InvisibleToOthers: + -Selectable: + -Building: MINV: - Category: Building + Inherits: ^Building Unit: HP: 1 RenderUnit: ATMine: BelowUnits: InvisibleToOthers: + -Selectable: + -Building: T01: - Category: Building + Inherits: ^Building Building: Footprint: x_ x_ Dimensions: 2,2 RenderBuilding: + -Selectable: T02: - Category: Building + Inherits: ^Building Building: Footprint: x_ x_ Dimensions: 2,2 RenderBuilding: + -Selectable: T03: - Category: Building + Inherits: ^Building Building: Footprint: x_ x_ Dimensions: 2,2 RenderBuilding: + -Selectable: T05: - Category: Building + Inherits: ^Building Building: Footprint: x_ x_ Dimensions: 2,2 RenderBuilding: + -Selectable: T06: - Category: Building + Inherits: ^Building Building: Footprint: x_ x_ Dimensions: 2,2 RenderBuilding: + -Selectable: T07: - Category: Building + Inherits: ^Building Building: Footprint: x_ x_ Dimensions: 2,2 RenderBuilding: + -Selectable: T08: - Category: Building + Inherits: ^Building Building: Footprint: x_ Dimensions: 2,1 RenderBuilding: + -Selectable: T10: - Category: Building + Inherits: ^Building Building: Footprint: xx xx Dimensions: 2,2 RenderBuilding: + -Selectable: T11: - Category: Building + Inherits: ^Building Building: Footprint: xx xx Dimensions: 2,2 RenderBuilding: + -Selectable: T12: - Category: Building + Inherits: ^Building Building: Footprint: xx xx Dimensions: 2,2 RenderBuilding: + -Selectable: T13: - Category: Building + Inherits: ^Building Building: Footprint: xx xx Dimensions: 2,2 RenderBuilding: + -Selectable: T14: - Category: Building + Inherits: ^Building Building: Footprint: xx xx Dimensions: 2,2 RenderBuilding: + -Selectable: T15: - Category: Building + Inherits: ^Building Building: Footprint: xx xx Dimensions: 2,2 RenderBuilding: + -Selectable: T16: - Category: Building + Inherits: ^Building Building: Footprint: x_ x_ Dimensions: 2,2 RenderBuilding: + -Selectable: T17: - Category: Building + Inherits: ^Building Building: Footprint: x_ x_ Dimensions: 2,2 RenderBuilding: + -Selectable: TC01: - Category: Building + Inherits: ^Building Building: Footprint: xx_ xx_ Dimensions: 3,2 RenderBuilding: + -Selectable: TC02: - Category: Building + Inherits: ^Building Building: Footprint: xx_ xx_ Dimensions: 3,2 RenderBuilding: + -Selectable: TC03: - Category: Building + Inherits: ^Building Building: Footprint: xx_ xx_ Dimensions: 3,2 RenderBuilding: + -Selectable: TC04: - Category: Building + Inherits: ^Building Building: Footprint: xxx_ xxx_ xxx_ Dimensions: 4,3 RenderBuilding: + -Selectable: TC05: - Category: Building + Inherits: ^Building Building: Footprint: xxx_ xxx_ xxx_ Dimensions: 4,3 RenderBuilding: + -Selectable: MINE: - Category: Building + Inherits: ^Building Building: Footprint: x Dimensions: 1,1 RenderBuilding: SeedsOre: + -Selectable: FCOM: Inherits: ^Building @@ -1991,8 +2016,6 @@ E1: AttackBase: PrimaryWeapon: M1Carbine TakeCover: - SquishByTank: - AutoTarget: E2: Inherits: ^Infantry @@ -2012,8 +2035,6 @@ E2: PrimaryOffset: 0,0,0,-13 FireDelay: 15 TakeCover: - SquishByTank: - AutoTarget: E3: Inherits: ^Infantry @@ -2032,8 +2053,6 @@ E3: PrimaryWeapon: RedEye PrimaryOffset: 0,0,0,-13 TakeCover: - SquishByTank: - AutoTarget: E4: Inherits: ^Infantry @@ -2054,8 +2073,6 @@ E4: PrimaryOffset: 0,0,0,-7 FireDelay: 8 TakeCover: - SquishByTank: - AutoTarget: E6: Inherits: ^Infantry @@ -2073,7 +2090,7 @@ E6: Speed: 4 EngineerCapture: TakeCover: - SquishByTank: + -AutoTarget: SPY: Inherits: ^Infantry @@ -2092,7 +2109,7 @@ SPY: Sight: 5 Speed: 4 TakeCover: - SquishByTank: + -AutoTarget: THF: Inherits: ^Infantry @@ -2111,8 +2128,8 @@ THF: Sight: 5 Speed: 4 TakeCover: - SquishByTank: Thief: + -AutoTarget: E7: Inherits: ^Infantry @@ -2134,8 +2151,6 @@ E7: AttackBase: PrimaryWeapon: Colt45 TakeCover: - SquishByTank: - AutoTarget: MEDI: Inherits: ^Infantry @@ -2156,5 +2171,5 @@ MEDI: AttackBase: PrimaryWeapon: Heal TakeCover: - SquishByTank: + -AutoTarget: diff --git a/units.ini b/units.ini index 396cdd7c8a..c5da8b7f26 100644 --- a/units.ini +++ b/units.ini @@ -549,7 +549,7 @@ MEDI Description=Attack Dog BuiltAt=KENN Voice=DogVoice -Traits=Unit, Mobile, RenderInfantry, Passenger ;; AttackBase, SquishByTank, AutoTarget, dog?? +Traits=Unit, Mobile, RenderInfantry, SquishByTank, AutoTarget, Passenger ;; AttackBase, SquishByTank, AutoTarget, dog?? LongDesc=Anti-infantry unit. Not fooled by the \nSpy's disguise.\n Strong vs Infantry\n Weak vs Vehicles SelectionSize=12,17,-1,-4 [E1]