public override void OnTrackActivate(TrackSectionComponent track, ActivateInfo info) { bool selectStart; if (info.button == ActivateButton.LeftClick && HighlightClosestEnd(track.trackSection, true, info.hit.point, out selectStart)) { if (state == State.Idle) { fromSection = track.trackSection; fromEnd = !selectStart; ToState(State.SelectedStart); } else if (state == State.SelectedStart) { // Try to place the track var toSection = track.trackSection; var toEnd = !selectStart; if (!TryPlaceTrack(fromSection, fromEnd, toSection, toEnd)) { Debug.Log("Unable to place flex section!"); } ToState(State.Idle); } } else if (info.button == ActivateButton.RightClick) { ToState(State.Idle); } }
public override void OnTrackActivate(TrackSectionComponent track, ActivateInfo info) { if (info.button == ActivateButton.LeftClick && selectedWagon != null) { // Place the selected wagon on the track float distance; GetSnappedTrackPosition(track.trackSection, info.hit.point, out distance); PlaceSelected(track.trackSection, distance); } }
public override void OnTrackHover(TrackSectionComponent track, ActivateInfo info) { if (HighlightClosestEnd(track.trackSection, true, info.hit.point, out shouldInvertOnReposition)) { lastHighlightedSection = track.trackSection; } else { lastHighlightedSection = null; } }
public override void OnTrackHover(TrackSectionComponent track, ActivateInfo info) { if (selectedWagon != null) { float distance; // TODO: Draw ghost instead var matrix = Matrix4x4.TRS(GetSnappedTrackPosition(track.trackSection, info.hit.point, out distance), track.trackSection.GetRotationOnTrack(distance), Vector3.one); Highlighter.DrawHighlighter(matrix); Graphics.DrawMesh(selectedWagon.GetComponent <MeshFilter>().sharedMesh, matrix, selectedWagon.GetComponent <MeshRenderer>().sharedMaterial, gameObject.layer); } }
private void Serialize(TrackSectionComponent component) { Serialize(component.trackSection); ushort id = 0; if (component.InGroup) { if (!trackGroupIds.ContainsKey(component.group)) { trackGroupIds.Add(component.group, (ushort)(trackGroupIds.Count + 1)); } id = trackGroupIds[component.group]; } writer.Write(id); }
public override void OnTrackActivate(TrackSectionComponent track, ActivateInfo info) { if (lastHighlightedSection == track.trackSection && info.button == ActivateButton.LeftClick) { // Reposition on track section, or deselect trackLayer.Reposition(lastHighlightedSection != trackLayer.CurrentSection ? lastHighlightedSection : null, shouldInvertOnReposition); } else if (info.button == ActivateButton.RightClick) { // Delete track if (track.trackSection == trackLayer.CurrentSection) { trackLayer.CurrentSection = null; } RemoveTrackSection(track); } }
public static void RemoveTrackSection(TrackSectionComponent component) { List <TrackSectionComponent> toRemove = new List <TrackSectionComponent> { component }; if (component.InGroup) { toRemove = component.group; } foreach (var track in toRemove) { // Unlink track sections if (track.trackSection.Next != null) { if (track.trackSection.Next.Previous == track.trackSection) { track.trackSection.Next.Previous = null; } else if (track.trackSection.Next.Next == track.trackSection) { track.trackSection.Next.Next = null; } } if (track.trackSection.Previous != null) { if (track.trackSection.Previous.Previous == track.trackSection) { track.trackSection.Previous.Previous = null; } else if (track.trackSection.Previous.Next == track.trackSection) { track.trackSection.Previous.Next = null; } } TrackDatabase.Instance.DeregisterTrack(track.trackSection); GameObject.Destroy(track.gameObject); } }
public virtual void OnTrackActivate(TrackSectionComponent track, ActivateInfo info) { }