Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
Unfinished port of the trackmusic mod from corecii
Browse files Browse the repository at this point in the history
  • Loading branch information
REHERC committed Jul 29, 2020
1 parent dc16dc1 commit 87a54e0
Show file tree
Hide file tree
Showing 23 changed files with 451 additions and 55 deletions.
1 change: 0 additions & 1 deletion Centrifuge.Mods.Distance.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Distance.Assemblies", "Distance.Assemblies", "{83201AB6-55D6-472B-98F8-BA11061CC2EA}"
ProjectSection(SolutionItems) = preProject
Distance.Assemblies\Assembly-CSharp-firstpass.dll = Distance.Assemblies\Assembly-CSharp-firstpass.dll
Distance.Assemblies\Assembly-CSharp.dev.dll = Distance.Assemblies\Assembly-CSharp.dev.dll
EndProjectSection
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Distance.Shared", "Distance.Shared\Distance.Shared.shproj", "{15B08B61-BEB4-40A6-8789-02B655A4B307}"
Expand Down
Binary file removed Distance.Assemblies/Assembly-CSharp.dev.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
23 changes: 11 additions & 12 deletions Distance.TextureModifier/Distance.TextureModifier.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<Deterministic>true</Deterministic>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -38,21 +39,20 @@
<Reference Include="0Harmony, Version=1.2.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lib.Harmony.1.2.0.1\lib\net35\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp, Version=9.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.18\lib\net35\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\Distance.Assemblies\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp.dev, Version=9.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Distance.Assemblies\Assembly-CSharp.dev.dll</HintPath>
</Reference>
<Reference Include="Centrifuge.Distance, Version=1.0.12.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.12\lib\net35\Centrifuge.Distance.dll</HintPath>
<Reference Include="Centrifuge.Distance, Version=1.0.18.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.18\lib\net35\Centrifuge.Distance.dll</HintPath>
</Reference>
<Reference Include="LitJSON, Version=0.15.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\LitJson.0.15.0\lib\net35\LitJSON.dll</HintPath>
</Reference>
<Reference Include="NAudio, Version=1.7.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.12\lib\net35\NAudio.dll</HintPath>
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.18\lib\net35\NAudio.dll</HintPath>
</Reference>
<Reference Include="Reactor.API, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Centrifuge.Mod.SDK.2.2.0\lib\net35\Reactor.API.dll</HintPath>
Expand All @@ -64,18 +64,18 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.12\lib\net35\UnityEngine.dll</HintPath>
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.18\lib\net35\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.Networking, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.12\lib\net35\UnityEngine.Networking.dll</HintPath>
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.18\lib\net35\UnityEngine.Networking.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.12\lib\net35\UnityEngine.UI.dll</HintPath>
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.18\lib\net35\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Declarations.cs" />
<Compile Include="Mod.cs" />
<Compile Include="Entry.cs" />
<Compile Include="Harmony\Assembly-CSharp\Resource\LoadPrefab.cs" />
<Compile Include="Harmony\Assembly-CSharp\Resource\LoadLevelPreviewTexture.cs" />
<Compile Include="Harmony\Assembly-CSharp\Resource\LoadTextureFromFile.cs" />
Expand All @@ -84,7 +84,6 @@
<Compile Include="TextureLoader.cs" />
</ItemGroup>
<ItemGroup>
<None Include="mod.json" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ internal IEnumerator ReskinResourcePrefabs()

yield break;
}

internal IEnumerator ReskinLevelObjects(Level level)
{
List<GameObject> objects = new List<GameObject>();
Expand Down Expand Up @@ -161,7 +161,7 @@ internal IEnumerator Reskin(List<GameObject> list, bool pause = false)

//if (!pause)
//{
yield return StartCoroutine(Reskin(list, true));
yield return StartCoroutine(Reskin(list, true));
//}

yield break;
Expand Down
12 changes: 0 additions & 12 deletions Distance.TextureModifier/mod.json

This file was deleted.

2 changes: 1 addition & 1 deletion Distance.TextureModifier/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Centrifuge.GameSupport.Distance" version="1.0.12" targetFramework="net35" />
<package id="Centrifuge.GameSupport.Distance" version="1.0.18" targetFramework="net35" />
<package id="Centrifuge.Mod.SDK" version="2.2.0" targetFramework="net35" />
<package id="Lib.Harmony" version="1.2.0.1" targetFramework="net35" />
<package id="LitJson" version="0.15.0" targetFramework="net35" />
Expand Down
29 changes: 19 additions & 10 deletions Distance.TrackMusic/Distance.TrackMusic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@
<Reference Include="0Harmony, Version=1.2.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lib.Harmony.1.2.0.1\lib\net35\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp, Version=9.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.18\lib\net35\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>..\Distance.Assemblies\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp.dev">
<HintPath>..\Distance.Assemblies\Assembly-CSharp.dev.dll</HintPath>
</Reference>
<Reference Include="Centrifuge.Distance, Version=1.0.12.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.12\lib\net35\Centrifuge.Distance.dll</HintPath>
<Reference Include="Centrifuge.Distance, Version=1.0.18.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.18\lib\net35\Centrifuge.Distance.dll</HintPath>
</Reference>
<Reference Include="LitJSON, Version=0.15.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\LitJson.0.15.0\lib\net35\LitJSON.dll</HintPath>
</Reference>
<Reference Include="NAudio, Version=1.7.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.12\lib\net35\NAudio.dll</HintPath>
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.18\lib\net35\NAudio.dll</HintPath>
</Reference>
<Reference Include="Reactor.API, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Centrifuge.Mod.SDK.2.2.0\lib\net35\Reactor.API.dll</HintPath>
Expand All @@ -62,17 +62,26 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.12\lib\net35\UnityEngine.dll</HintPath>
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.18\lib\net35\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.Networking, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.12\lib\net35\UnityEngine.Networking.dll</HintPath>
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.18\lib\net35\UnityEngine.Networking.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.12\lib\net35\UnityEngine.UI.dll</HintPath>
<HintPath>..\packages\Centrifuge.GameSupport.Distance.1.0.18\lib\net35\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ConfigurationLogic.cs" />
<Compile Include="Editor\Tools\AddMusicChoiceAction.cs" />
<Compile Include="Editor\Tools\AddMusicChoiceTool.cs" />
<Compile Include="Editor\Tools\AddMusicTrackAction.cs" />
<Compile Include="Editor\Tools\AddMusicTrackTool.cs" />
<Compile Include="Editor\Tools\AddOrRemoveMusicChoiceAction.cs" />
<Compile Include="Editor\Tools\RemoveMusicChoiceAction.cs" />
<Compile Include="Editor\Tools\RemoveMusicChoiceTool.cs" />
<Compile Include="Editor\Tools\ToggleMusicAction.cs" />
<Compile Include="Editor\Tools\ToggleMusicTool.cs" />
<Compile Include="Harmony\Assembly-CSharp\AudioEventTrigger\PlayMusic.cs" />
<Compile Include="Harmony\Assembly-CSharp\AudioManager\Awake.cs" />
<Compile Include="Harmony\Assembly-CSharp\AudioManager\OnEventPostLoad.cs" />
Expand All @@ -94,7 +103,7 @@
<Compile Include="Harmony\Assembly-CSharp\ZEventListener\Visit-MusicChoice.cs" />
<Compile Include="Harmony\Assembly-CSharp\ZEventListener\Visit-MusicTrack.cs" />
<Compile Include="LevelEditorLogic.cs" />
<Compile Include="Mod.cs" />
<Compile Include="Entry.cs" />
<Compile Include="Models\AttachedData.cs" />
<Compile Include="Models\CustomData.cs" />
<Compile Include="Models\CustomDataInfo.cs" />
Expand Down
11 changes: 11 additions & 0 deletions Distance.TrackMusic/Editor/Tools/AddMusicChoiceAction.cs
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";
}
}
48 changes: 48 additions & 0 deletions Distance.TrackMusic/Editor/Tools/AddMusicChoiceTool.cs
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;
}
}
}
66 changes: 66 additions & 0 deletions Distance.TrackMusic/Editor/Tools/AddMusicTrackAction.cs
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();
}
}
}
37 changes: 37 additions & 0 deletions Distance.TrackMusic/Editor/Tools/AddMusicTrackTool.cs
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;
}
}
}
Loading

0 comments on commit 87a54e0

Please sign in to comment.