/// <summary> /// Prepare this state for use in a live railway. /// Make sure all relevant connections to other state objects are resolved. /// </summary> /// <returns>True if the entity is now ready for use in a live railway, false otherwise.</returns> protected override bool TryPrepareForUse(IStateUserInterface ui, IStatePersistence statePersistence) { if (!base.TryPrepareForUse(ui, statePersistence)) { return(false); } var cs = SelectCommandStation(); if (cs == null) { return(false); } cs.AddJunction(this); commandStation = cs; RailwayState.Power.ActualChanged += OnPowerActualChanged; return(true); }
/// <summary> /// Prepare this state for use in a live railway. /// Make sure all relevant connections to other state objects are resolved. /// </summary> /// <returns>True if the entity is now ready for use in a live railway, false otherwise.</returns> protected override bool TryPrepareForUse(IStateUserInterface ui, IStatePersistence statePersistence) { // Resolve block. var entity = Entity; block = (entity.Block != null) ? RailwayState.BlockStates[entity.Block] : null; if (block == null) { return(false); } // Resolve command station var cs = RailwayState.SelectCommandStation(Entity); if (cs == null) { return(false); } commandStation = cs; commandStation.AddSignal(this); return(true); }