Skip to content

Commit

Permalink
1.1.42.847
Browse files Browse the repository at this point in the history
  • Loading branch information
SphereII committed Nov 11, 2024
1 parent b23908f commit 72bb756
Show file tree
Hide file tree
Showing 10 changed files with 822 additions and 810 deletions.
1,478 changes: 748 additions & 730 deletions Mods/0-SCore/Config/blocks.xml

Large diffs are not rendered by default.

18 changes: 4 additions & 14 deletions Mods/0-SCore/Features/Fire/Harmony/ChunkSetBlock.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
using HarmonyLib;
using UnityEngine;

namespace Features.Fire.Harmony
{
namespace Features.Fire.Harmony {
[HarmonyPatch(typeof(Chunk))]
[HarmonyPatch("SetBlock")]

public class ChunkSetBlock
{
public static void Postfix(Chunk __instance, int ___m_X, int ___m_Z, int x, int y, int z, bool _fromReset )
{
public class ChunkSetBlock {
public static void Postfix(Chunk __instance, int ___m_X, int ___m_Z, int x, int y, int z, bool _fromReset) {
if (!_fromReset) return;
// If the POI is being reset, clear the fire.
var vector3I = new Vector3i((___m_X << 4) + x, y, (___m_Z << 4) + z);
var fireMap = FireManager.Instance?.GetFireMap();
if (fireMap == null) return;
if (fireMap.ContainsKey(vector3I))
{
FireManager.Instance?.RemoveFire(vector3I);
}

FireManager.Instance?.RemoveFire(vector3I);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public override void ProcessPackage(World world, GameManager callbacks)
if (world == null)
{
return;
}
}
//FireManager.Instance.AddBlock(_position);
FireManager.Instance.Add(_position, _entityThatCausedIt);
FireManager.Instance?.Add(_position, _entityThatCausedIt);
}
}

2 changes: 1 addition & 1 deletion Mods/0-SCore/ModInfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<Description value="SCore Mod" />
<DisplayName value="0-SCore" />
<Website value="" />
<Version value="1.1.36.1627" />
<Version value="1.1.42.847" />
</xml>
4 changes: 2 additions & 2 deletions Mods/0-SCore/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@
// [assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("20.0.*")]

[assembly: AssemblyVersion("1.1.36.1627")]
[assembly: AssemblyFileVersion("1.1.36.1627")]
[assembly: AssemblyVersion("1.1.42.0847")]
[assembly: AssemblyFileVersion("1.1.42.0847")]
16 changes: 16 additions & 0 deletions Mods/0-SCore/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ Direct Download to the 0-SCore.zip available on gitlab mirror: https://github.co
### Change Logs

[ Change Log ]
Version: 1.1.42.847
[ ConfigurationBlock ]
- Added new section called "AdvancedQuests" to allow more control over quests.

[ Fire Manager ]
- Added a null check for the NetPackage for AddFirePosition
- Removed extra checks that may have been block fire from being cleared on quest reset

[ GotoPOISDX ]
- Added new Property block in ConfigurationBlock called AdvancedQuests
- New Property value in AdvancedQuests block in ConfigurationBlock for re-using quest locations
- If "ReusePOILocations" is set to true, it will not filter quest locations based on if they were already visited.

[ SpawnCube2SDX ]
- Added potential fix for duplicate spawns.

Version: 1.1.36.1627
[ Client Kill Event ]
- Changed ClientKill() patch to be a Prefix vs Postfix to fix an issue where it'd fire multiple times
Expand Down
Binary file modified Mods/0-SCore/SCore.dll
Binary file not shown.
Binary file modified Mods/0-SCore/SCore.pdb
Binary file not shown.
7 changes: 6 additions & 1 deletion Mods/0-SCore/Scripts/Blocks/BlockSpawnCube2SDX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,13 @@ public override bool UpdateTick(WorldBase _world, int _clrIdx, Vector3i _blockPo

ApplySignData(entity as EntityAlive, _blockPos);


_blockValue.meta++;
GameManager.Instance.World.SetBlockRPC(_blockPos, _blockValue);
if (_blockValue.meta < _maxSpawned)
{
GameManager.Instance.World.SetBlockRPC(_blockPos, _blockValue);
}

}

DestroySelf(_blockPos, _blockValue);
Expand Down
103 changes: 43 additions & 60 deletions Mods/0-SCore/Scripts/Quests/QuestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,44 @@

public static class QuestUtils
{
private static readonly string AdvFeatureClass = "AdvancedQuests";
private static readonly string Feature = "ReusePOILocations";


public static PrefabInstance FindPrefab(string poiName, Vector3 startPosition, ref List<Vector2> usedPOILocations, BiomeFilterTypes biomeFilterType = BiomeFilterTypes.AnyBiome, string biomeFilter = "")
{
//var listOfPrefabs = GameManager.Instance.World.ChunkClusters[0].ChunkProvider.GetDynamicPrefabDecorator().GetPOIPrefabs().FindAll(instance => instance.name.Contains(poiName));
var listOfPrefabs = GameManager.Instance.World.ChunkClusters[0].ChunkProvider.GetDynamicPrefabDecorator().GetDynamicPrefabs().FindAll(instance => instance.name.Contains(poiName));
if (listOfPrefabs == null)
{
if (GamePrefs.GetBool(EnumGamePrefs.DebugMenuEnabled))
{
Log.Out($"GotoPOISDX: No Prefabs by this name found: {poiName} Biome Filter Type: {biomeFilterType} Biome Filter: {biomeFilter}");
}
return null;
}

// Filter the prefab list if there's an exact name
var filteredPrefabs = listOfPrefabs.FindAll(instance => instance.name == poiName);
if (filteredPrefabs.Count > 0)
listOfPrefabs = filteredPrefabs;

// Find the closes Prefab
var prefab = QuestUtils.FindClosesPrefabs(startPosition, listOfPrefabs, usedPOILocations, biomeFilterType, biomeFilter);
if (prefab == null)
{
return null;
}
var prefab = FindClosesPrefabs(startPosition, listOfPrefabs, usedPOILocations, biomeFilterType, biomeFilter);
return prefab;
}
public static PrefabInstance FindClosesPrefabs(Vector3 position, List<PrefabInstance> prefabs, List<Vector2> usedPOILocations, BiomeFilterTypes biomeFilterType, string biomeFilter)
{
PrefabInstance prefab = null;
float minDist = Mathf.Infinity;
var minDist = Mathf.Infinity;
string[] array = null;

foreach (var t in prefabs)
{
// Have we already went to this one?
Vector2 vector = new Vector2((float)t.boundingBoxPosition.x, (float)t.boundingBoxPosition.z);
if (usedPOILocations != null && usedPOILocations.Contains(vector))
continue;
var vector = new Vector2(t.boundingBoxPosition.x, t.boundingBoxPosition.z);
if (Configuration.CheckFeatureStatus(AdvFeatureClass, Feature))
{
if (usedPOILocations != null && usedPOILocations.Contains(vector)) continue;
}



// Check if there's a biome filter.
if (biomeFilterType != BiomeFilterTypes.AnyBiome)
{
BiomeDefinition biomeAt = GameManager.Instance.World.ChunkCache.ChunkProvider.GetBiomeProvider().GetBiomeAt((int)vector.x, (int)vector.y);
var biomeAt = GameManager.Instance.World.ChunkCache.ChunkProvider.GetBiomeProvider().GetBiomeAt((int)vector.x, (int)vector.y);
if (biomeFilterType == BiomeFilterTypes.OnlyBiome && biomeAt.m_sBiomeName != biomeFilter)
{
if (GamePrefs.GetBool(EnumGamePrefs.DebugMenuEnabled))
Expand All @@ -62,24 +55,18 @@ public static PrefabInstance FindClosesPrefabs(Vector3 position, List<PrefabInst
}
if (biomeFilterType == BiomeFilterTypes.ExcludeBiome)
{
if (array == null)
{
array = biomeFilter.Split(new char[]
{
','
});
}
bool flag = false;
for (int j = 0; j < array.Length; j++)
array ??= biomeFilter.Split(new char[] {
','
});
var flag = false;
for (var j = 0; j < array.Length; j++)
{
if (biomeAt.m_sBiomeName == array[j])
{
if (GamePrefs.GetBool(EnumGamePrefs.DebugMenuEnabled))
Log.Out($"GotoPOISDX: Prefab excluded based on Biome Filter Type: {biomeFilterType} Biome Filter: {biomeFilter}");

flag = true;
break;
}
if (biomeAt.m_sBiomeName != array[j]) continue;
if (GamePrefs.GetBool(EnumGamePrefs.DebugMenuEnabled))
Log.Out($"GotoPOISDX: Prefab excluded based on Biome Filter Type: {biomeFilterType} Biome Filter: {biomeFilter}");

flag = true;
break;
}
if (flag)
{
Expand All @@ -88,18 +75,16 @@ public static PrefabInstance FindClosesPrefabs(Vector3 position, List<PrefabInst
}
}

float dist = Vector3.Distance(t.boundingBoxPosition, position);
var dist = Vector3.Distance(t.boundingBoxPosition, position);
if (GamePrefs.GetBool(EnumGamePrefs.DebugMenuEnabled))
Log.Out($"GotoPOISDX: Prefab {t.name} Found at {t.boundingBoxPosition} Distance: {dist} {biomeFilterType} Biome Filter: {biomeFilter}");

if (dist < minDist)
{
if (GamePrefs.GetBool(EnumGamePrefs.DebugMenuEnabled))
if (prefab != null)
Log.Out($"GotoPOISDX: Found closer Prefab {t.name} than {prefab.name} Old distance {minDist}");
prefab = t;
minDist = dist;
}
if (!(dist < minDist)) continue;
if (GamePrefs.GetBool(EnumGamePrefs.DebugMenuEnabled))
if (prefab != null)
Log.Out($"GotoPOISDX: Found closer Prefab {t.name} than {prefab.name} Old distance {minDist}");
prefab = t;
minDist = dist;
}

return prefab;
Expand Down Expand Up @@ -144,27 +129,26 @@ public static PrefabInstance GetRandomPOINearTrader(
BiomeFilterTypes biomeFilterType = BiomeFilterTypes.AnyBiome,
string biomeFilter = "")
{
World world = GameManager.Instance.World;
var world = GameManager.Instance.World;

int minDistanceTier = minSearchDistance < 0 ? 0 : GetTraderPrefabListTier(minSearchDistance);
int maxDistanceTier = maxSearchDistance < 0 ? 2 : GetTraderPrefabListTier(maxSearchDistance);
var minDistanceTier = minSearchDistance < 0 ? 0 : GetTraderPrefabListTier(minSearchDistance);
var maxDistanceTier = maxSearchDistance < 0 ? 2 : GetTraderPrefabListTier(maxSearchDistance);

for (int distanceTier = minDistanceTier; distanceTier <= maxDistanceTier; distanceTier++)
for (var distanceTier = minDistanceTier; distanceTier <= maxDistanceTier; distanceTier++)
{
List<PrefabInstance> prefabsForTrader = QuestEventManager.Current.GetPrefabsForTrader(
var prefabsForTrader = QuestEventManager.Current.GetPrefabsForTrader(
trader.traderArea,
difficulty,
distanceTier,
world.GetGameRandom());

if (prefabsForTrader != null)
if (prefabsForTrader == null) continue;
// GetPrefabsForTrader shuffles the prefabs before returning them, so we can just
// iterate through the list and still send players to "random" POIs
for (var j = 0; j < prefabsForTrader.Count; j++)
{
// GetPrefabsForTrader shuffles the prefabs before returning them, so we can just
// iterate through the list and still send players to "random" POIs
for (int j = 0; j < prefabsForTrader.Count; j++)
{
PrefabInstance prefabInstance = prefabsForTrader[j];
if (ValidPrefabForQuest(
var prefabInstance = prefabsForTrader[j];
if (ValidPrefabForQuest(
trader,
prefabInstance,
questTag,
Expand All @@ -176,9 +160,8 @@ public static PrefabInstance GetRandomPOINearTrader(
biomeFilter,
minSearchDistance,
maxSearchDistance))
{
return prefabInstance;
}
{
return prefabInstance;
}
}
}
Expand Down

0 comments on commit 72bb756

Please sign in to comment.