generated from Distance-Modding/Template.CSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9fef654
commit 1cc6f4f
Showing
19 changed files
with
502 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
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. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"FriendlyName": "TrackAttachToTrack", | ||
"Author": "PB", | ||
"Contact": "( .-.)", | ||
"ModuleFileName": "Distance.TrackAttachToTrack.dll", | ||
"Dependencies": [], | ||
"SkipLoad": false, | ||
"Priority": 10, | ||
"RequiredGSLs": [ | ||
"com.github.reherc/Centrifuge.Distance" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<bool>("gta"); | ||
set => Set("gta", value); | ||
} | ||
#endregion | ||
|
||
internal Settings Config; | ||
|
||
public event Action<ConfigurationLogic> OnChanged; | ||
|
||
private void Load() | ||
{ | ||
Config = new Settings("Config"); | ||
|
||
} | ||
|
||
public void Awake() | ||
{ | ||
Load(); | ||
Get("gta", false); | ||
Save(); | ||
} | ||
|
||
public T Get<T>(string key, T @default = default) | ||
{ | ||
return Config.GetOrCreate(key, @default); | ||
} | ||
|
||
public void Set<T>(string key, T value) | ||
{ | ||
Config[key] = value; | ||
Save(); | ||
} | ||
|
||
public void Save() | ||
{ | ||
Config?.Save(); | ||
OnChanged?.Invoke(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
Distance.TrackAttachToTrack/Distance.TrackAttachToTrack.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<ModName>Distance TrackAttachToTrack</ModName> | ||
</PropertyGroup> | ||
</Project> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ConfigurationLogic>(); | ||
//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(); | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
Distance.TrackAttachToTrack/Harmony/Assembly-CSharp/AttachTrackToTrack/Run.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
Oops, something went wrong.