-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from Auros/auros/sandrie
Update for SiraUtil 3
- Loading branch information
Showing
24 changed files
with
237 additions
and
293 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
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 |
---|---|---|
@@ -1,29 +1,13 @@ | ||
using Zenject; | ||
using SiraUtil.Interfaces; | ||
using CustomNotes.Managers; | ||
using CustomNotes.Providers; | ||
using CustomNotes.Settings.Utilities; | ||
using CustomNotes.Utilities; | ||
using CustomNotes.Managers; | ||
using Zenject; | ||
|
||
namespace CustomNotes.Installers | ||
{ | ||
internal class CustomNotesCoreInstaller : Installer<PluginConfig, CustomNotesCoreInstaller> | ||
internal class CustomNotesCoreInstaller : Installer | ||
{ | ||
private readonly PluginConfig _pluginConfig; | ||
|
||
public CustomNotesCoreInstaller(PluginConfig pluginConfig) | ||
{ | ||
_pluginConfig = pluginConfig; | ||
LayerUtils.pluginConfig = pluginConfig; | ||
} | ||
|
||
public override void InstallBindings() | ||
{ | ||
Container.BindInstance(_pluginConfig).AsSingle(); | ||
Container.BindInterfacesAndSelfTo<NoteAssetLoader>().AsSingle(); | ||
|
||
Container.Bind(typeof(IModelProvider), typeof(CustomGameNoteProvider)).To<CustomGameNoteProvider>().AsSingle(); | ||
Container.Bind(typeof(IModelProvider), typeof(CustomBombNoteProvider)).To<CustomBombNoteProvider>().AsSingle(); | ||
} | ||
} | ||
} |
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,24 +1,112 @@ | ||
using Zenject; | ||
using CustomNotes.Data; | ||
using CustomNotes.Managers; | ||
using CustomNotes.Overrides; | ||
using CustomNotes.Settings.Utilities; | ||
using CustomNotes.Utilities; | ||
using SiraUtil.Extras; | ||
using SiraUtil.Objects; | ||
using SiraUtil.Objects.Beatmap; | ||
using System.Reflection; | ||
using UnityEngine; | ||
using Zenject; | ||
|
||
namespace CustomNotes.Installers | ||
{ | ||
internal class CustomNotesGameInstaller : Installer | ||
{ | ||
private readonly PluginConfig _pluginConfig; | ||
private readonly NoteAssetLoader _noteAssetLoader; | ||
private readonly GameplayCoreSceneSetupData _gameplayCoreSceneSetupData; | ||
|
||
public CustomNotesGameInstaller(NoteAssetLoader noteAssetLoader) | ||
private bool _shouldSetup; | ||
|
||
private const int DECORATION_PRIORITY = 300; | ||
|
||
public CustomNotesGameInstaller(PluginConfig pluginConfig, NoteAssetLoader noteAssetLoader, GameplayCoreSceneSetupData gameplayCoreSceneSetupData) | ||
{ | ||
_pluginConfig = pluginConfig; | ||
_noteAssetLoader = noteAssetLoader; | ||
_gameplayCoreSceneSetupData = gameplayCoreSceneSetupData; | ||
} | ||
|
||
public override void InstallBindings() | ||
{ | ||
if (_noteAssetLoader.SelectedNote != 0) | ||
bool autoDisable = _pluginConfig.AutoDisable && (_gameplayCoreSceneSetupData.gameplayModifiers.ghostNotes || _gameplayCoreSceneSetupData.gameplayModifiers.disappearingArrows || _gameplayCoreSceneSetupData.gameplayModifiers.smallCubes || Utils.IsNoodleMap(_gameplayCoreSceneSetupData.difficultyBeatmap)); | ||
_shouldSetup = !autoDisable && (!(_gameplayCoreSceneSetupData.gameplayModifiers.ghostNotes || _gameplayCoreSceneSetupData.gameplayModifiers.disappearingArrows) || !Container.HasBinding<MultiplayerLevelSceneSetupData>()); | ||
if (_pluginConfig.Enabled && _noteAssetLoader.SelectedNote != 0 && _shouldSetup) | ||
{ | ||
Container.BindInterfacesAndSelfTo<GameCameraManager>().AsSingle(); | ||
Container.Bind<IInitializable>().To<CustomNoteManager>().AsSingle(); | ||
CustomNote note = _noteAssetLoader.CustomNoteObjects[_noteAssetLoader.SelectedNote]; | ||
|
||
#region Note Setup | ||
|
||
Container.RegisterRedecorator(new BasicNoteRegistration(DecorateNote, DECORATION_PRIORITY)); | ||
MaterialSwapper.GetMaterials(); | ||
MaterialSwapper.ReplaceMaterialsForGameObject(note.NoteLeft); | ||
MaterialSwapper.ReplaceMaterialsForGameObject(note.NoteRight); | ||
MaterialSwapper.ReplaceMaterialsForGameObject(note.NoteDotLeft); | ||
MaterialSwapper.ReplaceMaterialsForGameObject(note.NoteDotRight); | ||
Utils.AddMaterialPropertyBlockController(note.NoteLeft); | ||
Utils.AddMaterialPropertyBlockController(note.NoteRight); | ||
Utils.AddMaterialPropertyBlockController(note.NoteDotLeft); | ||
Utils.AddMaterialPropertyBlockController(note.NoteDotRight); | ||
|
||
Container.BindMemoryPool<SiraPrefabContainer, SiraPrefabContainer.Pool>().WithId(Protocol.LeftArrowPool).WithInitialSize(25).FromComponentInNewPrefab(NotePrefabContainer(note.NoteLeft)); | ||
Container.BindMemoryPool<SiraPrefabContainer, SiraPrefabContainer.Pool>().WithId(Protocol.RightArrowPool).WithInitialSize(25).FromComponentInNewPrefab(NotePrefabContainer(note.NoteRight)); | ||
if (note.NoteDotLeft != null) | ||
Container.BindMemoryPool<SiraPrefabContainer, SiraPrefabContainer.Pool>().WithId(Protocol.LeftDotPool).WithInitialSize(10).FromComponentInNewPrefab(NotePrefabContainer(note.NoteDotLeft)); | ||
if (note.NoteDotRight != null) | ||
Container.BindMemoryPool<SiraPrefabContainer, SiraPrefabContainer.Pool>().WithId(Protocol.RightDotPool).WithInitialSize(10).FromComponentInNewPrefab(NotePrefabContainer(note.NoteDotRight)); | ||
|
||
#endregion | ||
|
||
#region Bomb Setup | ||
|
||
if (note.NoteBomb != null) | ||
{ | ||
MaterialSwapper.GetMaterials(); | ||
MaterialSwapper.ReplaceMaterialsForGameObject(note.NoteBomb); | ||
Container.BindMemoryPool<SiraPrefabContainer, SiraPrefabContainer.Pool>().WithId(Protocol.BombPool).WithInitialSize(10).FromComponentInNewPrefab(NotePrefabContainer(note.NoteBomb)); | ||
Container.RegisterRedecorator(new BombNoteRegistration(DecorateBombs, DECORATION_PRIORITY)); | ||
} | ||
|
||
#endregion | ||
} | ||
} | ||
|
||
private GameNoteController DecorateNote(GameNoteController original) | ||
{ | ||
if (!_shouldSetup) | ||
return original; | ||
|
||
original.gameObject.AddComponent<CustomNoteController>(); | ||
|
||
ColorNoteVisuals originalVisuals = original.GetComponent<ColorNoteVisuals>(); | ||
|
||
CustomNoteColorNoteVisuals customVisuals = original.gameObject.AddComponent<CustomNoteColorNoteVisuals>(); | ||
customVisuals.enabled = false; | ||
foreach (FieldInfo info in originalVisuals.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic)) | ||
info.SetValue(customVisuals, info.GetValue(originalVisuals)); | ||
UnityEngine.Object.Destroy(originalVisuals); | ||
|
||
return original; | ||
} | ||
|
||
public BombNoteController DecorateBombs(BombNoteController original) | ||
{ | ||
if (!_shouldSetup) | ||
return original; | ||
|
||
original.gameObject.AddComponent<CustomBombController>(); | ||
return original; | ||
} | ||
|
||
private SiraPrefabContainer NotePrefabContainer(GameObject initialPrefab) | ||
{ | ||
var prefab = new GameObject("CustomNotes" + initialPrefab.name).AddComponent<SiraPrefabContainer>(); | ||
prefab.Prefab = initialPrefab; | ||
return prefab; | ||
} | ||
} | ||
} |
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,25 +1,21 @@ | ||
using Zenject; | ||
using SiraUtil; | ||
using CustomNotes.Managers; | ||
using CustomNotes.Managers; | ||
using CustomNotes.Settings; | ||
using CustomNotes.Settings.UI; | ||
using Zenject; | ||
|
||
namespace CustomNotes.Installers | ||
{ | ||
internal class CustomNotesMenuInstaller : Installer | ||
{ | ||
public override void InstallBindings() | ||
{ | ||
|
||
|
||
Container.Bind<NotePreviewViewController>().FromNewComponentAsViewController().AsSingle(); | ||
Container.Bind<NoteDetailsViewController>().FromNewComponentAsViewController().AsSingle(); | ||
Container.Bind<NoteListViewController>().FromNewComponentAsViewController().AsSingle(); | ||
Container.BindInterfacesAndSelfTo<NoteModifierViewController>().AsSingle(); | ||
Container.Bind<NotesFlowCoordinator>().FromNewComponentOnNewGameObject().AsSingle(); | ||
|
||
Container.BindInterfacesTo<MenuButtonManager>().AsSingle(); | ||
Container.BindInterfacesAndSelfTo<NoteModifierViewController>().AsSingle(); | ||
Container.BindInterfacesTo<CustomNotesViewManager>().AsSingle(); | ||
Container.BindInterfacesTo<MenuButtonManager>().AsSingle(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.