This repository has been archived by the owner on Jan 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unfinished port of the trackmusic mod from corecii
- Loading branch information
Showing
23 changed files
with
451 additions
and
55 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
Binary file not shown.
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
This file was deleted.
Oops, something went wrong.
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,11 @@ | ||
using UnityEngine; | ||
|
||
namespace Distance.TrackMusic.Editor.Tools | ||
{ | ||
public class AddMusicChoiceAction : AddOrRemoveMusicChoiceAction | ||
{ | ||
public AddMusicChoiceAction(GameObject obj) : base(obj, null) { } | ||
|
||
public override string Description_ => "Added Music Choice to object"; | ||
} | ||
} |
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,48 @@ | ||
using Centrifuge.Distance.EditorTools.Attributes; | ||
using LevelEditorActions; | ||
using LevelEditorTools; | ||
using UnityEngine; | ||
|
||
namespace Distance.TrackMusic.Editor.Tools | ||
{ | ||
[EditorTool] | ||
public class AddMusicChoiceTool : InstantTool | ||
{ | ||
public static ToolInfo info_ = new ToolInfo("Add Music Choice", "", ToolCategory.Others, ToolButtonState.Invisible, false); | ||
public override ToolInfo Info_ => info_; | ||
|
||
public static GameObject[] Target = new GameObject[0]; | ||
|
||
public static void Register() | ||
{ | ||
G.Sys.LevelEditor_.RegisterTool(info_); | ||
} | ||
|
||
public override bool Run() | ||
{ | ||
GameObject[] selected = Target; | ||
|
||
if (selected.Length == 0) | ||
{ | ||
return false; | ||
} | ||
|
||
foreach (var obj in selected) | ||
{ | ||
if (obj.HasComponent<LevelSettings>() || obj.HasComponent<MusicTrigger>() || obj.HasComponent<MusicZone>()) | ||
{ | ||
var listener = obj.GetComponent<ZEventListener>(); | ||
|
||
if (listener == null) | ||
{ | ||
var action = new AddMusicChoiceAction(obj); | ||
action.Redo(); | ||
action.FinishAndAddToLevelEditorActions(); | ||
} | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
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,66 @@ | ||
using Distance.TrackMusic.Models; | ||
using LevelEditorActions; | ||
using UnityEngine; | ||
|
||
namespace Distance.TrackMusic.Editor.Tools | ||
{ | ||
public class AddMusicTrackAction : SimplerAction | ||
{ | ||
public override string Description_ => "Add Music Track"; | ||
|
||
public ReferenceMap.Handle<GameObject> objectHandle; | ||
|
||
public GameObject CreateTrack() | ||
{ | ||
GameObject gameObject = Resource.LoadPrefabInstance("Group", true); | ||
|
||
gameObject.GetComponent<CustomName>().customName_ = "Music Track"; | ||
|
||
var component = gameObject.AddComponent<ZEventListener>(); | ||
|
||
var track = new MusicTrack() { Name = "Unknown" }; | ||
|
||
track.NewVersion(); | ||
|
||
track.WriteObject(component); | ||
|
||
gameObject.ForEachILevelEditorListener(delegate (ILevelEditorListener listener) | ||
{ | ||
listener.LevelEditorStart(true); | ||
}); | ||
|
||
MonoBehaviour[] components = gameObject.GetComponents<MonoBehaviour>(); | ||
|
||
foreach (MonoBehaviour monoBehaviour in components) | ||
{ | ||
monoBehaviour.enabled = false; | ||
} | ||
|
||
LevelEditor editor = G.Sys.LevelEditor_; | ||
|
||
editor.AddGameObjectSilent(ref objectHandle, gameObject, null); | ||
|
||
return gameObject; | ||
} | ||
|
||
public void DestroyTrack() | ||
{ | ||
GameObject gameObject = objectHandle.Get(); | ||
if (gameObject == null) | ||
{ | ||
return; | ||
} | ||
G.Sys.LevelEditor_.RemoveGameObjectSilent(gameObject); | ||
} | ||
|
||
public override void Undo() | ||
{ | ||
DestroyTrack(); | ||
} | ||
|
||
public override void Redo() | ||
{ | ||
CreateTrack(); | ||
} | ||
} | ||
} |
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,37 @@ | ||
using Centrifuge.Distance.EditorTools.Attributes; | ||
using LevelEditorActions; | ||
using LevelEditorTools; | ||
using UnityEngine; | ||
|
||
namespace Distance.TrackMusic.Editor.Tools | ||
{ | ||
[EditorTool] | ||
public class AddMusicTrackTool : InstantTool | ||
{ | ||
public static ToolInfo info_ = new ToolInfo("Add Music Track", "", ToolCategory.Edit, ToolButtonState.Button, false); | ||
|
||
public override ToolInfo Info_ => info_; | ||
|
||
public static void Register() | ||
{ | ||
G.Sys.LevelEditor_.RegisterTool(info_); | ||
} | ||
|
||
public override bool Run() | ||
{ | ||
LevelEditor editor = G.Sys.LevelEditor_; | ||
|
||
var action = new AddMusicTrackAction(); | ||
|
||
GameObject gameObject = action.CreateTrack(); | ||
|
||
editor.ClearSelectedList(true); | ||
|
||
editor.SelectObject(gameObject); | ||
|
||
action.FinishAndAddToLevelEditorActions(); | ||
|
||
return true; | ||
} | ||
} | ||
} |
Oops, something went wrong.