diff --git a/.env b/.env
index 13efeba..34bdbb9 100644
--- a/.env
+++ b/.env
@@ -1,3 +1,5 @@
-SOLUTION=Mod.Template.sln
-ARTIFACTS=Build/Distance Mod Template.zip
-RELEASE_BODY=This release was automatically generated as part of a GitHub workflow. Please read the repository README for more info.
\ No newline at end of file
+SOLUTION=Distance.TrackAttachToTrack.sln
+ARTIFACTS=Build/Distance TrackAttachToTrack.zip
+RELEASE_BODY=This release was automatically generated as part of a GitHub workflow. Please read the repository README for more info.
+
+
diff --git a/Mod.Template.Content/Mod.Template.Content.projitems b/Distance.TrackAttachToTrack.Content/Distance.TrackAttachToTrack.Content.projitems
similarity index 83%
rename from Mod.Template.Content/Mod.Template.Content.projitems
rename to Distance.TrackAttachToTrack.Content/Distance.TrackAttachToTrack.Content.projitems
index 8289aae..4a3f14d 100644
--- a/Mod.Template.Content/Mod.Template.Content.projitems
+++ b/Distance.TrackAttachToTrack.Content/Distance.TrackAttachToTrack.Content.projitems
@@ -1,4 +1,4 @@
-
+
$(MSBuildAllProjects);$(MSBuildThisFileFullPath)
@@ -6,7 +6,7 @@
4e7d37c7-8afe-4f79-baf6-4ce82d05e091
- Mod.Template.Content
+ Distance.TrackAttachToTrack.Content
@@ -16,4 +16,6 @@
-
\ No newline at end of file
+
+
+
diff --git a/Mod.Template.Content/Mod.Template.Content.shproj b/Distance.TrackAttachToTrack.Content/Distance.TrackAttachToTrack.Content.shproj
similarity index 90%
rename from Mod.Template.Content/Mod.Template.Content.shproj
rename to Distance.TrackAttachToTrack.Content/Distance.TrackAttachToTrack.Content.shproj
index d4502a8..d3712b4 100644
--- a/Mod.Template.Content/Mod.Template.Content.shproj
+++ b/Distance.TrackAttachToTrack.Content/Distance.TrackAttachToTrack.Content.shproj
@@ -8,6 +8,8 @@
-
+
-
\ No newline at end of file
+
+
+
diff --git a/Distance.TrackAttachToTrack.Content/Mod/mod.json b/Distance.TrackAttachToTrack.Content/Mod/mod.json
new file mode 100644
index 0000000..7da1883
--- /dev/null
+++ b/Distance.TrackAttachToTrack.Content/Mod/mod.json
@@ -0,0 +1,12 @@
+{
+ "FriendlyName": "TrackAttachToTrack",
+ "Author": "PB",
+ "Contact": "( .-.)",
+ "ModuleFileName": "Distance.TrackAttachToTrack.dll",
+ "Dependencies": [],
+ "SkipLoad": false,
+ "Priority": 10,
+ "RequiredGSLs": [
+ "com.github.reherc/Centrifuge.Distance"
+ ]
+}
\ No newline at end of file
diff --git a/Mod.Template.sln b/Distance.TrackAttachToTrack.sln
similarity index 71%
rename from Mod.Template.sln
rename to Distance.TrackAttachToTrack.sln
index 5ea1c6d..af9d5b2 100644
--- a/Mod.Template.sln
+++ b/Distance.TrackAttachToTrack.sln
@@ -1,11 +1,11 @@
-
+
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31515.178
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Mod.Template.Content", "Mod.Template.Content\Mod.Template.Content.shproj", "{4E7D37C7-8AFE-4F79-BAF6-4CE82D05E091}"
+Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Distance.TrackAttachToTrack.Content", "Distance.TrackAttachToTrack.Content\Distance.TrackAttachToTrack.Content.shproj", "{4E7D37C7-8AFE-4F79-BAF6-4CE82D05E091}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mod.Template", "Mod.Template\Mod.Template.csproj", "{7BCB2908-B003-45D9-BE68-50CBA5217603}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Distance.TrackAttachToTrack", "Distance.TrackAttachToTrack\Distance.TrackAttachToTrack.csproj", "{7BCB2908-B003-45D9-BE68-50CBA5217603}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{08A1C9FA-7DC2-4A60-B9A6-AC0EB7132893}"
ProjectSection(SolutionItems) = preProject
@@ -17,7 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
- Mod.Template.Content\Mod.Template.Content.projitems*{4e7d37c7-8afe-4f79-baf6-4ce82d05e091}*SharedItemsImports = 13
+ Distance.TrackAttachToTrack.Content\Distance.TrackAttachToTrack.Content.projitems*{4e7d37c7-8afe-4f79-baf6-4ce82d05e091}*SharedItemsImports = 13
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -36,3 +36,6 @@ Global
SolutionGuid = {E6970D48-CD23-4427-951B-448B144F30DA}
EndGlobalSection
EndGlobal
+
+
+
diff --git a/Distance.TrackAttachToTrack/ConfigurationLogic.cs b/Distance.TrackAttachToTrack/ConfigurationLogic.cs
new file mode 100644
index 0000000..1935ddb
--- /dev/null
+++ b/Distance.TrackAttachToTrack/ConfigurationLogic.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Reactor.API.Configuration;
+using System;
+using UnityEngine;
+
+namespace Distance.EditorAnnihilator
+{
+ public class ConfigurationLogic : MonoBehaviour
+ {
+ #region Properties
+ public bool gta
+ {
+ get => Get("gta");
+ set => Set("gta", value);
+ }
+ #endregion
+
+ internal Settings Config;
+
+ public event Action OnChanged;
+
+ private void Load()
+ {
+ Config = new Settings("Config");
+
+ }
+
+ public void Awake()
+ {
+ Load();
+ Get("gta", false);
+ Save();
+ }
+
+ public T Get(string key, T @default = default)
+ {
+ return Config.GetOrCreate(key, @default);
+ }
+
+ public void Set(string key, T value)
+ {
+ Config[key] = value;
+ Save();
+ }
+
+ public void Save()
+ {
+ Config?.Save();
+ OnChanged?.Invoke(this);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Mod.Template/Mod.Template.csproj b/Distance.TrackAttachToTrack/Distance.TrackAttachToTrack.csproj
similarity index 92%
rename from Mod.Template/Mod.Template.csproj
rename to Distance.TrackAttachToTrack/Distance.TrackAttachToTrack.csproj
index 186296c..51abdff 100644
--- a/Mod.Template/Mod.Template.csproj
+++ b/Distance.TrackAttachToTrack/Distance.TrackAttachToTrack.csproj
@@ -7,8 +7,8 @@
{7BCB2908-B003-45D9-BE68-50CBA5217603}
Library
Properties
- Mod.Template
- Mod.Template
+ Distance.TrackAttachToTrack
+ Distance.TrackAttachToTrack
v3.5
512
true
@@ -86,11 +86,15 @@
-
+
+
+
+
+
-
+
diff --git a/Distance.TrackAttachToTrack/Distance.TrackAttachToTrack.targets b/Distance.TrackAttachToTrack/Distance.TrackAttachToTrack.targets
new file mode 100644
index 0000000..574a980
--- /dev/null
+++ b/Distance.TrackAttachToTrack/Distance.TrackAttachToTrack.targets
@@ -0,0 +1,7 @@
+
+
+ Distance TrackAttachToTrack
+
+
+
+
diff --git a/Distance.TrackAttachToTrack/Entry.cs b/Distance.TrackAttachToTrack/Entry.cs
new file mode 100644
index 0000000..834d279
--- /dev/null
+++ b/Distance.TrackAttachToTrack/Entry.cs
@@ -0,0 +1,74 @@
+using Centrifuge.Distance.Game;
+using Centrifuge.Distance.GUI.Controls;
+using Centrifuge.Distance.GUI.Data;
+using Events.MainMenu;
+using Events.QuitLevelEditor;
+using Reactor.API.Attributes;
+using Reactor.API.Interfaces.Systems;
+using Reactor.API.Logging;
+using Reactor.API.Runtime.Patching;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using UnityEngine;
+
+namespace Distance.EditorAnnihilator
+{
+ [ModEntryPoint("com.github.pred/Distance.TrackAttachToTrack")]
+ public class Mod : MonoBehaviour
+ {
+ public static Mod Instance;
+
+ public IManager Manager { get; set; }
+
+ public static Log Logger { get; private set; }
+
+ public static ConfigurationLogic Config { get; private set; }
+
+ public static bool ModEnabled { get; set; }
+
+ public void Initialize(IManager manager)
+ {
+ Instance = this;
+ Logger = LogManager.GetForCurrentAssembly();
+ Manager = manager;
+ Config = gameObject.AddComponent();
+ //Events.MainMenu.Initialized.Subscribe(OnMainMenuInitialized);
+ //Events.QuitLevelEditor.Quit.Subscribe(OnMainMenuInitialized2);
+ //Events.MainMenu.Initialized.Unsubscribe(OnMainMenuInitialized);
+ //Events.MainMenu.Initialized.Broadcast(new Initialized.Data());
+ CreateSettingsMenu();
+ //GameObject lamp = new GameObject();
+ //Type lamptrans = System.Type.GetType("Transform");
+ //lamp.AddComponent(lamptrans);
+ RuntimePatcher.AutoPatch();
+ }
+
+ public void CreateSettingsMenu()
+ {
+ MenuTree settingsMenu;
+ settingsMenu = new MenuTree("menu.mod.TrackAttachToTrack", "TrackAttachToTrack Settings")
+ {
+ new CheckBox(MenuDisplayMode.MainMenu, "setting:enable_disable_trackgrouping", "ENABLE GROUPING TRACK ATTACHMENTS")
+ .WithGetter(() => Config.gta)
+ .WithSetter((x) => Config.gta = x)
+ .WithDescription("Normally, you can only group track attachments with the track they are attached to, but enabling this removes this restriction. The reason this is an option and not a default feature is that it can produce some weird effects under certain circumstances. Say you attach an object to a track, group that object, and then delete the track, and then ungroup the object. The object will then have a track attachment to a nonexistant track, which can cause the editor to freak out and crash under certain circumstances (Though you can remove it just fine if you don't try to do anything else with it first, like duplicating the object or something.).")
+ };
+
+ Menus.AddNew(MenuDisplayMode.Both, settingsMenu, "TrackAttachToTrack", "Settings for the TrackAttachToTrack mod.");
+ }
+
+ public static bool GTA => Config.gta;
+
+ private void OnMainMenuInitialized(Initialized.Data data)
+ {
+ Resource.CreateLevelEditorPrefabDirInfo();
+ }
+
+ private void OnMainMenuInitialized2(Quit.Data data)
+ {
+ Resource.CreateResourceList();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Distance.TrackAttachToTrack/Harmony/Assembly-CSharp/AttachTrackToTrack/Run.cs b/Distance.TrackAttachToTrack/Harmony/Assembly-CSharp/AttachTrackToTrack/Run.cs
new file mode 100644
index 0000000..be5307c
--- /dev/null
+++ b/Distance.TrackAttachToTrack/Harmony/Assembly-CSharp/AttachTrackToTrack/Run.cs
@@ -0,0 +1,56 @@
+
+
+using System;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HarmonyLib;
+using LevelEditorTools;
+using UnityEngine;
+using LevelEditorActions;
+
+namespace Distance.EditorAnnihilator.Harmony
+{
+ [HarmonyPatch(typeof(GroupTool), "Run")]
+ internal static class GroupTool__Run
+ {
+ //__instance is the class you are patching, so you can call functions on it.
+ //If patching a function with paramaters, you can just add those paramaters as paramaters inside Postfix.
+ //If the function you're patching has a return type, you can modify the result value with the parameter 'ref [type of return value] __result'
+ [HarmonyPrefix]
+ internal static bool Prefix(ref bool __result, GroupTool __instance)
+ {
+ if(Mod.GTA)
+ {
+ LevelEditor levelEditor = G.Sys.LevelEditor_;
+ GameObject[] array = levelEditor.SelectedNonTrackNodeAndNonOnlyAllowOneObjects_.ToArray();
+ if (array.Length < 1)
+ {
+ LevelEditorTool.PrintErrorMessage("Requires at least 1 object to group.");
+ __result = false;
+ return false;
+ }
+ GroupAction groupAction = Group.CreateGroupAction(array, levelEditor.ActiveObject_);
+ GameObject gameObject = groupAction.GroupObjects().gameObject;
+ if ((UnityEngine.Object)gameObject != (UnityEngine.Object)null)
+ {
+ levelEditor.ClearSelectedList();
+ levelEditor.SelectObject(gameObject);
+ groupAction.FinishAndAddToLevelEditorActions();
+ LevelEditorTool.PrintFormattedCountMessage("Grouped {0} object{1}.", array.Length);
+ __result = true;
+ return false;
+ }
+ Debug.LogError((object)"Grouping failed");
+ __result = false;
+ return false;
+ }
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Distance.TrackAttachToTrack/Harmony/Assembly-CSharp/AttachTrackToTrack/TrackToTrackButton.cs b/Distance.TrackAttachToTrack/Harmony/Assembly-CSharp/AttachTrackToTrack/TrackToTrackButton.cs
new file mode 100644
index 0000000..9c716e0
--- /dev/null
+++ b/Distance.TrackAttachToTrack/Harmony/Assembly-CSharp/AttachTrackToTrack/TrackToTrackButton.cs
@@ -0,0 +1,129 @@
+using Centrifuge.Distance.EditorTools.Attributes;
+using LevelEditorActions;
+using LevelEditorTools;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using UnityEngine;
+
+namespace Distance.TrackAttachToTrack.Harmony
+{
+ [EditorTool, KeyboardShortcut("CTRL+SHIFT+A")]
+ public class TrackAttachToTrackTool : InstantTool
+ {
+ internal static ToolInfo info_ => new ToolInfo("TrackAttachToTrackTool", "Attaches selected objects to the first Track Segment selected.\nIf any selected objects are attached, they will be detached, and none will be attached.\nObjects containing track CAN be attached to the track.", ToolCategory.Track, ToolButtonState.Button, true, 1120);
+ public override ToolInfo Info_ => info_;
+
+ // Required by distance itself
+ public static void Register()
+ {
+ if (!G.Sys.LevelEditor_.registeredToolsNamesToTypes_.ContainsKey(info_.Name_))
+ G.Sys.LevelEditor_.RegisterTool(info_);
+ }
+
+ public override bool Run()
+ {
+
+ List possibleAttachments;
+ List possibleParents;
+ this.DetermineSelectedSegmentsAndObjects(out possibleAttachments, out possibleParents);
+ if (possibleAttachments.Count == 0)
+ {
+ LevelEditorTool.PrintErrorMessage("Need to select at least 1 non-track object to attach to the track");
+ return false;
+ }
+ if (possibleParents.Count == 0)
+ {
+ LevelEditorTool.PrintErrorMessage("No segment found to attach to.");
+ return false;
+ }
+ List levelEditorActionList = new List();
+ foreach (GameObject gameObject in possibleAttachments)
+ {
+ int nearestSubsegmentIndex;
+ TrackSegment nearestSegment = this.FindNearestSegment(possibleParents, gameObject.transform.position, out nearestSubsegmentIndex);
+ if ((UnityEngine.Object)nearestSegment != (UnityEngine.Object)null)
+ levelEditorActionList.Add((ILevelEditorAction)new AttachToTrackAction(nearestSegment, gameObject, nearestSubsegmentIndex));
+ }
+ ILevelEditorAction ifNecessary = CompositeAction.CreateIfNecessary((ICollection)levelEditorActionList);
+ if (ifNecessary != null)
+ {
+ ifNecessary.Redo();
+ ifNecessary.FinishAndAddToLevelEditorActions();
+ }
+ LevelEditorTool.PrintFormattedCountMessage("{0} object{1} attached.", levelEditorActionList.Count);
+ return true;
+ }
+
+ private void DetermineSelectedSegmentsAndObjects(
+ out List possibleAttachments,
+ out List possibleParents)
+ {
+ possibleAttachments = new List();
+ possibleParents = new List();
+ List trackSegmentList = new List();
+ int trackcount = 0;
+ foreach (GameObject selectedObject in G.Sys.LevelEditor_.SelectedObjects_)
+ {
+ trackSegmentList.Clear();
+ TrackLinkParent component = selectedObject.GetComponent();
+ if ((UnityEngine.Object)component != (UnityEngine.Object)null)
+ component.GetContainedSegments((ICollection)trackSegmentList);
+ if (trackSegmentList.Count > 0 && trackcount != 1)
+ {
+ possibleParents.AddRange((IEnumerable)trackSegmentList);
+ trackcount = 1;
+ }
+ else if (true)
+ possibleAttachments.Add(selectedObject);
+ }
+ if (possibleAttachments.Count == 0 || possibleParents.Count != 0)
+ return;
+ foreach (TrackSegment trackSegment in UnityEngine.Object.FindObjectsOfType())
+ possibleParents.Add(trackSegment);
+ }
+
+ private static bool CanAttachToTrack(GameObject gameObject) => !gameObject.HasComponent() && !gameObject.HasComponent();
+
+ private bool TryDetachSelectedObjects()
+ {
+ List levelEditorActionList = new List();
+ foreach (GameObject selectedObject in G.Sys.LevelEditor_.SelectedObjects_)
+ {
+ TrackAttachment component = selectedObject.GetComponent();
+ if ((UnityEngine.Object)component != (UnityEngine.Object)null)
+ levelEditorActionList.Add((ILevelEditorAction)new DetachFromTrackAction(component));
+ }
+ ILevelEditorAction ifNecessary = CompositeAction.CreateIfNecessary((ICollection)levelEditorActionList);
+ if (ifNecessary == null)
+ return false;
+ ifNecessary.Redo();
+ ifNecessary.FinishAndAddToLevelEditorActions();
+ LevelEditorTool.PrintFormattedCountMessage("{0} object{1} detached.", levelEditorActionList.Count);
+ return true;
+ }
+
+ private TrackSegment FindNearestSegment(
+ List segments,
+ Vector3 pos,
+ out int nearestSubsegmentIndex)
+ {
+ TrackSegment trackSegment = (TrackSegment)null;
+ nearestSubsegmentIndex = -1;
+ float num = float.MaxValue;
+ foreach (TrackSegment segment in segments)
+ {
+ float estDistSq;
+ int nearestSubsegmentIndex1 = segment.GetNearestSubsegmentIndex(pos, out estDistSq);
+ if ((double)estDistSq < (double)num)
+ {
+ nearestSubsegmentIndex = nearestSubsegmentIndex1;
+ trackSegment = segment;
+ num = estDistSq;
+ }
+ }
+ return trackSegment;
+ }
+ }
+}
diff --git a/Distance.TrackAttachToTrack/Harmony/Assembly-CSharp/AttachTrackToTrack/TrackToTrackSButton.cs b/Distance.TrackAttachToTrack/Harmony/Assembly-CSharp/AttachTrackToTrack/TrackToTrackSButton.cs
new file mode 100644
index 0000000..197ade2
--- /dev/null
+++ b/Distance.TrackAttachToTrack/Harmony/Assembly-CSharp/AttachTrackToTrack/TrackToTrackSButton.cs
@@ -0,0 +1,129 @@
+using Centrifuge.Distance.EditorTools.Attributes;
+using LevelEditorActions;
+using LevelEditorTools;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using UnityEngine;
+
+namespace Distance.TrackAttachToTrack.Harmony
+{
+ [EditorTool, KeyboardShortcut("SHIFT+ALT+A")]
+ public class TrackAttachToTrackToolS : InstantTool
+ {
+ internal static ToolInfo info_ => new ToolInfo("TrackAttachToTrackTool+", "Attaches selected objects to the first Track Segment selected.\nNever detatches.\nObjects containing track CAN be attached to the track.", ToolCategory.Track, ToolButtonState.Button, true, 1120);
+
+ public override ToolInfo Info_ => info_;
+
+ // Required by distance itself
+ public static void Register()
+ {
+ if (!G.Sys.LevelEditor_.registeredToolsNamesToTypes_.ContainsKey(info_.Name_))
+ G.Sys.LevelEditor_.RegisterTool(info_);
+ }
+
+ public override bool Run()
+ {
+ List possibleAttachments;
+ List possibleParents;
+ this.DetermineSelectedSegmentsAndObjects(out possibleAttachments, out possibleParents);
+ if (possibleAttachments.Count == 0)
+ {
+ LevelEditorTool.PrintErrorMessage("Need to select at least 1 non-track object to attach to the track");
+ return false;
+ }
+ if (possibleParents.Count == 0)
+ {
+ LevelEditorTool.PrintErrorMessage("No segment found to attach to.");
+ return false;
+ }
+ List levelEditorActionList = new List();
+ foreach (GameObject gameObject in possibleAttachments)
+ {
+ int nearestSubsegmentIndex;
+ TrackSegment nearestSegment = this.FindNearestSegment(possibleParents, gameObject.transform.position, out nearestSubsegmentIndex);
+ if ((UnityEngine.Object)nearestSegment != (UnityEngine.Object)null)
+ levelEditorActionList.Add((ILevelEditorAction)new AttachToTrackAction(nearestSegment, gameObject, nearestSubsegmentIndex));
+ }
+ ILevelEditorAction ifNecessary = CompositeAction.CreateIfNecessary((ICollection)levelEditorActionList);
+ if (ifNecessary != null)
+ {
+ ifNecessary.Redo();
+ ifNecessary.FinishAndAddToLevelEditorActions();
+ }
+ LevelEditorTool.PrintFormattedCountMessage("{0} object{1} attached.", levelEditorActionList.Count);
+ return true;
+ }
+
+ private void DetermineSelectedSegmentsAndObjects(
+ out List possibleAttachments,
+ out List possibleParents)
+ {
+ possibleAttachments = new List();
+ possibleParents = new List();
+ List trackSegmentList = new List();
+ int trackcount = 0;
+ foreach (GameObject selectedObject in G.Sys.LevelEditor_.SelectedObjects_)
+ {
+ trackSegmentList.Clear();
+ TrackLinkParent component = selectedObject.GetComponent();
+ if ((UnityEngine.Object)component != (UnityEngine.Object)null)
+ component.GetContainedSegments((ICollection)trackSegmentList);
+ if (trackSegmentList.Count > 0 && trackcount != 1)
+ {
+ possibleParents.AddRange((IEnumerable)trackSegmentList);
+ trackcount = 1;
+ }
+ else if (true)
+ possibleAttachments.Add(selectedObject);
+ }
+ if (possibleAttachments.Count == 0 || possibleParents.Count != 0)
+ return;
+ foreach (TrackSegment trackSegment in UnityEngine.Object.FindObjectsOfType())
+ possibleParents.Add(trackSegment);
+ }
+
+ private static bool CanAttachToTrack(GameObject gameObject) => !gameObject.HasComponent() && !gameObject.HasComponent();
+
+ private bool TryDetachSelectedObjects()
+ {
+ List levelEditorActionList = new List();
+ foreach (GameObject selectedObject in G.Sys.LevelEditor_.SelectedObjects_)
+ {
+ TrackAttachment component = selectedObject.GetComponent();
+ if ((UnityEngine.Object)component != (UnityEngine.Object)null)
+ levelEditorActionList.Add((ILevelEditorAction)new DetachFromTrackAction(component));
+ }
+ ILevelEditorAction ifNecessary = CompositeAction.CreateIfNecessary((ICollection)levelEditorActionList);
+ if (ifNecessary == null)
+ return false;
+ ifNecessary.Redo();
+ ifNecessary.FinishAndAddToLevelEditorActions();
+ LevelEditorTool.PrintFormattedCountMessage("{0} object{1} detached.", levelEditorActionList.Count);
+ return true;
+ }
+
+ private TrackSegment FindNearestSegment(
+ List segments,
+ Vector3 pos,
+ out int nearestSubsegmentIndex)
+ {
+ TrackSegment trackSegment = (TrackSegment)null;
+ nearestSubsegmentIndex = -1;
+ float num = float.MaxValue;
+ foreach (TrackSegment segment in segments)
+ {
+ float estDistSq;
+ int nearestSubsegmentIndex1 = segment.GetNearestSubsegmentIndex(pos, out estDistSq);
+ if ((double)estDistSq < (double)num)
+ {
+ nearestSubsegmentIndex = nearestSubsegmentIndex1;
+ trackSegment = segment;
+ num = estDistSq;
+ }
+ }
+ return trackSegment;
+ }
+ }
+}
diff --git a/Mod.Template/Properties/AssemblyInfo.cs b/Distance.TrackAttachToTrack/Properties/AssemblyInfo.cs
similarity index 89%
rename from Mod.Template/Properties/AssemblyInfo.cs
rename to Distance.TrackAttachToTrack/Properties/AssemblyInfo.cs
index 2ff0ed0..1760e87 100644
--- a/Mod.Template/Properties/AssemblyInfo.cs
+++ b/Distance.TrackAttachToTrack/Properties/AssemblyInfo.cs
@@ -1,15 +1,15 @@
-using System.Reflection;
+using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
-[assembly: AssemblyTitle("Distance.ModTemplate")]
+[assembly: AssemblyTitle("Distance.TrackAttachToTrack")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Distance.ModTemplate")]
+[assembly: AssemblyProduct("Distance.TrackAttachToTrack")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -34,3 +34,6 @@
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+
+
+
diff --git a/Mod.Template/packages.config b/Distance.TrackAttachToTrack/packages.config
similarity index 100%
rename from Mod.Template/packages.config
rename to Distance.TrackAttachToTrack/packages.config
diff --git a/Mod.Template.Content/Mod/mod.json b/Mod.Template.Content/Mod/mod.json
deleted file mode 100644
index 6fe0e0f..0000000
--- a/Mod.Template.Content/Mod/mod.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "FriendlyName": "Mod Template",
- "Author": "You",
- "Contact": "N/A",
- "ModuleFileName": "Mod.Template.dll",
- "Dependencies": [],
- "RequiredGSLs": [
- "com.github.reherc/Centrifuge.Distance"
- ],
- "SkipLoad": false,
- "Priority": 10
-}
\ No newline at end of file
diff --git a/Mod.Template/Mod.Template.targets b/Mod.Template/Mod.Template.targets
deleted file mode 100644
index fc29990..0000000
--- a/Mod.Template/Mod.Template.targets
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- Distance Mod Template
-
-
\ No newline at end of file
diff --git a/Mod.Template/Mod.cs b/Mod.Template/Mod.cs
deleted file mode 100644
index a08b398..0000000
--- a/Mod.Template/Mod.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using Reactor.API.Attributes;
-using Reactor.API.Interfaces.Systems;
-using Reactor.API.Logging;
-using Reactor.API.Runtime.Patching;
-using UnityEngine;
-
-namespace Distance.ModTemplate
-{
- ///
- /// The mod's main class containing its entry point
- ///
- [ModEntryPoint("")]
- public sealed class Mod : MonoBehaviour
- {
- public static Mod Instance { get; private set; }
-
- public IManager Manager { get; private set; }
-
- public Log Logger { get; private set; }
-
- ///
- /// Method called as soon as the mod is loaded.
- /// WARNING: Do not load asset bundles/textures in this function
- /// The unity assets systems are not yet loaded when this
- /// function is called. Loading assets here can lead to
- /// unpredictable behaviour and crashes!
- ///
- public void Initialize(IManager manager)
- {
- // Do not destroy the current game object when loading a new scene
- DontDestroyOnLoad(this);
-
- Instance = this;
-
- Manager = manager;
-
- // Create a log file
- Logger = LogManager.GetForCurrentAssembly();
-
- Logger.Info("Hello World!");
-
- RuntimePatcher.AutoPatch();
- }
-
- ///
- /// Method called after
- /// GameManager.Start()
- /// This initialisation method is the same as
- /// the Spectrum mod loader initialisation procedure.
- ///
- public void LateInitialize(IManager manager)
- {
- // Code here...
- Initialize(manager);
- }
- }
-}
diff --git a/README.md b/README.md
index 89f2589..92323cf 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,6 @@
-# Distance mod template
+# Distance TrackAttachToTrack
-Use this repository as a base to create your own Distance mods.
-
-# Using the template
-On github, click the `Use this template` button to create a new repository based on this one
-
-Once the repository is created, be sure to clone it locally **with submodules**:
-```sh
-git clone --recurse-submodules -j8
-```
-
-# Setting up the project
-After cloning the repository on your local drive, run the [setup.ps1](setup.ps1) script using [PowerShell 7 or higher](https://github.com/PowerShell/PowerShell#get-powershell).
-
-This script will rename the files correctly and replace their content to match your mod name.
\ No newline at end of file
+## Features:
+-TrackAttachToTrackTool (Shortcut Ctrl+Shift+A.), which attaches all selected objects to the first spline selected. Even other splines. Detatches when an attached object is selected.
+-TrackAttachToTrackTool+ (Shortcut Ctrl+Alt+A.), which attaches all selected objects to the first spline selected. Even other splines. Never detaches, so can be used to attach 2 splines to eachother, for example.
+-An option to enable the ability to group track attachments to objects that aren't the track they are attached to (But it is disabled by default.). Normally, you can only group track attachments with the track they are attached to, but enabling this removes this restriction. The reason this is an option and not a default feature is that it can produce some weird effects under certain circumstances. Say you attach an object to a track, group that object, and then delete the track, and then ungroup the object. The object will then have a track attachment to a nonexistant track, which can cause the editor to freak out and crash under certain circumstances (Though you can remove it just fine if you don't try to do anything else with it first, like duplicating the object or something.). It's not unstable so long as you don't put it in such a position though.
\ No newline at end of file
diff --git a/setup.ps1 b/setup.ps1
deleted file mode 100644
index 0343983..0000000
--- a/setup.ps1
+++ /dev/null
@@ -1,97 +0,0 @@
-Set-Variable Source -Option Constant -Value $MyInvocation.MyCommand.Definition;
-Set-Variable ValidationRegex -Option Constant -Value "^([a-zA-Z]+([ ]?[a-zA-Z0-9])*)\r?$";
-
-$Extensions = ".txt", ".json", ".env", ".sln", ".proj", ".csproj", ".vbproj", ".shproj", ".projitems", ".cs", ".vb", ".targets", ".props";
-
-Class ProjectInfo {
- [string]$Namespace;
- [string]$Title;
-
- ProjectInfo([string]$namespace, [string]$title) {
- $this.Namespace = $namespace;
- $this.Title = $title;
- }
-}
-
-Function Read-ProjectInfo {
- [OutputType([ProjectInfo])]
- Param ()
-
- Write-Host "Enter a new project name to setup your mod (Example: 'My First Mod').";
- Write-Host "In order to be valid, a name must respect the following rules:";
- Write-Host "- The project name can't begin with a number";
- Write-Host "- The project name can't start or end with one or more spaces";
- Write-Host "- The name can't contain a series of more than 1 consecutive space character";
- Write-Host "- Words must be composed only of (latin) letters and numbers (a-zA-Z0-9)";
- Write-Host "- Any special characters are not allowed (@#-.;:/!§,?%=+* ...)";
- Write-Host "";
- Write-Host "The program will prompt you to type a name until it is a valid one.";
- Write-Host "To exit it, press CTRL + C";
- Write-Host "";
-
- Do {
- $ProjectName = Read-Host -Prompt "Enter project name";
- }
- Until ($ProjectName -match $ValidationRegex);
-
- Return [ProjectInfo]::new("Distance." + $ProjectName.Replace(" ", ""), "Distance " + $ProjectName);
-}
-
-Function Rename-Files {
- Param ([string]$Find, [string]$Replace)
-
- Rename-Items -Find $Find -Replace $Replace -Attributes "Directory";
- Rename-Items -Find $Find -Replace $Replace -Attributes "!Directory";
- Write-FilesContent -Find $Find -Replace $Replace
-}
-
-Function Rename-Items {
- Param ([string]$Find, [string]$Replace, [string]$Attributes)
- $Items = Get-ChildItem -Attributes $Attributes -Recurse | Where-Object -FilterScript {$_.FullName -Ne $Source};
-
- ForEach ($Item in $Items) {
- If ($Item.Name.Contains($Find)) {
- Rename-Item -Path $Item.PSPath -NewName $Item.Name.Replace($Find, $Replace);
- }
- }
-}
-
-Function Write-FilesContent {
- Param ([string]$Find, [string]$Replace)
-
- $Files = Get-ChildItem -File -Recurse | Where-Object -FilterScript {$_.FullName -Ne $Source -And $Extensions.Contains($_.Extension.ToLower())};
-
- ForEach ($File in $Files) {
- $Content = (Get-Content -Path $File.FullName -Encoding utf8 -Raw).Replace($Find, $Replace);
- Set-Content -Path $File.FullName -Value $Content -Encoding utf8;
- }
-}
-
-Function Remove-Script {
- [OutputType([bool])]
- Param ()
-
- $Yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Remove this powershell script from the disk.";
- $No = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "Keep this powershell script on the disk.";
-
- $Options = [System.Management.Automation.Host.ChoiceDescription[]]($Yes, $No);
-
- $ChoiceResult = $Host.Ui.PromptForChoice("Setup complete!", "Do you want to delete this powershell script?", $Options, 0);
-
- Return $ChoiceResult -Eq 0;
-}
-
-Function Init {
- [ProjectInfo]$Info = Read-ProjectInfo;
-
- Rename-Files -Find "Mod.Template" -Replace $Info.Namespace;
- Rename-Files -Find "Distance.ModTemplate" -Replace $Info.Namespace;
- Rename-Files -Find "Mod Template" -Replace $Info.Title;
-
- [bool]$RemoveFiles = Remove-Script;
- If ($RemoveFiles) {
- Remove-Item -Path "$Source" -Force
- }
-}
-
-Init;
\ No newline at end of file