diff --git a/1.4/Assemblies/CombatAI.dll b/1.4/Assemblies/CombatAI.dll index 45443d7..e59bead 100644 Binary files a/1.4/Assemblies/CombatAI.dll and b/1.4/Assemblies/CombatAI.dll differ diff --git a/Media/fog1.png b/Media/fog1.png new file mode 100644 index 0000000..1b8d35b Binary files /dev/null and b/Media/fog1.png differ diff --git a/Media/fog2.png b/Media/fog2.png new file mode 100644 index 0000000..f3a4856 Binary files /dev/null and b/Media/fog2.png differ diff --git a/Source/Rule56/ITRegionGridPrepatched.cs b/Source/Rule56/ITRegionGridPrepatched.cs index 7c6079e..4330369 100644 --- a/Source/Rule56/ITRegionGridPrepatched.cs +++ b/Source/Rule56/ITRegionGridPrepatched.cs @@ -6,13 +6,13 @@ namespace CombatAI public class ITRegionGridPrepatched : ITRegionGrid { private readonly int gridId; - private ISRegion[] cells; + private readonly ISRegion[] cells; - public ITRegionGridPrepatched(Map map) : base(map) + public ITRegionGridPrepatched(Map map, int id) : base(map) { cells = new ISRegion[NumGridCells]; - gridId = ITRegionGridPrepatchedHelper.CombatAI_ReginGridCounter(map); - ITRegionGridPrepatchedHelper.CombatAI_ReginGridCounter(map) = gridId + 1; + gridId = id; + Log.Message($"gridId:{id}"); } public override void Set(int index) { @@ -115,9 +115,6 @@ public sealed class IRegionFields public static class ITRegionGridPrepatchedHelper { - [PrepatcherField] - public static extern ref int CombatAI_ReginGridCounter(Map map); - [PrepatcherField] [ValueInitializer(nameof(InitRegionFields))] public static extern ref ITRegionGridPrepatched.IRegionFields CombatAI_RegionFields(Region region); diff --git a/Source/Rule56/Maths.cs b/Source/Rule56/Maths.cs index b3b6029..1a64971 100644 --- a/Source/Rule56/Maths.cs +++ b/Source/Rule56/Maths.cs @@ -144,6 +144,7 @@ public static byte Sqr(byte a) return (byte)(a * a); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Sqrt_Fast(float x, int iterations) { if (x < 0.001f) @@ -210,6 +211,7 @@ public static float Sqrt_Fast(float x, int iterations) } return (bot + top) / 64f; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Sqrt_Fast(int a, int iterations) { if (a == 0) diff --git a/Source/Rule56/SightGrid.cs b/Source/Rule56/SightGrid.cs index 15f8363..7cef35e 100644 --- a/Source/Rule56/SightGrid.cs +++ b/Source/Rule56/SightGrid.cs @@ -73,18 +73,23 @@ public class SightGrid /// Whether this is the player grid /// public bool trackFactions = false; - private bool wait; + /// + /// SightGrid Id. + /// + public readonly int gridId; + private bool wait; - public SightGrid(SightTracker sightTracker, Settings.SightPerformanceSettings settings) + public SightGrid(SightTracker sightTracker, Settings.SightPerformanceSettings settings, int gridId) { - this.sightTracker = sightTracker; - map = sightTracker.map; - this.settings = settings; - grid = new ITSignalGrid(map); + this.gridId = gridId; + this.sightTracker = sightTracker; + map = sightTracker.map; + this.settings = settings; + grid = new ITSignalGrid(map); if (!Extern.active) grid_regions = new ITRegionGridLegacy(map); else - grid_regions = new ITRegionGridPrepatched(map); + grid_regions = new ITRegionGridPrepatched(map, gridId); asyncActions = new AsyncActions(1); ticksUntilUpdate = Rand.Int % this.settings.interval; buckets = new IBuckets(settings.buckets); @@ -140,18 +145,21 @@ public virtual void SightGridUpdate(bool gamePaused, bool performanceOkay) { if (gamePaused || performanceOkay) { - int limit = gamePaused ? 32 : 8; - int numGridCells = map.cellIndices.NumGridCells; - for (int i = 0; i < limit; i++) - { - Region region = map.regionGrid.regionGrid[regionUpdateIndex]; - grid_regions.SetRegionAt(regionUpdateIndex, (region?.valid ?? false) ? region : null); - regionUpdateIndex++; - if (regionUpdateIndex >= numGridCells) - { - regionUpdateIndex = 0; - } - } +// int limit = gamePaused ? 32 : 8; +// int numGridCells = map.cellIndices.NumGridCells; +// for (int i = 0; i < limit; i++) +// { +// Region region = map.regionGrid.regionGrid[regionUpdateIndex]; +// if (region?.valid ?? false) +// { +// grid_regions.SetRegionAt(regionUpdateIndex, region); +// regionUpdateIndex++; +// if (regionUpdateIndex >= numGridCells) +// { +// regionUpdateIndex = 0; +// } +// } +// } } } diff --git a/Source/Rule56/SightTracker.cs b/Source/Rule56/SightTracker.cs index a185de7..c0ce4ca 100644 --- a/Source/Rule56/SightTracker.cs +++ b/Source/Rule56/SightTracker.cs @@ -25,21 +25,21 @@ public SightTracker(Map map) : base(map) { fogGrid = new ITFloatGrid(map); colonistsAndFriendlies = - new SightGrid(this, Finder.Settings.SightSettings_FriendliesAndRaiders); + new SightGrid(this, Finder.Settings.SightSettings_FriendliesAndRaiders, 0); colonistsAndFriendlies.gridFog = fogGrid; colonistsAndFriendlies.playerAlliance = true; colonistsAndFriendlies.trackFactions = true; raidersAndHostiles = - new SightGrid(this, Finder.Settings.SightSettings_FriendliesAndRaiders); + new SightGrid(this, Finder.Settings.SightSettings_FriendliesAndRaiders, 1); raidersAndHostiles.trackFactions = true; insectsAndMechs = - new SightGrid(this, Finder.Settings.SightSettings_MechsAndInsects); + new SightGrid(this, Finder.Settings.SightSettings_MechsAndInsects, 2); insectsAndMechs.trackFactions = false; wildlife = - new SightGrid(this, Finder.Settings.SightSettings_Wildlife); + new SightGrid(this, Finder.Settings.SightSettings_Wildlife, 3); wildlife.trackFactions = false; factionedUInt64Map = new IThingsUInt64Map();