Example #1
0
        public bool TryCreateEntity(int column, int row, bool isPartOfDrag, [NotNullWhen(returnValue: true)] out Track?entity)
        {
            // never automatically draw a signal

            entity = null;
            return(false);
        }
Example #2
0
        public static void Warning(object instance, Track?track, string message, params object[] values)
        {
            object log;

            Details(instance, track, out track, out log);
            Register(DiagnosticType.Warning, log, null, message, values);
        }
Example #3
0
 public TrackNeighbors(Track?left, Track?up, Track?right, Track?down)
 {
     this.Left  = left;
     this.Up    = up;
     this.Right = right;
     this.Down  = down;
 }
Example #4
0
 public CarGroup(
     int startIndex,
     int endIndex,
     List <TrainCar> cars,
     float maxStress,
     float?maxCouplerStress,
     Job?job,
     Track?nextDestination,
     float minBrakePipePressure,
     float minBrakeReservoirPressure,
     float maxBrakeCylinderPressure,
     float maxBrakeFactor,
     IEnumerable <char> brakeModes)
 {
     this.startIndex       = startIndex;
     this.endIndex         = endIndex;
     this.cars             = cars;
     this.maxStress        = maxStress;
     this.maxCouplerStress = maxCouplerStress;
     this.job                       = job;
     this.nextDestination           = nextDestination;
     this.minBrakePipePressure      = minBrakePipePressure;
     this.minBrakeReservoirPressure = minBrakeReservoirPressure;
     this.maxBrakeCylinderPressure  = maxBrakeCylinderPressure;
     this.maxBrakeFactor            = maxBrakeFactor;
     this.brakeModes                = brakeModes.ToList();
     if (this.brakeModes.Count == 0)
     {
         this.brakeModes.Add(' ');
     }
 }
Example #5
0
        //      ------------------

        //public void Play(PlayerControl playerControl, Track track) {
        //  OwnerPlayerControl = playerControl;
        //  Playinglist = null;
        //  CanSkipTrack = false;
        //  Track = track;
        //  trace($"Play single track {Track.Title}");
        //  playtrack();
        //}


        public void Play(
            PlayerControl playerControl,
            Playinglist?playinglist,
            Track?track,
            TimeSpan position,
            bool isShuffle,
            double volume)
        {
            OwnerPlayerControl = playerControl;
            Playinglist        = playinglist;
            CanSkipTrack       = playinglist?.Playlist?.TracksCount > 0 || playinglist?.AllTracks.Count > 0;
            if (playinglist is not null && track is null)
            {
                //start playing new track from playinglist
                trace($"Play playlist {playinglist.Playlist?.Name}");
                Track = playinglist.GetNext(null);
                if (Track is null)
                {
                    trace($"cannot find a track.");
                    mediaPlayer.Pause();//prevents from immediate playing when user changes position
                    State = PlayerStateEnum.Idle;
                }
                else
                {
                    playtrack();
                }
            }
Example #6
0
 private void player_TrackChanged(Player player)
 {
     if (isPlayerOwner)
     {
         track = player.Track;
     }
 }
Example #7
0
        public static void Warning <TEx>(object instance, TEx ex) where TEx : Exception
        {
            Track? track = TrackException(ex);
            object log;

            Details(instance, track, out track, out log);
            Register(DiagnosticType.Warning, log, track, $"{ex.GetType().Name}: {ex.Message}");
        }
Example #8
0
        public static void Error <TEx>(object instance, TEx ex) where TEx : Exception
        {
            Track? track = TrackException(ex);
            object log;

            Details(instance, track, out track, out log);
            Register(DiagnosticType.Error, log, track, $"{ex.GetType().Name}: {ex.Message.Replace(System.Environment.NewLine, " ")}");
        }
 internal void Init(Track track, float noteLinesDistance, TrackLaneRing?trackLaneRing, ParametricBoxController?parametricBoxController, BeatmapObjectsAvoidance?beatmapObjectsAvoidance)
 {
     _track                   = track;
     _noteLinesDistance       = noteLinesDistance;
     _trackLaneRing           = trackLaneRing;
     _parametricBoxController = parametricBoxController;
     _beatmapObjectsAvoidance = beatmapObjectsAvoidance;
 }
Example #10
0
        public static void Debug(object instance, Track?track, string message, params object[] values)
        {
            if (R.DebugMode)
            {
                object log;
                Details(instance, track, out track, out log);

                Register(DiagnosticType.Debug, log, track, message, values);
            }
        }
Example #11
0
        public bool TryCreateEntity(int column, int row, bool isPartOfDrag, [NotNullWhen(returnValue: true)] out Track?entity)
        {
            if (!_terrainMap.Get(column, row).IsWater)
            {
                entity = null;
                return(false);
            }

            entity = new Bridge();
            return(true);
        }
Example #12
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Track = await _context.Tracks.FirstOrDefaultAsync(m => m.TrackId == id);

            if (Track == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Example #13
0
        internal static void GetColorOffset(PointDefinition?localColor, Track?track, float time, out Color?color)
        {
            Vector4?pathColor = localColor?.InterpolateVector4(time) ?? TryGetVector4PathProperty(track, COLOR, time);

            Vector4?colorVector = MultVector4Nullables((Vector4?)TryGetProperty(track, COLOR), pathColor);

            if (colorVector.HasValue)
            {
                Vector4 vectorValue = colorVector.Value;
                color = new Color(vectorValue.x, vectorValue.y, vectorValue.z, vectorValue.w);
            }
            else
            {
                color = null;
            }
        }
Example #14
0
        public bool TryCreateEntity(int column, int row, [NotNullWhen(returnValue: true)] out Track?entity)
        {
            if (!_terrainMap.Get(column, row).IsWater&&
                _layout.TryGet(column, row, out Track? track) &&
                (
                    track is Signal ||
                    track.Direction is TrackDirection.Horizontal or TrackDirection.Vertical && track.Happy)
                )
            {
                entity = new Signal();
                return(true);
            }

            entity = null;
            return(false);
        }
        internal static void HandleTrackData(
            GameObject gameObject,
            Dictionary <string, object?> gameObjectData,
            IReadonlyBeatmapData beatmapData,
            float noteLinesDistance,
            TrackLaneRing?trackLaneRing,
            ParametricBoxController?parametricBoxController,
            BeatmapObjectsAvoidance?beatmapObjectsAvoidance)
        {
            Track?track = GetTrack(gameObjectData, beatmapData);

            if (track != null)
            {
                GameObjectTrackController trackController = gameObject.AddComponent <GameObjectTrackController>();
                trackController.Init(track, noteLinesDistance, trackLaneRing, parametricBoxController, beatmapObjectsAvoidance);
            }
        }
Example #16
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Track = await _context.Tracks.FindAsync(id);

            if (Track != null)
            {
                _context.Tracks.Remove(Track);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Example #17
0
        private static void Register(DiagnosticType dtype, object log, Track?track, string message, params object[] values)
        {
#if DEBUG
            var file = $"{Helpers.DiagnosticHelper.PathLog}\\{DateTime.Now.ToString("yyMMdd")}_0000.log";
#else
            var file = $"{Helpers.DiagnosticHelper.PathLog}\\{DateTime.Now.ToString("yyMMdd_HH")}00.log";
#endif

            var time = DateTime.Now.ToString("HH:mm:ss");
            var type = dtype.ToString() + new String(' ', 7 - dtype.ToString().Length);
            var trck = track;
            if (message is null)
            {
                message = "Sorry! No messages logged.";
            }
            var msg = Dynamic.StringFormat(message, values);

            var line = $"{time} {type} - {log} {trck}: {msg}";

            Shell.File.Save(line, file, false, true);
        }
Example #18
0
        internal static void AssignTrack(Track track)
        {
            if (_instance == null)
            {
                GameObject gameObject   = GameObject.Find("LocalPlayerGameCore");
                GameObject noodleObject = new GameObject("NoodlePlayerTrack");
                _origin = noodleObject.transform;
                _origin.SetParent(gameObject.transform.parent, true);
                gameObject.transform.SetParent(_origin, true);

                _instance        = noodleObject.AddComponent <PlayerTrack>();
                _pauseController = FindObjectOfType <PauseController>();
                if (_pauseController != null)
                {
                    _pauseController.didPauseEvent += _instance.OnDidPauseEvent;
                }

                _startLocalRot = _origin.localRotation;
                _startPos      = _origin.localPosition;
            }

            _track = track;
        }
Example #19
0
 public CarGroup(
     int startIndex,
     int endIndex,
     List <TrainCar> cars,
     float maxStress,
     Job?job,
     Track?nextDestination,
     float minBrakePipePressure,
     float minBrakeReservoirPressure,
     float maxBrakeCylinderPressure,
     float maxBrakeFactor)
 {
     this.startIndex                = startIndex;
     this.endIndex                  = endIndex;
     this.cars                      = cars;
     this.maxStress                 = maxStress;
     this.job                       = job;
     this.nextDestination           = nextDestination;
     this.minBrakePipePressure      = minBrakePipePressure;
     this.minBrakeReservoirPressure = minBrakeReservoirPressure;
     this.maxBrakeCylinderPressure  = maxBrakeCylinderPressure;
     this.maxBrakeFactor            = maxBrakeFactor;
 }
Example #20
0
 private static void Details(object instance, Track?trackin, out Track?track, out object log)
 {
     if (instance is null)
     {
         track = trackin;
         log   = Track.Null;
     }
     else if (instance is int)
     {
         track = trackin;
         log   = $"C{(int)instance}";
     }
     else if (instance is string)
     {
         track = trackin;
         log   = (string)instance;
     }
     else
     {
         log   = $"{instance.GetType().FullName}:C{instance.GetHashCode()}";
         track = trackin ?? TrackObject(instance);
     }
 }
Example #21
0
        private static void Postfix(NoteController __instance, NoteData ____noteData, NoteMovement ____noteMovement)
        {
            ChromaObjectData?chromaData = TryGetObjectData <ChromaObjectData>(____noteData);

            if (chromaData == null)
            {
                return;
            }

            Track?          track = chromaData.Track;
            PointDefinition?pathPointDefinition = chromaData.LocalPathColor;

            if (track != null || pathPointDefinition != null)
            {
                NoteJump noteJump = _noteJumpAccessor(ref ____noteMovement);

                float jumpDuration = _jumpDurationAccessor(ref noteJump);
                float elapsedTime  = _audioTimeSyncControllerAccessor(ref noteJump).songTime - (____noteData.time - (jumpDuration * 0.5f));
                float normalTime   = elapsedTime / jumpDuration;

                Chroma.AnimationHelper.GetColorOffset(pathPointDefinition, track, normalTime, out Color? colorOffset);

                if (colorOffset.HasValue)
                {
                    Color color = colorOffset.Value;
                    if (__instance is BombNoteController)
                    {
                        __instance.ColorizeBomb(color);
                    }
                    else
                    {
                        __instance.ColorizeNote(color);
                    }
                }
            }
        }
Example #22
0
 private void Player_TrackChanged(Player player)
 {
     trace($"<<<Track changed {player.Track}");
     TrackTextBox.Text = player.Track?.Title ?? "";
     track             = player.Track;
 }
Example #23
0
        public Track?GetNext(Random?random)
        {
            Track?next = null;

            if (toPlayTracks.Count > 0)
            {
                var trackIndex      = random?.Next(toPlayTracks.Count) ?? 0;
                var playinglistItem = toPlayTracks[trackIndex];
                toPlayTracks.RemoveAt(trackIndex);
                if (playinglistItem is PlayinglistItemTrack playinglistItemTrack)
                {
                    next = playinglistItemTrack.Track;
                }
                else if (playinglistItem is PlayinglistItemPlaylistTrack playinglistItemPlaylistTrack)
                {
                    if (DC.Data.PlayinglistTracksByPlaylistTrackKey.TryGetValue(playinglistItemPlaylistTrack.PlaylistTrack.Key, out var playinglistTrack))
                    {
                        playinglistTrack.Release();
                        next = playinglistItemPlaylistTrack.PlaylistTrack.Track;
                    }
                    else
                    {
                        //PlayinglistTrack not found, Track might just have been removed from Playlist
                        //search for next existing playinglistItem
                        while (toPlayTracks.Count > 0)
                        {
                            if (trackIndex >= toPlayTracks.Count)
                            {
                                trackIndex = 0;
                            }
                            playinglistItem = toPlayTracks[trackIndex];
                            toPlayTracks.RemoveAt(trackIndex);
                            if (DC.Data.PlayinglistTracksByPlaylistTrackKey.TryGetValue(playinglistItemPlaylistTrack.PlaylistTrack.Key, out playinglistTrack))
                            {
                                playinglistTrack.Release();
                                return(playinglistItemPlaylistTrack.PlaylistTrack.Track);
                            }
                        }
                        System.Diagnostics.Debugger.Break();
                        return(null);
                    }
                }
                else
                {
                    throw new NotSupportedException();
                }
            }

            if (toPlayTracks.Count == 0)
            {
                if (Playlist is null)
                {
                    if (allTracks.Count == 0)
                    {
                        System.Diagnostics.Debugger.Break();
                        return(null);
                    }
                    foreach (var copyTrack in allTracks)
                    {
                        toPlayTracks.Add(copyTrack);
                        if (copyTrack is PlayinglistItemPlaylistTrack playinglistItemPlaylistTrack)
                        {
                            System.Diagnostics.Debugger.Break();//We should never come here, because PlayinglistItemPlaylistTrack are not used when Playlist is null
                            //todo: change allTracks to List<PlayinglistItemTrack>
                            _ = new PlayinglistTrack(playinglistItemPlaylistTrack.PlaylistTrack.Key);
                        }
                    }
                }
                else
                {
                    fill(Playlist.PlaylistTracks);
                    if (toPlayTracks.Count == 0)
                    {
                        //it seems user has deleted all tracks from playlist
                        return(null);
                    }
                }
            }
            if (next is null)
            {
                //toPlayTracks was empty when GetNext() was called. Now toPlayTracks is supposed to be full, unless user deleted
                //all tracks which were in the playlist in the meantime
                System.Diagnostics.Debugger.Break();
                return(null);
            }
            return(next);
        }
Example #24
0
 private void BuildEntrances(Track?neighbour, Tunnel neighbourCellTunnel, Dictionary <(int column, int row), Tunnel> entrances)
Example #25
0
 private static bool AreAllPresent(Track?track1, Track?track2, Track?track3)
 => track1 is not null &&
Example #26
0
        public TrackRenameWindow(Track?track = null, Action <Track>?refreshOwner = null)
        {
            this.track        = track;
            this.refreshOwner = refreshOwner;

            InitializeComponent();

            Loaded             += trackRenameWindow_Loaded;
            GoogleButton.Click += googleButton_Click;
            SaveButton.Click   += saveButton_Click;
            Closed             += trackRenameWindow_Closed;

            if (track is null || lastPath != new FileInfo(track.FullFileName).DirectoryName)
            {
                lastPath   = null;
                lastAlbum  = null;
                lastGenres = null;
                lastYear   = null;
            }
            if (track is not null)
            {
                FileNameTextBox.Text = track.FileName;
                TitleTextBox.Text    = track.Title;
                TitleTextBoxNew.Initialise(track.Title);
                AlbumTextBox.Text = track.Album;
                if (track.Album is not null)
                {
                    AlbumTextBoxNew.Initialise(track.Album);
                }
                else if (lastAlbum is not null)
                {
                    AlbumTextBoxNew.Initialise(lastAlbum);
                }
                else
                {
                    AlbumTextBoxNew.Initialise(null);
                }
                AlbumTrackTextBox.Text = track.AlbumTrack.ToString();
                AlbumTrackTextBoxNew.Initialise(track.AlbumTrack);
                ArtistsTextBox.Text = track.Artists;
                ArtistsTextBoxNew.Initialise(track.Artists);
                ComposersTextBox.Text = track.Composers;
                ComposersTextBoxNew.Initialise(track.Composers);
                GenresTextBox.Text = track.Genres;

                GenreEditComboBox.ItemsSource = DC.Data.Genres;
                int?genreIndex = 0;
                var isFound    = false;
                foreach (var genre in DC.Data.Genres)
                {
                    if (genre == track.Genres)
                    {
                        isFound = true;
                        break;
                    }
                    genreIndex++;
                }
                string?text;
                if (isFound)
                {
                    text = null;
                }
                else
                {
                    genreIndex = null;
                    text       = track.Genres;
                }
                if (text is not null || genreIndex is not null)
                {
                    GenreEditComboBox.Initialise(text, genreIndex);
                }
                else if (lastGenres is not null)
                {
                    GenreEditComboBox.Initialise(lastGenres, null);
                }
                else
                {
                    GenreEditComboBox.Initialise(null, null);
                }
                //GenreEditComboBox.Text = track.Genres;
                PublisherTextBox.Text = track.Publisher;
                PublisherTextBoxNew.Initialise(track.Publisher);
                YearTextBox.Text = track.Year.ToString();
                if (track.Year is not null)
                {
                    YearTextBoxNew.Initialise(track.Year);
                    //} else if (lastYear is not null) { //too confusing
                    //  YearTextBoxNew.Initialise(lastYear);
                }
                else
                {
                    YearTextBoxNew.Initialise(null);
                }

                MainWindow.Register(this, $"Rename {track.FileName}");
                updateSaveButtonIsEnabled();
            }
Example #27
0
        private IEnumerable <CarGroup> GetCarGroups(IEnumerable <TrainCar> cars, bool individual)
        {
            Job?  prevJob       = null;
            Track?prevDestTrack = null;
            int   startIndex    = 0;
            float maxStress     = 0f;

            var firstCar  = cars.First();
            var groupCars = new List <TrainCar>()
            {
                firstCar
            };
            float minBrakePipePressure      = firstCar.brakeSystem.brakePipePressure;
            float minBrakeReservoirPressure = GetAuxReservoirPressure(firstCar);
            float maxBrakeCylinderPressure  = GetBrakeCylinderPressure(firstCar);
            float maxBrakeFactor            = firstCar.brakeSystem.brakingFactor;

            int i = 0;

            foreach (var car in cars)
            {
                float       carStress             = car.GetComponent <TrainStress>().derailBuildUp;
                Job?        job                   = JobChainController.GetJobOfCar(car);
                Track?      nextDestination       = GetNextDestinationTrack(job, car.logicCar);
                BrakeSystem brakeSystem           = car.brakeSystem;
                float       pipePressure          = brakeSystem.brakePipePressure;
                float       auxReservoirPressure  = GetAuxReservoirPressure(car);
                float       brakeCylinderPressure = GetBrakeCylinderPressure(car);
                if (individual || nextDestination == null || nextDestination != prevDestTrack || job != prevJob)
                {
                    // complete previous group
                    if (i > 0)
                    {
                        yield return(new CarGroup(
                                         startIndex,
                                         i,
                                         groupCars,
                                         maxStress,
                                         prevJob,
                                         prevDestTrack,
                                         minBrakePipePressure,
                                         minBrakeReservoirPressure,
                                         maxBrakeCylinderPressure,
                                         maxBrakeFactor));
                    }

                    // start new group
                    startIndex = i;
                    groupCars  = new List <TrainCar>()
                    {
                        car
                    };
                    prevJob                   = job;
                    prevDestTrack             = nextDestination;
                    maxStress                 = carStress;
                    minBrakePipePressure      = pipePressure;
                    minBrakeReservoirPressure = auxReservoirPressure;
                    maxBrakeCylinderPressure  = brakeCylinderPressure;
                    maxBrakeFactor            = brakeSystem.brakingFactor;
                }
                else
                {
                    groupCars.Add(car);
                    if (carStress > maxStress)
                    {
                        maxStress = carStress;
                    }
                    if (pipePressure < minBrakePipePressure)
                    {
                        minBrakeReservoirPressure = auxReservoirPressure;
                    }
                    if (auxReservoirPressure < minBrakeReservoirPressure)
                    {
                        minBrakeReservoirPressure = auxReservoirPressure;
                    }
                    if (brakeCylinderPressure > maxBrakeCylinderPressure)
                    {
                        maxBrakeCylinderPressure = brakeCylinderPressure;
                    }
                    if (brakeSystem.brakingFactor > maxBrakeFactor)
                    {
                        maxBrakeFactor = brakeSystem.brakingFactor;
                    }
                }
                i++;
            }

            // complete last group
            yield return(new CarGroup(
                             startIndex,
                             i,
                             groupCars,
                             maxStress,
                             prevJob,
                             prevDestTrack,
                             minBrakePipePressure,
                             minBrakeReservoirPressure,
                             maxBrakeCylinderPressure,
                             maxBrakeFactor));
        }
Example #28
0
        //public bool GetNextTrack([NotNullWhen(true)] out Track? nextTrack) {
        //  if (getNextTrack is null) {
        //    System.Diagnostics.Debugger.Break();
        //    nextTrack = null;
        //    return false;
        //  }
        //  nextTrack = getNextTrack();
        //  return true;
        //}


        public void SetSelectedTrack(Track?track)
        {
            TrackChanged?.Invoke(track);
        }
 private void WaveformSeekbar_Loaded(object sender, RoutedEventArgs e)
 {
     _mainTrack    = (Track)this.Template.FindName("PART_Track", this);
     _previewTrack = (Track)this.Template.FindName("PreviewTrack", this);
     _previewPopup = (Popup)this.Template.FindName("PreviewPopup", this);
 }
        public bool TryCreateEntity(int column, int row, bool isPartOfDrag, [NotNullWhen(true)] out Track?entity)
        {
            var neighbours = TrackNeighbors.GetConnectedNeighbours(_layout.ToLayout(), column, row, emptyIsConsideredConnected: true);

            // if they click and its the perfect spot for a cross track, just do it
            if (!isPartOfDrag && neighbours.Count == 4)
            {
                entity = new CrossTrack();
                return(true);
            }

            if (isPartOfDrag)
            {
                if (neighbours.Count == 4)
                {
                    entity = new CrossTrack();
                    return(true);
                }

                // if they're dragging, we're looking for them to complete an intersection
                neighbours = TrackNeighbors.GetConnectedNeighbours(_layout.ToLayout(), column - 1, row);
                if (neighbours.Count == 3 && neighbours.Right is null)
                {
                    entity = new Track()
                    {
                        Direction = TrackDirection.Horizontal
                    };
                    _layout.Set(column - 1, row, new CrossTrack());
                    return(true);
                }

                neighbours = TrackNeighbors.GetConnectedNeighbours(_layout.ToLayout(), column, row - 1);
                if (neighbours.Count == 3 && neighbours.Down is null)
                {
                    entity = new Track()
                    {
                        Direction = TrackDirection.Vertical
                    };
                    _layout.Set(column, row - 1, new CrossTrack());
                    return(true);
                }

                neighbours = TrackNeighbors.GetConnectedNeighbours(_layout.ToLayout(), column + 1, row);
                if (neighbours.Count == 3 && neighbours.Left is null)
                {
                    entity = new Track()
                    {
                        Direction = TrackDirection.Horizontal
                    };
                    _layout.Set(column + 1, row, new CrossTrack());
                    return(true);
                }

                neighbours = TrackNeighbors.GetConnectedNeighbours(_layout.ToLayout(), column, row + 1);
                if (neighbours.Count == 3 && neighbours.Up is null)
                {
                    entity = new Track()
                    {
                        Direction = TrackDirection.Vertical
                    };
                    _layout.Set(column, row + 1, new CrossTrack());
                    return(true);
                }
            }

            entity = null;
            return(false);
        }