Skip to content

Commit

Permalink
Fixed Item Get Message fade issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nickc01 committed Jun 19, 2024
1 parent 85a27e3 commit f52e0f2
Show file tree
Hide file tree
Showing 17 changed files with 201 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 8acfdb48cc2a635439fbd1eff244a928, type: 3}
m_Texture: {fileID: 2800000, guid: 2185737cc0508734aa7386644f6a477e, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OutlineTex:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 8acfdb48cc2a635439fbd1eff244a928, type: 3}
m_Texture: {fileID: 2800000, guid: 60a836d715be9a247b83bdb65dd4382d, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OutlineTex:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 8acfdb48cc2a635439fbd1eff244a928, type: 3}
m_Texture: {fileID: 2800000, guid: d2627649b701d9141a6507c7efbff250, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OutlineTex:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 8acfdb48cc2a635439fbd1eff244a928, type: 3}
m_Texture: {fileID: 2800000, guid: 774cdb224155cee4ba5fa38929c07c3b, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OutlineTex:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 8acfdb48cc2a635439fbd1eff244a928, type: 3}
m_Texture: {fileID: 2800000, guid: a98fb8a1d49582841abecec09d8d5732, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OutlineTex:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 8acfdb48cc2a635439fbd1eff244a928, type: 3}
m_Texture: {fileID: 2800000, guid: 2edecbaeb5eabd54f8eafc52ceb07d8b, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OutlineTex:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 8acfdb48cc2a635439fbd1eff244a928, type: 3}
m_Texture: {fileID: 2800000, guid: 35ad0f3b09dbc1747bb59a9c83f86243, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OutlineTex:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 8acfdb48cc2a635439fbd1eff244a928, type: 3}
m_Texture: {fileID: 2800000, guid: 5e594fbf23cbc344982af33961eeafea, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OutlineTex:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 8acfdb48cc2a635439fbd1eff244a928, type: 3}
m_Texture: {fileID: 2800000, guid: c6f692727898ca145aaa2636704815f4, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OutlineTex:
Expand Down
1 change: 1 addition & 0 deletions WeaverCore/Components/DroppedCustomCharmItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class DroppedCustomCharmItem : DroppedItem

protected override void OnGiveItem()
{
//WeaverLog.Log("CHARM = " + charm);
if (charm == null)
{
throw new System.Exception("No charm has been specified");
Expand Down
15 changes: 15 additions & 0 deletions WeaverCore/Components/DroppedItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,20 @@ protected virtual void Awake()

IEnumerator DroppedItemRoutine()
{
if (SettingsStorage != null)
{
//WeaverLog.Log("OLD SETTINGS DUMP = " + JsonUtility.ToJson(SettingsStorage, true));
var result = SaveSpecificSettings.GetSaveSettings(SettingsStorage.GetType());
if (result != null)
{
SettingsStorage = result;
//WeaverLog.Log("NEW SETTINGS DUMP = " + JsonUtility.ToJson(result, true));
}
}
transform.rotation = Quaternion.identity;

//WeaverLog.Log("CAN SPAWN = " + CanSpawn());

if (!CanSpawn())
{
Destroy(gameObject);
Expand Down Expand Up @@ -156,6 +168,9 @@ protected virtual bool CanSpawn()
{
if (SettingsStorage.HasField<bool>(SettingsField))
{
var result = SettingsStorage.GetFieldValue<bool>(SettingsField);
//WeaverLog.Log($"{SettingsField} = {result}");
//WeaverLog.Log("CAN SPAWN RESULT = " + !result);
return !SettingsStorage.GetFieldValue<bool>(SettingsField);
}
else
Expand Down
12 changes: 6 additions & 6 deletions WeaverCore/Features/WeaverCharm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public virtual bool Acquired
}
else
{
throw new Exception($"The settings field {StringUtilities.Prettify(nameof(acquired_settingsField))} doesn't point to a valid field");
throw new Exception($"The settings field {nameof(acquired_settingsField)} doesn't point to a valid field. Tried to access field: {acquired_settingsField}");
}
}

Expand All @@ -69,7 +69,7 @@ public virtual bool Acquired
}
else
{
throw new Exception($"The settings field {StringUtilities.Prettify(nameof(acquired_settingsField))} doesn't point to a valid field");
throw new Exception($"The settings field {nameof(acquired_settingsField)} doesn't point to a valid field. Tried to access field: {acquired_settingsField}");
}
}
}
Expand All @@ -83,7 +83,7 @@ public virtual bool Equipped
}
else
{
throw new Exception($"The settings field {StringUtilities.Prettify(nameof(equipped_settingsField))} doesn't point to a valid field");
throw new Exception($"The settings field {nameof(equipped_settingsField)} doesn't point to a valid field. Tried to access field: {equipped_settingsField}");
}
}

Expand All @@ -95,7 +95,7 @@ public virtual bool Equipped
}
else
{
throw new Exception($"The settings field {StringUtilities.Prettify(nameof(equipped_settingsField))} doesn't point to a valid field");
throw new Exception($"The settings field {nameof(equipped_settingsField)} doesn't point to a valid field. Tried to access field: {equipped_settingsField}");
}
}
}
Expand All @@ -109,7 +109,7 @@ public virtual bool NewlyCollected
}
else
{
throw new Exception($"The settings field {StringUtilities.Prettify(nameof(newlyCollected_settingsField))} doesn't point to a valid field");
throw new Exception($"The settings field {nameof(newlyCollected_settingsField)} doesn't point to a valid field. Tried to access field: {newlyCollected_settingsField}");
}
}

Expand All @@ -121,7 +121,7 @@ public virtual bool NewlyCollected
}
else
{
throw new Exception($"The settings field {StringUtilities.Prettify(nameof(newlyCollected_settingsField))} doesn't point to a valid field");
throw new Exception($"The settings field {nameof(newlyCollected_settingsField)} doesn't point to a valid field. Tried to access field: {newlyCollected_settingsField}");
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions WeaverCore/Utilities/CharmUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,13 @@ private static string ModHooks_LanguageGetHook(string key, string sheetTitle, st

public static bool GiveCharmToPlayer(IWeaverCharm charm, bool displayCollectMessage = true)
{
//WeaverLog.Log($"GIVING CHARM {charm} to player");
return GiveCharmToPlayer(GetCustomCharmID(charm), displayCollectMessage);
}

public static bool GiveCharmToPlayer(int charmID, bool displayCollectMessage = true)
{
//WeaverLog.Log($"GIVING CHARM ID {charmID} to player");
bool alreadyCollected = false;
if (PlayerData.instance.GetBool($"gotCharm_{charmID}") == true)
{
Expand All @@ -318,6 +320,10 @@ public static bool GiveCharmToPlayer(int charmID, bool displayCollectMessage = t
GameManager.instance.IncrementPlayerDataInt("charmsOwned");
}

//WeaverLog.Log("ALREADY COLLECTED = " + alreadyCollected);

//WeaverLog.Log("HAS CHARM = " + GameManager.instance.GetPlayerDataBool($"gotCharm_{charmID}"));

PlayerData.instance.SetBool($"gotCharm_{charmID}", true);
GameManager.instance.StoryRecord_acquired($"gotCharm_{charmID}");

Expand All @@ -328,8 +334,13 @@ public static bool GiveCharmToPlayer(int charmID, bool displayCollectMessage = t

if (displayCollectMessage)
{
//WeaverLog.Log("SPAWNING COLLECT MESSAGE");
ItemGetMessage.SpawnCharm(charmID);
}
//else
//{
//WeaverLog.Log("NOT SPAWNING COLLECT MESSAGE");
//}
return alreadyCollected;
}
}
Expand Down
114 changes: 114 additions & 0 deletions WeaverCore/Utilities/RendererUtilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

namespace WeaverCore.Utilities
{
public static class RendererUtilities
{
public interface IColorable
{
UnityEngine.Component BackingComponent {get;}
Color color {get; set;}
}

public class SpriteColorable : IColorable
{
public readonly SpriteRenderer BackingRenderer;
public SpriteColorable(SpriteRenderer renderer)
{
BackingRenderer = renderer;
}

public Component BackingComponent => BackingRenderer;

public Color color { get => BackingRenderer.color; set => BackingRenderer.color = color; }
}

public class GraphicColorable : IColorable
{
public readonly Graphic BackingGraphic;
public GraphicColorable(Graphic graphic)
{
BackingGraphic = graphic;
}

public Component BackingComponent => BackingGraphic;

public Color color { get => BackingGraphic.color; set => BackingGraphic.color = color; }
}

public class RendererColorable : IColorable
{
public readonly Renderer BackingRenderer;
public RendererColorable(Renderer renderer)
{
BackingRenderer = renderer;
}

public Component BackingComponent => BackingRenderer;

public Color color
{
get
{
if (BackingRenderer.sharedMaterial.HasProperty("_Color"))
{
return BackingRenderer.sharedMaterial.GetColor("_Color");
}
else
{
return BackingRenderer.sharedMaterial.GetColor("_FaceColor");
}

}
set
{
if (BackingRenderer.sharedMaterial.HasProperty("_Color"))
{
BackingRenderer.sharedMaterial.SetColor("_Color", color);
}
else
{
BackingRenderer.sharedMaterial.SetColor("_FaceColor", color);
}
//
}
}
}

public static IEnumerable<IColorable> GetObjectColorables(GameObject obj)
{
return GetObjectColorables(obj.GetComponents<Component>());
}

public static IEnumerable<IColorable> GetObjectColorableInChildren(GameObject obj)
{
return GetObjectColorables(obj.GetComponentsInChildren<Component>());
}

public static IEnumerable<IColorable> GetObjectColorables(IEnumerable<Component> components)
{
foreach (var c in components)
{
if (c is SpriteRenderer sr)
{
//WeaverLog.Log("FOUND SPRITE COLORABLE = " + sr);
yield return new SpriteColorable(sr);
}
else if (c is Graphic g)
{
//WeaverLog.Log("FOUND GRAPHIC COLORABLE = " + g);
yield return new GraphicColorable(g);
}
else if (c is Renderer r)
{
//WeaverLog.Log("FOUND RENDERERABLE COLORABLE = " + r);
yield return new RendererColorable(r);
}
}
}
}
}
11 changes: 11 additions & 0 deletions WeaverCore/Utilities/RendererUtilities.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions WeaverCore/Utilities/TypeUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

namespace WeaverCore.Utilities
{
/// <summary>
/// Contains utility functions related to types
/// </summary>
public static class TypeUtilities

/// <summary>
/// Contains utility functions related to types
/// </summary>
public static class TypeUtilities
{
static Cache<(string tName, string aName), Type> typeCache = new Cache<(string tName, string aName), Type>();

Expand Down
Loading

0 comments on commit f52e0f2

Please sign in to comment.