Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PFM] Allow Producers to take BigCraftables as input. Allow looking up producer rule input by object name #183

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions ProducerFrameworkMod/Controllers/ProducerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,8 @@ private static bool ValidateRuleProducerName(string producerName)
private static void AddRuleToRepository(ProducerRule producerRule)
{
Tuple<string, object> ruleKey = new Tuple<string, object>(producerRule.ProducerName, producerRule.InputKey);
if (RulesRepository.ContainsKey(ruleKey))
if (RulesRepository.TryGetValue(ruleKey, out var oldRule))
{
ProducerRule oldRule = RulesRepository[ruleKey];
if (oldRule.ModUniqueID != producerRule.ModUniqueID)
{
if (oldRule.OverrideMod.Contains(producerRule.ModUniqueID) &&
Expand Down Expand Up @@ -475,28 +474,34 @@ private static void AddConfigToRepository(ProducerConfig producerConfig)
public static ProducerRule GetProducerItem(string producerName, Object input)
{
ProducerRule value;
if (input == null)
{
RulesRepository.TryGetValue(new Tuple<string, object>(producerName, null), out value);
if (input == null) {
RulesRepository.TryGetValue(new Tuple<string, object>(producerName, null), out value);
return value;
}

if (RulesRepository.TryGetValue(new Tuple<string, object>(producerName, input.Name), out value))
{
return value;
}
else

if (RulesRepository.TryGetValue(new Tuple<string, object>(producerName, input.ParentSheetIndex), out value))
{
return value;
}

foreach (string tag in input.GetContextTagList())
{
RulesRepository.TryGetValue(new Tuple<string, object>(producerName, input.ParentSheetIndex), out value);
if (value == null)
{
foreach (string tag in input.GetContextTagList())
{
if (RulesRepository.TryGetValue(new Tuple<string, object>(producerName, tag), out value))
{
break;
}
}
}
if (value == null)
if (RulesRepository.TryGetValue(new Tuple<string, object>(producerName, tag), out value))
{
RulesRepository.TryGetValue(new Tuple<string, object>(producerName, input.Category), out value);
return value;
}
}

if (RulesRepository.TryGetValue(new Tuple<string, object>(producerName, input.Category), out value))
{
return value;
}

return value;
}

Expand Down
2 changes: 1 addition & 1 deletion ProducerFrameworkMod/ObjectOverrides.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal static bool PerformObjectDropInAction(Object __instance, Item dropInIte
bool failLocationCondition = false;
bool failSeasonCondition = false;

if (__instance.heldObject.Value != null && !__instance.name.Equals("Crystalarium") || input.bigCraftable.Value)
if (__instance.heldObject.Value != null && !__instance.name.Equals("Crystalarium"))
{
return true;
}
Expand Down