@@ -35,16 +35,11 @@ public VehicleViewModel(VehicleObject model) : base(model)
3535 RoadOrTrackType = model . RoadOrTrackType ;
3636 RackRail = model . RackRail ;
3737
38- HasRackRail = model . Flags . HasFlag ( VehicleObjectFlags . RackRail ) ;
39-
4038 SimpleMotorSound = model . SimpleMotorSound ?? new SimpleMotorSound ( ) ;
4139 FrictionSound = model . FrictionSound ?? new FrictionSound ( ) ;
4240 GearboxMotorSound = model . GearboxMotorSound ?? new GearboxMotorSound ( ) ;
4341 Sound = model . Sound ;
4442
45- _ = this . WhenAnyValue ( x => x . RackRail )
46- . Subscribe ( ( _ ) => model . RackRail = RackRail ) ;
47-
4843 #region Road/Track Type Binding
4944
5045 _ = this . WhenAnyValue ( x => x . Mode , x => x . Flags )
@@ -53,9 +48,6 @@ public VehicleViewModel(VehicleObject model) : base(model)
5348 _ = this . WhenAnyValue ( x => x . IsTrackTypeSettable )
5449 . Subscribe ( ( _ ) => this . RaisePropertyChanged ( nameof ( RoadOrTrackType ) ) ) ;
5550
56- _ = this . WhenAnyValue ( x => x . RoadOrTrackType )
57- . Subscribe ( ( _ ) => model . RoadOrTrackType = RoadOrTrackType ) ;
58-
5951 #endregion
6052
6153 #region Sound Properties Binding
@@ -165,10 +157,13 @@ public VehicleObjectFlags Flags
165157 bool IsTrackTypeSettable
166158 => ! model . Flags . HasFlag ( VehicleObjectFlags . AnyRoadType ) && ( model . Mode == TransportMode . Rail || model . Mode == TransportMode . Road ) ;
167159
168- [ Reactive ]
169160 [ ConditionTarget ]
170161 [ PropertyVisibilityCondition ( nameof ( IsTrackTypeSettable ) , true ) ]
171- public ObjectModelHeader ? RoadOrTrackType { get ; set ; }
162+ public ObjectModelHeader ? RoadOrTrackType
163+ {
164+ get => model . RoadOrTrackType ;
165+ set => model . RoadOrTrackType = value ;
166+ }
172167
173168 [ ConditionTarget ]
174169 public bool HasRackRail
@@ -177,16 +172,23 @@ public bool HasRackRail
177172 set
178173 {
179174 model . Flags = model . Flags . ToggleFlag ( VehicleObjectFlags . RackRail , value ) ;
180- RackRail = value && RackRail == null
181- ? new ObjectModelHeader ( "<obj>" , ObjectType . TrackExtra , ObjectSource . OpenLoco , 0 )
182- : null ;
175+
176+ if ( RackRail == null && model . Flags . HasFlag ( VehicleObjectFlags . RackRail ) )
177+ {
178+ RackRail = new ObjectModelHeader ( ) { Name = "<obj>" , ObjectSource = ObjectSource . Custom , ObjectType = ObjectType . TrackExtra } ;
179+ }
180+
181+ this . RaisePropertyChanged ( nameof ( RackRail ) ) ;
183182 }
184183 }
185184
186- [ Reactive ]
187185 [ ConditionTarget ]
188186 [ PropertyVisibilityCondition ( nameof ( HasRackRail ) , true ) ]
189- public ObjectModelHeader ? RackRail { get ; set ; }
187+ public ObjectModelHeader ? RackRail
188+ {
189+ get => model . RackRail ;
190+ set => model . RackRail = value ;
191+ }
190192
191193 [ Range ( 0 , 4 ) ]
192194 public uint8_t NumCarComponents
0 commit comments