Skip to content

Commit

Permalink
Removed dependency on Friendlies
Browse files Browse the repository at this point in the history
  • Loading branch information
Digitalroot committed Aug 15, 2021
1 parent 8b85be2 commit ea83184
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public EpicValheimBounties()
&& Valheim.Common.Utils.DoesPluginExist(Valheim.EpicLoot.Adventure.Bounties.Main.RRRCore)
&& Valheim.Common.Utils.DoesPluginExist(Valheim.EpicLoot.Adventure.Bounties.Main.RRRNpcs)
&& Valheim.Common.Utils.DoesPluginExist(Valheim.EpicLoot.Adventure.Bounties.Main.RRRBetterRaids)
&& Valheim.Common.Utils.DoesPluginExist(Valheim.EpicLoot.Adventure.Bounties.Main.Friendlies)
&& Valheim.Common.Utils.DoesPluginExist(Valheim.EpicLoot.Adventure.Bounties.Main.MonsterLabZ)
;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Digitalroot.EpicLoot.Bounties.EpicValheim/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Digitalroot.EpicLoot.Bounties.EpicValheim
[BepInDependency(Digitalroot.Valheim.EpicLoot.Adventure.Bounties.Main.RRRMonsters)]
public class Main : BaseUnityPlugin
{
public const string Version = "1.0.0";
public const string Version = "1.0.1";
public const string Name = "Digitalroot Valheim EpicLoot Adventure Bounties for Epic Valheim";

// ReSharper disable MemberCanBePrivate.Global
Expand Down Expand Up @@ -43,6 +43,7 @@ private void Awake()
{
try
{
Config.Bind("General", "NexusID", 1401, "Nexus mod ID for updates");
_harmony = Harmony.CreateAndPatchAll(typeof(Main).Assembly, Guid);
}
catch (Exception e)
Expand Down
31 changes: 19 additions & 12 deletions src/Digitalroot.Valheim.EpicLoot.Bounties/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ namespace Digitalroot.Valheim.EpicLoot.Adventure.Bounties
[BepInDependency(RRRNpcs, BepInDependency.DependencyFlags.SoftDependency)]
[BepInDependency(RRRMonsters, BepInDependency.DependencyFlags.SoftDependency)]
[BepInDependency(RRRBetterRaids, BepInDependency.DependencyFlags.SoftDependency)]
[BepInDependency(Friendlies, BepInDependency.DependencyFlags.SoftDependency)]
[BepInDependency(Bears, BepInDependency.DependencyFlags.SoftDependency)]
public class Main : BaseUnityPlugin, ITraceableLogging
{
public const string Version = "2.0.3";
public const string Version = "2.0.4";
public const string Name = "Digitalroot EpicLoot Adventure Bounties";

// ReSharper disable once MemberCanBePrivate.Global
Expand All @@ -42,7 +41,6 @@ public class Main : BaseUnityPlugin, ITraceableLogging
// ReSharper disable InconsistentNaming
public const string MonsterLabZ = "DYBAssets";
public const string Bears = "som.Bears";
public const string Friendlies = "som.Friendlies";
public const string CustomRaids = "asharppen.valheim.custom_raids";
public const string SpawnThat = "asharppen.valheim.spawn_that";
public const string RRRCore = "com.alexanderstrada.rrrcore";
Expand All @@ -58,7 +56,7 @@ public Main()
Instance = this;
#if DEBUG
EnableTrace = true;
Log.RegisterSource(this);
Log.RegisterSource(Instance);
#else
EnableTrace = false;
#endif
Expand All @@ -68,6 +66,7 @@ public Main()
[UsedImplicitly]
private void Awake()
{
Config.Bind("General", "NexusID", 1401, "Nexus mod ID for updates");
_softDependencies = new SoftDependencies();
_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), Guid);
}
Expand All @@ -84,17 +83,21 @@ public void OnObjectDBCopyOtherDB(ref ObjectDB objectDB)
try
{
ClearBounties();
Log.Debug(this, _softDependencies.ToString());
Log.Debug(Instance, _softDependencies.ToString());
if (_isVanillaBountiesEnabled) AddToBountiesCollection(new VanillaBounties());
Log.Trace(Instance, $"_isVanillaBountiesEnabled : {_isVanillaBountiesEnabled}");
if (_isBearsBountiesEnabled) AddToBountiesCollection(new BearsBounties());
Log.Trace(Instance, $"_isBearsBountiesEnabled : {_isBearsBountiesEnabled}");
if (_isMonsterLabZBountiesEnabled) AddToBountiesCollection(new MonsterLabZBounties());
Log.Trace(Instance, $"_isMonsterLabZBountiesEnabled : {_isMonsterLabZBountiesEnabled}");
if (_isRRRMonsterBountiesEnabled) AddToBountiesCollection(new RRRMonsterBounties());
Log.Trace(Instance, $"_isRRRMonsterBountiesEnabled : {_isRRRMonsterBountiesEnabled}");
AddBounties();
PrintBounties();
}
catch (Exception e)
{
Log.Error(this, e);
Log.Error(Instance, e);
}
}

Expand All @@ -107,14 +110,18 @@ public void AddToBountiesCollection(AbstractBounties bounties)
private void AddBounties()
{
if (!global::EpicLoot.EpicLoot.IsAdventureModeEnabled()) return;
Log.Debug(this, "Adding Bounties to EpicLoot");
Log.Debug(Instance, "Adding Bounties to EpicLoot");

// Log.Trace(this, $"_bountiesList == null : {_bountiesList == null}");
// Log.Trace(this, $"_bountiesList.Count : {_bountiesList?.Count}");

foreach (var bountiesCollection in _bountiesList)
Log.Trace(Instance, $"_bountiesList == null : {_bountiesList == null}");
if (_bountiesList == null) return;
Log.Trace(Instance, $"_bountiesList.Count : {_bountiesList.Count}");

foreach (AbstractBounties bountiesCollection in _bountiesList)
{
// Log.Trace(this, $"bountiesCollection.IsDependenciesResolved : {bountiesCollection.IsDependenciesResolved}");
Log.Trace(Instance, $"bountiesCollection.GetType().FullName : {bountiesCollection.GetType().FullName}");
Log.Trace(Instance, $"bountiesCollection.IsDependenciesResolved : {bountiesCollection.IsDependenciesResolved}");
Log.Trace(Instance, bountiesCollection);

if (!bountiesCollection.IsDependenciesResolved) continue;
foreach (var biome in Enum.GetValues(typeof(Heightmap.Biome)).Cast<Heightmap.Biome>())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public RRRMonsterBounties()
&& Common.Utils.DoesPluginExist(Main.RRRCore)
&& Common.Utils.DoesPluginExist(Main.RRRNpcs)
&& Common.Utils.DoesPluginExist(Main.RRRBetterRaids)
&& Common.Utils.DoesPluginExist(Main.Friendlies);
;
}

#region Overrides of AbstractBounties
Expand Down
5 changes: 2 additions & 3 deletions src/Digitalroot.Valheim.EpicLoot.Bounties/SoftDependencies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public SoftDependencies()
RRRNpcs = Common.Utils.DoesPluginExist(Main.RRRNpcs);
RRRMonsters = Common.Utils.DoesPluginExist(Main.RRRMonsters);
RRRBetterRaids = Common.Utils.DoesPluginExist(Main.RRRBetterRaids);
Friendlies = Common.Utils.DoesPluginExist(Main.Friendlies);
}

public bool MonsterLabZ { get; }
Expand All @@ -25,7 +24,7 @@ public SoftDependencies()
public bool RRRNpcs { get; }
public bool RRRMonsters { get; }
public bool RRRBetterRaids { get; }
public bool Friendlies { get; }
// public bool Friendlies { get; }
public bool Bears { get; }

#region Overrides of Object
Expand All @@ -41,7 +40,7 @@ public override string ToString()
$"{nameof(RRRNpcs)} : {RRRNpcs}{Environment.NewLine}" +
$"{nameof(RRRMonsters)} : {RRRMonsters}{Environment.NewLine}" +
$"{nameof(RRRBetterRaids)} : {RRRBetterRaids}{Environment.NewLine}" +
$"{nameof(Friendlies)} : {Friendlies}{Environment.NewLine}" +
// $"{nameof(Friendlies)} : {Friendlies}{Environment.NewLine}" +
$"{nameof(Bears)} : {Bears}{Environment.NewLine}";
}

Expand Down

0 comments on commit ea83184

Please sign in to comment.