Skip to content

Commit

Permalink
Merge pull request #12 from PrashantMohta/dandydev
Browse files Browse the repository at this point in the history
Swapper fixes and Chores
  • Loading branch information
PrashantMohta authored Dec 24, 2021
2 parents 00c6e0c + 67413af commit 37e76ea
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 67 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,5 @@ ASALocalRun/
#Vanilla files
CustomKnight/Vanilla

.DS_Store
.DS_Store
CustomKnight/Assets
27 changes: 21 additions & 6 deletions CustomKnight/CustomKnight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,28 @@ public class CustomKnight : Mod, IGlobalSettings<GlobalModSettings>, ILocalSett
public static SwapManager swapManager {get; private set;} = new SwapManager();

public static readonly Dictionary<string, GameObject> GameObjects = new Dictionary<string, GameObject>();
private void getVersionSafely(){
internal static void touchSatchelVersion(){
Satchel.AssemblyUtils.Version();
}
internal static bool isSatchelInstalled(){
var isInstalled = false;
try{
touchSatchelVersion();
isInstalled = true;
} catch (Exception e){
Modding.Logger.Log(e);
}
return isInstalled;
}
internal void getVersionSafely(){
version = Satchel.AssemblyUtils.GetAssemblyVersionHash();
}
public string version;
new public string GetName() => "Custom Knight";
public override string GetVersion(){
version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
try{
version = "Satchel not found";
if(isSatchelInstalled()){
getVersionSafely();
} catch(Exception e){

}
return version;
}
Expand Down Expand Up @@ -90,6 +101,9 @@ public override void Initialize(Dictionary<string, Dictionary<string, GameObject
{
Instance = this;
}
if(!isSatchelInstalled()){
return;
}
SkinManager.checkDirectoryStructure();

// Initial load
Expand Down Expand Up @@ -131,7 +145,8 @@ public MenuScreen GetMenuScreen(MenuScreen modListMenu,ModToggleDelegates? toggl

public void LoadSaveGame(SaveGameData data){
Log("LoadSaveGame");
SkinManager.SKIN_FOLDER = SaveSettings.DefaultSkin != GlobalSettings.DefaultSkin ? SaveSettings.DefaultSkin : GlobalSettings.DefaultSkin;
SkinManager.SKIN_FOLDER = ( SaveSettings.DefaultSkin != GlobalSettings.DefaultSkin && SaveSettings.DefaultSkin != null ) ? SaveSettings.DefaultSkin : GlobalSettings.DefaultSkin;
SaveSettings.DefaultSkin = SkinManager.SKIN_FOLDER;
ModMenu.setModMenu(SkinManager.SKIN_FOLDER,CustomKnight.GlobalSettings.Preloads);
SkinManager.LoadSkin();
}
Expand Down
42 changes: 22 additions & 20 deletions CustomKnight/CustomKnight.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<VanillaFiles>..\..\Vanilla</VanillaFiles>
<ModdingAPi>..\..\HollowKnight.Modding\OutputFinal</ModdingAPi>
<HollowKnightModsDirectory>..\..\linkedtoHKMods</HollowKnightModsDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand All @@ -37,19 +39,19 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\HollowKnight.Modding\OutputFinal\Assembly-CSharp.dll</HintPath>
<HintPath>$(ModdingAPi)\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="MMHOOK_Assembly-CSharp">
<HintPath>..\..\HollowKnight.Modding\OutputFinal\MMHOOK_Assembly-CSharp.dll</HintPath>
<HintPath>$(ModdingAPi)\MMHOOK_Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="MMHOOK_PlayMaker">
<HintPath>..\..\HollowKnight.Modding\OutputFinal\MMHOOK_PlayMaker.dll</HintPath>
<HintPath>$(ModdingAPi)\MMHOOK_PlayMaker.dll</HintPath>
</Reference>
<Reference Include="PlayMaker">
<HintPath>.\Vanilla\PlayMaker.dll</HintPath>
<HintPath>$(VanillaFiles)\PlayMaker.dll</HintPath>
</Reference>
<Reference Include="PlayMaker, Version=1.6.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>.\Vanilla\PlayMaker.dll</HintPath>
<HintPath>$(VanillaFiles)\PlayMaker.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -58,44 +60,44 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>.\Vanilla\UnityEngine.dll</HintPath>
<HintPath>$(VanillaFiles)\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>.\Vanilla\UnityEngine.CoreModule.dll</HintPath>
<HintPath>$(VanillaFiles)\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AnimationModule">
<HintPath>$(VanillaFiles)\UnityEngine.AnimationModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.InputLegacyModule">
<HintPath>.\Vanilla\UnityEngine.InputLegacyModule.dll</HintPath>
<HintPath>$(VanillaFiles)\UnityEngine.InputLegacyModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ImageConversionModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\Vanilla\UnityEngine.ImageConversionModule.dll</HintPath>
<HintPath>$(VanillaFiles)\UnityEngine.ImageConversionModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.IMGUIModule">
<HintPath>.\Vanilla\UnityEngine.IMGUIModule.dll</HintPath>
<HintPath>$(VanillaFiles)\UnityEngine.IMGUIModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.Physics2DModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>.\Vanilla\UnityEngine.Physics2DModule.dll</HintPath>
<HintPath>$(VanillaFiles)\UnityEngine.Physics2DModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.TextRenderingModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>.\Vanilla\UnityEngine.TextRenderingModule.dll</HintPath>
<HintPath>$(VanillaFiles)\UnityEngine.TextRenderingModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>.\Vanilla\UnityEngine.UI.dll</HintPath>
<HintPath>$(VanillaFiles)\UnityEngine.UI.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>.\Vanilla\UnityEngine.UI.dll</HintPath>
<HintPath>$(VanillaFiles)\UnityEngine.UI.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UIModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>.\Vanilla\UnityEngine.UIModule.dll</HintPath>
<HintPath>$(VanillaFiles)\UnityEngine.UIModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ParticleSystemModule">
<HintPath>.\Vanilla\UnityEngine.ParticleSystemModule.dll</HintPath>
<HintPath>$(VanillaFiles)\UnityEngine.ParticleSystemModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ParticlesLegacyModule">
<HintPath>.\Vanilla\UnityEngine.ParticlesLegacyModule.dll</HintPath>
<HintPath>$(VanillaFiles)\UnityEngine.ParticlesLegacyModule.dll</HintPath>
</Reference>
<Reference Include="Satchel">
<HintPath>..\..\Satchel\bin\Debug\Satchel.dll</HintPath>
Expand Down Expand Up @@ -124,7 +126,7 @@
<Compile Include="Settings.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(HollowKnightModsDirectory)/CustomKnight"/>
</Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(HollowKnightModsDirectory)/Custom Knight"/>
</Target>
</Project>
2 changes: 1 addition & 1 deletion CustomKnight/Menu/ModMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ out MenuButton OpenSkinsButton
"FixSkinButton",
new MenuButtonConfig
{
Label = "Fix skins",
Label = "Fix & reload skins",
CancelAction = GoToModListMenu,
SubmitAction = FixSkins,
Proceed = true,
Expand Down
2 changes: 1 addition & 1 deletion CustomKnight/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.0.0")]
[assembly: AssemblyVersion("1.6.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
2 changes: 1 addition & 1 deletion CustomKnight/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace CustomKnight
{
public class SaveModSettings {
public string DefaultSkin {get; set;} = "Default";
public string DefaultSkin {get; set;} = null;
}

public class GlobalModSettings
Expand Down
17 changes: 14 additions & 3 deletions CustomKnight/Skin/Base/SkinManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,28 @@ public static class SkinManager{
"Leak",
"Liquid",
"HitPt",
"ShadowDashBlobs"
"ShadowDashBlobs",
"Beam"
};
public static Dictionary<string, CustomKnightTexture> Textures = new Dictionary<string, CustomKnightTexture>();

public static string DATA_DIR = Satchel.AssemblyUtils.getCurrentDirectory();
public static string SKINS_FOLDER = Path.Combine(DATA_DIR,"Skins");
public static string DATA_DIR;
public static string SKINS_FOLDER;
public static string SKIN_FOLDER;

public static List<string> skinsArr;
public static List<string> skinNamesArr;

public static void SetDataDir(){
DATA_DIR = Satchel.AssemblyUtils.getCurrentDirectory();
SKINS_FOLDER = Path.Combine(DATA_DIR,"Skins");
}
static SkinManager(){
if(CustomKnight.isSatchelInstalled()){
SetDataDir();
}
}

public static void getSkinNames()
{
var dirs = Directory.GetDirectories(SKINS_FOLDER);
Expand Down
48 changes: 46 additions & 2 deletions CustomKnight/Skin/Base/SpriteLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ internal class SpriteLoader : MonoBehaviour
private static Material _LowHealthLeakMat;
private static Material _LiquidMat;
private static Material _ShadowDashBlobs;

private static Material _BeamUMat;
private static Material _BeamDMat;
private static Material _BeamLMat;
private static Material _BeamRMat;
private static Material _BeamUFMat;
private static Material _BeamDFMat;
private static Material _BeamLFMat;
private static Material _BeamRFMat;
public static void PullDefaultTextures()
{

Expand All @@ -90,7 +99,7 @@ public static void PullDefaultTextures()

SkinManager.Textures["Shade"].defaultTex = _shadeMat.mainTexture as Texture2D;
SkinManager.Textures["ShadeOrb"].defaultTex = _shadeOrbMat.mainTexture as Texture2D;

SkinManager.Textures["Beam"].defaultTex = _BeamRMat.mainTexture as Texture2D;
if (CustomKnight.GlobalSettings.Preloads)
{
SkinManager.Textures["Cloak"].defaultTex = _cloakMat.mainTexture as Texture2D;
Expand Down Expand Up @@ -271,7 +280,23 @@ public static void UnloadAll()
_shadeOrbDepartMat.mainTexture = _shadeOrbMat.mainTexture;

_shadeOrbQuakeMat.mainTexture = _shadeOrbMat.mainTexture;


_BeamRMat.mainTexture = SkinManager.Textures["Beam"].defaultTex;

_BeamLMat.mainTexture = _BeamRMat.mainTexture;

_BeamUMat.mainTexture = _BeamRMat.mainTexture;

_BeamDMat.mainTexture = _BeamRMat.mainTexture;

_BeamLFMat.mainTexture = _BeamRMat.mainTexture;

_BeamRFMat.mainTexture = _BeamRMat.mainTexture;

_BeamUFMat.mainTexture = _BeamRMat.mainTexture;

_BeamDFMat.mainTexture = _BeamRMat.mainTexture;

if (CustomKnight.GlobalSettings.Preloads)
{
_cloakMat.mainTexture = SkinManager.Textures["Cloak"].defaultTex;
Expand Down Expand Up @@ -351,6 +376,15 @@ public IEnumerator Start()

_ShadowDashBlobs = hc.FindGameObjectInChildren("Shadow Dash Blobs").GetComponent<ParticleSystemRenderer>().material;

_BeamDFMat = HeroController.instance.grubberFlyBeamPrefabD_fury.GetComponent<tk2dSprite>().GetCurrentSpriteDef().material;
_BeamDMat = HeroController.instance.grubberFlyBeamPrefabD.GetComponent<tk2dSprite>().GetCurrentSpriteDef().material;
_BeamUFMat = HeroController.instance.grubberFlyBeamPrefabU_fury.GetComponent<tk2dSprite>().GetCurrentSpriteDef().material;
_BeamUMat = HeroController.instance.grubberFlyBeamPrefabU.GetComponent<tk2dSprite>().GetCurrentSpriteDef().material;
_BeamLFMat = HeroController.instance.grubberFlyBeamPrefabL_fury.GetComponent<tk2dSprite>().GetCurrentSpriteDef().material;
_BeamLMat = HeroController.instance.grubberFlyBeamPrefabL.GetComponent<tk2dSprite>().GetCurrentSpriteDef().material;
_BeamRFMat = HeroController.instance.grubberFlyBeamPrefabR_fury.GetComponent<tk2dSprite>().GetCurrentSpriteDef().material;
_BeamRMat = HeroController.instance.grubberFlyBeamPrefabR.GetComponent<tk2dSprite>().GetCurrentSpriteDef().material;

_LiquidMat = GameCameras.instance.hudCanvas.FindGameObjectInChildren("Liquid").GetComponent<tk2dSprite>().GetCurrentSpriteDef().material;

tk2dSpriteAnimator shadeAnim = sm.hollowShadeObject.GetComponent<tk2dSpriteAnimator>();
Expand Down Expand Up @@ -529,12 +563,22 @@ private static IEnumerator SetHeroTex()
_shadeMat.mainTexture = SkinManager.Textures["Shade"].currentTexture;
_shadeOrbMat.mainTexture = SkinManager.Textures["ShadeOrb"].currentTexture;

_BeamRMat.mainTexture = SkinManager.Textures["Beam"].currentTexture;
_BeamRFMat.mainTexture = _BeamRMat.mainTexture;
_BeamLFMat.mainTexture = _BeamRMat.mainTexture;
_BeamLMat.mainTexture = _BeamRMat.mainTexture;
_BeamUFMat.mainTexture = _BeamRMat.mainTexture;
_BeamUMat.mainTexture = _BeamRMat.mainTexture;
_BeamDFMat.mainTexture = _BeamRMat.mainTexture;
_BeamDMat.mainTexture = _BeamRMat.mainTexture;

_shadeOrbReformMat.mainTexture = _shadeOrbMat.mainTexture;
_shadeOrbRetreatMat.mainTexture = _shadeOrbMat.mainTexture;
_shadeOrbChargeMat.mainTexture = _shadeOrbMat.mainTexture;
_shadeOrbDepartMat.mainTexture = _shadeOrbMat.mainTexture;
_shadeOrbQuakeMat.mainTexture = _shadeOrbMat.mainTexture;


if (CustomKnight.GlobalSettings.Preloads)
{
_cloakMat.mainTexture = SkinManager.Textures["Cloak"].currentTexture;
Expand Down
Loading

0 comments on commit 37e76ea

Please sign in to comment.