Skip to content

Commit

Permalink
Merge pull request #1 from PrashantMohta/1.5
Browse files Browse the repository at this point in the history
1.5
  • Loading branch information
PrashantMohta authored Sep 13, 2021
2 parents b7861a9 + 99a9e43 commit 0f74c02
Show file tree
Hide file tree
Showing 35 changed files with 607 additions and 95 deletions.
2 changes: 1 addition & 1 deletion Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using UnityEngine;
using static Modding.Logger;

namespace DandyCore{
namespace Satchel{
public class Core{

public static AssetBundle shaderBundle;
Expand Down
6 changes: 5 additions & 1 deletion Core.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@
<SharedGUID>28A5F3C0-2F3D-40FA-BF50-3A8AEEFDC54D</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>DandyCore</Import_RootNamespace>
<Import_RootNamespace>Satchel</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Core.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Mod.cs" />

<Compile Include="$(MSBuildThisFileDirectory)Utils\AssemblyUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\WavUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\AnimationUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\TextureUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\SpriteUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\SceneUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\GameObjectUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\PlayerDataUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\FsmUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\EnemyUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\IoUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\Singleton.cs" />

<Compile Include="$(MSBuildThisFileDirectory)Monobehaviour\Unity\WhoAmI.cs" />
Expand All @@ -29,6 +32,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Monobehaviour\Unity\AlertRangeMarker.cs" />

<Compile Include="$(MSBuildThisFileDirectory)Monobehaviour\CustomEnemy.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Monobehaviour\CustomAnimationFrames.cs" />

<Compile Include="$(MSBuildThisFileDirectory)Custom\CustomEnemyManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Custom\CustomDreamNailManager.cs" />
Expand Down
10 changes: 5 additions & 5 deletions Custom/CustomDreamNailManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
using static Modding.Logger;
using UnityEngine;

namespace DandyCore{
namespace Satchel{
public class CustomDreamNailManager {

public Dictionary<string,string> DNdialog = new Dictionary<string,string>();

public CustomDreamNailManager(){
ModHooks.Instance.LanguageGetHook += LanguageGet;
ModHooks.LanguageGetHook += LanguageGet;
}

// will add or update dn text for id
Expand All @@ -21,8 +21,8 @@ public Convo SetText(Convo conv, string text){
return conv;
}

public string LanguageGet( string key, string sheet){
string orig = Language.Language.GetInternal(key, sheet);
public string LanguageGet( string key, string sheet, string orig){
//string orig = Language.Language.GetInternal(key, sheet);
if(key.StartsWith(Convo.prefix)){
var dnkey = key.Replace(Convo.prefix,"");
if(DNdialog.TryGetValue(dnkey, out var dntext)){
Expand All @@ -35,7 +35,7 @@ public string LanguageGet( string key, string sheet){
}
private void OnDestroy()
{
ModHooks.Instance.LanguageGetHook -= LanguageGet;
ModHooks.LanguageGetHook -= LanguageGet;
}

}
Expand Down
2 changes: 1 addition & 1 deletion Custom/CustomEnemyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using UnityEngine;
using UnityEngine.SceneManagement;

namespace DandyCore{
namespace Satchel{
public class CustomEnemyManager{
private GameObject defaultInfectedEnemyPrefab;
private GameObject defaultUnInfectedEnemyPrefab;
Expand Down
32 changes: 16 additions & 16 deletions Custom/CustomMapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;

using static DandyCore.SceneUtils;
using static Satchel.SceneUtils;
using static Modding.Logger;

namespace DandyCore{
namespace Satchel{

public class customMapZone{
public string ZoneName;
Expand Down Expand Up @@ -54,7 +54,7 @@ public CustomMapManager(){
On.GameMap.CloseQuickMap += NewCloseQuickMap;
On.GameMap.PositionCompass += NewPositionCompass;
On.HutongGames.PlayMaker.Actions.PlayerDataBoolTest.OnEnter += HandlePlayerDataBoolTest;
ModHooks.Instance.LanguageGetHook += LanguageGet;
ModHooks.LanguageGetHook += LanguageGet;
}
public void AddZone(customMapZone newZone){
Zones.Add(newZone.ZoneName,newZone);
Expand Down Expand Up @@ -226,8 +226,8 @@ public void CheckOpenCustomQuickMap(ActionArg arg)
OpenCustomMap(arg.go.GetComponent<GameMap>());
}

public string LanguageGet( string key, string sheet){
string orig = Language.Language.GetInternal(key, sheet);
public string LanguageGet( string key, string sheet, string orig){
//string orig = Language.Language.GetInternal(key, sheet);

if(key.StartsWith("dc_custom_map_")){
var sceneName = key.Replace("dc_custom_map_","");
Expand Down Expand Up @@ -300,12 +300,12 @@ protected void NewCloseQuickMap(On.GameMap.orig_CloseQuickMap orig, GameMap self
protected void NewPositionCompass(On.GameMap.orig_PositionCompass orig, GameMap self, bool posShade)
{
GameObject gameObject = null;
var currentMapZone = ReflectionHelper.GetAttr<GameMap, GameManager>(self, "gm").GetCurrentMapZone();
var currentMapZone = ReflectionHelper.GetField<GameMap, GameManager>(self, "gm").GetCurrentMapZone();

string sceneName;
if (!self.inRoom)
{
sceneName = ReflectionHelper.GetAttr<GameMap, GameManager>(self, "gm").sceneName;
sceneName = ReflectionHelper.GetField<GameMap, GameManager>(self, "gm").sceneName;
}
else
{
Expand Down Expand Up @@ -399,16 +399,16 @@ protected void NewPositionCompass(On.GameMap.orig_PositionCompass orig, GameMap
new Vector3(self.currentScene.transform.localPosition.x + gameObject.transform.localPosition.x,
self.currentScene.transform.localPosition.y + gameObject.transform.localPosition.y, 0f);

if (!posShade && !ReflectionHelper.GetAttr<GameMap, bool>(self, "posGate"))
if (!posShade && !ReflectionHelper.GetField<GameMap, bool>(self, "posGate"))
{
if (ReflectionHelper.GetAttr<GameMap, PlayerData>(self, "pd").GetBool("equippedCharm_2"))
if (ReflectionHelper.GetField<GameMap, PlayerData>(self, "pd").GetBool("equippedCharm_2"))
{
ReflectionHelper.SetAttr(self, "displayingCompass", true);
ReflectionHelper.SetField(self, "displayingCompass", true);
self.compassIcon.SetActive(true);
}
else
{
ReflectionHelper.SetAttr(self, "displayingCompass", false);
ReflectionHelper.SetField(self, "displayingCompass", false);
self.compassIcon.SetActive(false);
}
}
Expand All @@ -435,15 +435,15 @@ protected void NewPositionCompass(On.GameMap.orig_PositionCompass orig, GameMap
self.shadeMarker.transform.localPosition = new Vector3(x, y, 0f);
}

ReflectionHelper.GetAttr<GameMap, PlayerData>(self, "pd").SetVector3("shadeMapPos",
ReflectionHelper.GetField<GameMap, PlayerData>(self, "pd").SetVector3("shadeMapPos",
new Vector3(self.currentScenePos.x, self.currentScenePos.y, 0f));
}

if (ReflectionHelper.GetAttr<GameMap, bool>(self, "posGate"))
if (ReflectionHelper.GetField<GameMap, bool>(self, "posGate"))
{
self.dreamGateMarker.transform.localPosition =
new Vector3(self.currentScenePos.x, self.currentScenePos.y, 0f);
ReflectionHelper.GetAttr<GameMap, PlayerData>(self, "pd").SetVector3("dreamgateMapPos",
ReflectionHelper.GetField<GameMap, PlayerData>(self, "pd").SetVector3("dreamgateMapPos",
new Vector3(self.currentScenePos.x, self.currentScenePos.y, 0f));
}
}
Expand All @@ -452,9 +452,9 @@ protected void NewPositionCompass(On.GameMap.orig_PositionCompass orig, GameMap
Debug.Log("Couldn't find current scene object!");
if (posShade)
{
ReflectionHelper.GetAttr<GameMap, PlayerData>(self, "pd")
ReflectionHelper.GetField<GameMap, PlayerData>(self, "pd")
.SetVector3("shadeMapPos", new Vector3(-10000f, -10000f, 0f));
self.shadeMarker.transform.localPosition = ReflectionHelper.GetAttr<GameMap, PlayerData>(self, "pd")
self.shadeMarker.transform.localPosition = ReflectionHelper.GetField<GameMap, PlayerData>(self, "pd")
.GetVector3("shadeMapPos");
}
}
Expand Down
4 changes: 2 additions & 2 deletions Custom/CustomSaveSlotsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
using System.Collections;
using System.Collections.Generic;

using static DandyCore.SceneUtils;
using static Satchel.SceneUtils;
using static Modding.Logger;

namespace DandyCore{
namespace Satchel{

public class CustomSaveSlotsManager
{
Expand Down
8 changes: 4 additions & 4 deletions Custom/CustomScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
using Modding;
using static Modding.Logger;

using GatewayParams = DandyCore.SceneUtils.GatewayParams;
using BenchParams = DandyCore.SceneUtils.BenchParams;
using CustomSceneManagerSettings = DandyCore.SceneUtils.CustomSceneManagerSettings;
using GatewayParams = Satchel.SceneUtils.GatewayParams;
using BenchParams = Satchel.SceneUtils.BenchParams;
using CustomSceneManagerSettings = Satchel.SceneUtils.CustomSceneManagerSettings;
//playerData.respawnScene
namespace DandyCore{
namespace Satchel{

public class CustomScene
{
Expand Down
24 changes: 24 additions & 0 deletions Mod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections;
using System.Collections.Generic;

using System.IO;
using UnityEngine;
using Modding;
using static Modding.Logger;

namespace Satchel{
public class Satchel : Mod{

new public string GetName() => AssemblyUtils.name;
public override string GetVersion() => $"{AssemblyUtils.GetAssemblyVersionHash(AssemblyUtils.ver)}";
public Satchel Instance;
public override void Initialize()
{
if (Instance == null)
{
Instance = this;
}
}
}
}
69 changes: 69 additions & 0 deletions Monobehaviour/CustomAnimationFrames.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;

using Modding;
using static Modding.Logger;
using UnityEngine;

namespace Satchel{
public class CustomAnimationFrames : MonoBehaviour {
public Dictionary<string,Dictionary<int,Sprite>> customClips = new Dictionary<string,Dictionary<int,Sprite>>();
public Animator anim;
private SpriteRenderer sr;
public bool dump;
public string dumpPath;
public string dumpingClip = "";
public List<int> dumpedFrames;
private void Awake()
{
sr = GetComponent<SpriteRenderer>();
anim = GetComponent<Animator>();
}
public void Add(string clip,int frame,Sprite s){
if(!customClips.TryGetValue(clip, out var data)){
customClips[clip] = new Dictionary<int,Sprite>();
}
customClips[clip][frame] = s;
}
private void LateUpdate(){
var currentClipName = anim.GetClipName();
var currentFrame = anim.GetCurrentFrame();
if(dump){
if(dumpingClip != currentClipName){
dumpedFrames = new List<int>();
}
if(!dumpedFrames.Contains(currentFrame)){
dumpedFrames.Add(currentFrame);
var path = Path.Combine(dumpPath, gameObject.GetName(true));
var fileName = $"{currentClipName}.{currentFrame}.png";
if(!Directory.Exists(path)){
Directory.CreateDirectory(path);
}
var filePath = Path.Combine(path,fileName);
if(!File.Exists(filePath)){
var texture = SpriteUtils.ExtractTextureFromSprite(sr.sprite);
TextureUtils.WriteTextureToFile(texture,filePath);
}
}
return;
}
if(anim != null){
if(customClips.TryGetValue(currentClipName,out var frames)){
try{
sr.sprite = frames[currentFrame];
} catch (Exception e){
Log(e.ToString());
}
} else {
Log($"Unable to find clip {currentClipName} in Animator for {gameObject.name}");
}
}
}
private void OnDestroy()
{
}

}
}
2 changes: 1 addition & 1 deletion Monobehaviour/CustomEnemy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using UnityEngine;
using System.Collections;

namespace DandyCore{
namespace Satchel{
public class CustomEnemy : MonoBehaviour{
public DamageHero dh;
public Rigidbody2D rb;
Expand Down
2 changes: 1 addition & 1 deletion Monobehaviour/Unity/AlertRangeMarker.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Modding;
using UnityEngine;

namespace DandyCore{
namespace Satchel{
public class AlertRangeMarker : MonoBehaviour{

// dont show in editer
Expand Down
4 changes: 2 additions & 2 deletions Monobehaviour/Unity/ChangeMeshColor.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using UnityEngine;
using static DandyCore.TextureUtils;
using static Satchel.TextureUtils;

namespace DandyCore{
namespace Satchel{
class ChangeMeshColor : MonoBehaviour
{
private Material mat;
Expand Down
2 changes: 1 addition & 1 deletion Monobehaviour/Unity/CustomEnemyMarker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Collections;


namespace DandyCore{
namespace Satchel{
public class CustomEnemyMarker : MonoBehaviour{
//this script just marks the go as one to add a custom enemy to

Expand Down
2 changes: 1 addition & 1 deletion Monobehaviour/Unity/SpriteRendererMaterial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System;
using UnityEngine;

namespace DandyCore{
namespace Satchel{
public class SpriteRendererMaterial : MonoBehaviour {

public bool enableFlash = false;
Expand Down
2 changes: 1 addition & 1 deletion Monobehaviour/Unity/WhoAmI.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Modding;
using UnityEngine;

namespace DandyCore{
namespace Satchel{
public class WhoAmI : MonoBehaviour{
private void Awake() {
Modding.Logger.Log("v2 Type: " + this.GetType().AssemblyQualifiedName);
Expand Down
Loading

0 comments on commit 0f74c02

Please sign in to comment.