Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added restore of class roster icons in story mode
- Loading branch information
1 parent
75c3884
commit 5607302
Showing
6 changed files
with
129 additions
and
2 deletions.
There are no files selected for viewing
112 changes: 112 additions & 0 deletions
112
src/KK_Fix_RestoreMissingFunctions/CalendarIcon/CalendarIconHooks.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,112 @@ | ||
using System; | ||
using ActionGame; | ||
using ActionGame.Chara; | ||
using HarmonyLib; | ||
using Illusion.Component; | ||
using KKAPI.Utilities; | ||
using Manager; | ||
using UniRx; | ||
using UniRx.Triggers; | ||
using UnityEngine; | ||
|
||
namespace IllusionFixes | ||
{ | ||
public partial class RestoreMissingFunctions | ||
{ | ||
private static class CalendarIconHooks | ||
{ | ||
[HarmonyPostfix] | ||
[HarmonyPatch(typeof(ActionMap), "Reserve")] | ||
private static void OnMapChangedHook(ActionMap __instance) | ||
{ | ||
if (__instance.mapRoot == null || __instance.isMapLoading) return; | ||
|
||
// All 4 classroom ids | ||
if (__instance.no == 5 || __instance.no == 8 || __instance.no == 9 || __instance.no == 11) | ||
{ | ||
try | ||
{ | ||
SpawnCrestActionPoint(); | ||
} | ||
catch (Exception e) | ||
{ | ||
Logger.LogError(e); | ||
} | ||
} | ||
} | ||
|
||
private static void SpawnCrestActionPoint() | ||
{ | ||
Logger.LogDebug("Spawning crest action point"); | ||
|
||
if (_iconOff == null) | ||
{ | ||
_iconOff = (ResourceUtils.GetEmbeddedResource(@"action_icon_calendar_off.png").LoadTexture() | ||
?? throw new Exception("asset not found - action_icon_calendar_off")).ToSprite(); | ||
DontDestroyOnLoad(_iconOff); | ||
} | ||
|
||
if (_iconOn == null) | ||
{ | ||
_iconOn = (ResourceUtils.GetEmbeddedResource(@"action_icon_calendar_on.png").LoadTexture() | ||
?? throw new Exception("asset not found - action_icon_calendar_on")).ToSprite(); | ||
DontDestroyOnLoad(_iconOn); | ||
} | ||
|
||
var inst = CommonLib.LoadAsset<GameObject>("map/playeractionpoint/00.unity3d", "PlayerActionPoint_05", true); | ||
var parent = GameObject.Find("Map/ActionPoints"); | ||
inst.transform.SetParent(parent.transform, true); | ||
|
||
var pap = inst.GetComponentInChildren<PlayerActionPoint>(); | ||
var iconRootObject = pap.gameObject; | ||
var iconRootTransform = pap.transform; | ||
DestroyImmediate(pap, false); | ||
|
||
// position above the small table | ||
iconRootTransform.position = new Vector3(2.43f, 0.45f, 4.55f); | ||
|
||
if (iconRootObject.GetComponent<ObservableUpdateTrigger>()) | ||
Console.WriteLine("was spawned -=--------------"); | ||
|
||
var evt = iconRootObject.AddComponent<TriggerEnterExitEvent>(); | ||
var animator = iconRootObject.GetComponentInChildren<Animator>(); | ||
var rendererIcon = iconRootObject.GetComponentInChildren<SpriteRenderer>(); | ||
rendererIcon.sprite = _iconOff; | ||
var playerInRange = false; | ||
evt.onTriggerEnter += c => | ||
{ | ||
if (!c.CompareTag("Player")) return; | ||
playerInRange = true; | ||
animator.Play("icon_action"); | ||
rendererIcon.sprite = _iconOn; | ||
c.GetComponent<Player>().actionPointList.Add(evt); | ||
}; | ||
evt.onTriggerExit += c => | ||
{ | ||
if (!c.CompareTag("Player")) return; | ||
playerInRange = false; | ||
animator.Play("icon_stop"); | ||
rendererIcon.sprite = _iconOff; | ||
c.GetComponent<Player>().actionPointList.Remove(evt); | ||
}; | ||
|
||
var player = Singleton<Game>.Instance.actScene.Player; | ||
evt.UpdateAsObservable() | ||
.Where(_ => playerInRange && ActionInput.isAction && !player.isActionNow && !Singleton<Scene>.Instance.IsNowLoadingFade) | ||
.Subscribe(_ => | ||
{ | ||
Singleton<Scene>.Instance.LoadReserve(new Scene.Data | ||
{ | ||
assetBundleName = "action/menu/classschedulemenu.unity3d", | ||
levelName = "ClassScheduleMenu", | ||
isAdd = true, | ||
isAsync = true | ||
}, false); | ||
}) | ||
.AddTo(evt); | ||
} | ||
|
||
private static Sprite _iconOff, _iconOn; | ||
} | ||
} | ||
} |
Binary file added
BIN
+16.6 KB
src/KK_Fix_RestoreMissingFunctions/CalendarIcon/action_icon_calendar_off.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.7 KB
src/KK_Fix_RestoreMissingFunctions/CalendarIcon/action_icon_calendar_on.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
2 changes: 2 additions & 0 deletions
2
src/KK_Fix_RestoreMissingFunctions/KK_Fix_RestoreMissingFunctions.csproj.DotSettings
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,2 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=calendaricon/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
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