Skip to content
This repository has been archived by the owner on Dec 30, 2024. It is now read-only.

Commit

Permalink
fix #40
Browse files Browse the repository at this point in the history
  • Loading branch information
Chasmical committed Aug 29, 2021
1 parent 1a29951 commit 9bdf371
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion RogueLibsCore/Patches/Patches_Unlocks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public static void InitializeUnlockWrappers()
{
if (unlock.onlyInCharacterCreation && !unlock.unavailable)
unlock.unavailable = true;
if (!unlock.unavailable) unlock.onlyInCharacterCreation = true;
wrapper = new TraitUnlock(unlock);
}
else if (unlock.unlockType == UnlockTypes.Ability)
Expand Down Expand Up @@ -158,6 +159,25 @@ public static void InitializeUnlockWrappers()
}
}
#pragma warning restore CS0618 // Type or member is obsolete
private static void ReverseRogueLibsEffects(Unlock unlock)
{
if (unlock.unlockType == UnlockTypes.Item)
{
if (unlock.unavailable && unlock.freeItem && unlock.onlyInCharacterCreation)
unlock.unavailable = false;
else if (unlock.unavailable && !unlock.freeItem && unlock.onlyInCharacterCreation)
unlock.unavailable = false;
else if (!unlock.unavailable && unlock.freeItem && unlock.onlyInCharacterCreation)
unlock.freeItem = unlock.onlyInCharacterCreation = false;
}
else if (unlock.unlockType == UnlockTypes.Trait)
{
if (!unlock.unavailable && unlock.onlyInCharacterCreation)
unlock.onlyInCharacterCreation = false;
if (unlock.unavailable && unlock.onlyInCharacterCreation)
unlock.unavailable = false;
}
}
public static void AddUnlockFull(UnlockWrapper wrapper, bool alreadyLoaded = false)
{
try
Expand Down Expand Up @@ -260,9 +280,12 @@ public static IEnumerator SaveEnumerator(Unlocks __instance)
Directory.CreateDirectory(text + "/CloudData/");
}
SessionDataBig sdb = GameController.gameController.sessionDataBig;

List<Unlock> unlocks = sdb.unlocks.ConvertAll(CloneUnlock);
unlocks.ForEach(ReverseRogueLibsEffects);
UnlockSaveData unlockSaveData = new UnlockSaveData
{
unlocks = sdb.unlocks,
unlocks = unlocks,
highScores = sdb.highScores,
customCharacterSlots = sdb.customCharacterSlots,
storedItem = sdb.storedItem,
Expand Down Expand Up @@ -667,5 +690,37 @@ public static bool Unlocks_LoadUnlockData2(Unlocks __instance, bool secondTry, b
}
return false;
}

public static Unlock CloneUnlock(Unlock unlock) => new Unlock(unlock.unlockName, unlock.unlockType, unlock.unlocked)
{
__RogueLibsCustom = null,
agents = unlock.agents.ToList(),
cancellations = unlock.cancellations.ToList(),
cantLose = unlock.cantLose,
cantSwap = unlock.cantSwap,
categories = unlock.categories.ToList(),
cost = unlock.cost,
cost2 = unlock.cost2,
cost3 = unlock.cost3,
dcUnlock = unlock.dcUnlock,
freeItem = unlock.freeItem,
isUpgrade = unlock.isUpgrade,
leadingBigQuests = unlock.leadingBigQuests.ToList(),
leadingItems = unlock.leadingItems.ToList(),
leadingTraits = unlock.leadingTraits.ToList(),
notActive = unlock.notActive,
notOnClient = unlock.notOnClient,
nowAvailable = unlock.nowAvailable,
onlyInCharacterCreation = unlock.onlyInCharacterCreation,
prerequisites = unlock.prerequisites.ToList(),
progressCount = unlock.progressCount,
progressList = unlock.progressList.ToList(),
recommendations = unlock.recommendations.ToList(),
removal = unlock.removal,
replacing = unlock.replacing,
specialAbilities = unlock.specialAbilities.ToList(),
unavailable = unlock.unavailable,
upgrade = unlock.upgrade,
};
}
}

0 comments on commit 9bdf371

Please sign in to comment.