Cleanup of usings
This commit is contained in:
parent
c34fd5eb0d
commit
d5b7f0aa26
@ -1,8 +1,8 @@
|
|||||||
using System;
|
using Aki.Common;
|
||||||
|
using astealz.SmartSpawnController.Utils;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Aki.Common;
|
|
||||||
using astealz.SmartSpawnController.Utils;
|
|
||||||
|
|
||||||
namespace Aki.SinglePlayer.Utils
|
namespace Aki.SinglePlayer.Utils
|
||||||
{
|
{
|
||||||
|
208
src/Aki/ZLib.cs
208
src/Aki/ZLib.cs
@ -1,127 +1,127 @@
|
|||||||
using System;
|
using ComponentAce.Compression.Libs.zlib;
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using ComponentAce.Compression.Libs.zlib;
|
|
||||||
|
|
||||||
namespace Aki.Common
|
namespace Aki.Common
|
||||||
{
|
{
|
||||||
public enum ZlibCompression
|
public enum ZlibCompression
|
||||||
{
|
{
|
||||||
Store = 0,
|
Store = 0,
|
||||||
Fastest = 1,
|
Fastest = 1,
|
||||||
Fast = 3,
|
Fast = 3,
|
||||||
Normal = 5,
|
Normal = 5,
|
||||||
Ultra = 7,
|
Ultra = 7,
|
||||||
Maximum = 9
|
Maximum = 9
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Zlib
|
public static class Zlib
|
||||||
{
|
{
|
||||||
// Level | CM/CI FLG
|
// Level | CM/CI FLG
|
||||||
// ----- | ---------
|
// ----- | ---------
|
||||||
// 1 | 78 01
|
// 1 | 78 01
|
||||||
// 2 | 78 5E
|
// 2 | 78 5E
|
||||||
// 3 | 78 5E
|
// 3 | 78 5E
|
||||||
// 4 | 78 5E
|
// 4 | 78 5E
|
||||||
// 5 | 78 5E
|
// 5 | 78 5E
|
||||||
// 6 | 78 9C
|
// 6 | 78 9C
|
||||||
// 7 | 78 DA
|
// 7 | 78 DA
|
||||||
// 8 | 78 DA
|
// 8 | 78 DA
|
||||||
// 9 | 78 DA
|
// 9 | 78 DA
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if the file is ZLib compressed
|
/// Check if the file is ZLib compressed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Data">Data</param>
|
/// <param name="Data">Data</param>
|
||||||
/// <returns>If the file is Zlib compressed</returns>
|
/// <returns>If the file is Zlib compressed</returns>
|
||||||
public static bool IsCompressed(byte[] Data)
|
public static bool IsCompressed(byte[] Data)
|
||||||
{
|
{
|
||||||
// We need the first two bytes;
|
// We need the first two bytes;
|
||||||
// First byte: Info (CM/CINFO) Header, should always be 0x78
|
// First byte: Info (CM/CINFO) Header, should always be 0x78
|
||||||
// Second byte: Flags (FLG) Header, should define our compression level.
|
// Second byte: Flags (FLG) Header, should define our compression level.
|
||||||
|
|
||||||
if (Data == null || Data.Length < 3 || Data[0] != 0x78)
|
if (Data == null || Data.Length < 3 || Data[0] != 0x78)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (Data[1])
|
switch (Data[1])
|
||||||
{
|
{
|
||||||
case 0x01: // fastest
|
case 0x01: // fastest
|
||||||
case 0x5E: // low
|
case 0x5E: // low
|
||||||
case 0x9C: // normal
|
case 0x9C: // normal
|
||||||
case 0xDA: // max
|
case 0xDA: // max
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deflate data.
|
/// Deflate data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static byte[] Compress(byte[] data, ZlibCompression level)
|
public static byte[] Compress(byte[] data, ZlibCompression level)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[data.Length + 24];
|
byte[] buffer = new byte[data.Length + 24];
|
||||||
|
|
||||||
ZStream zs = new ZStream()
|
ZStream zs = new ZStream()
|
||||||
{
|
{
|
||||||
avail_in = data.Length,
|
avail_in = data.Length,
|
||||||
next_in = data,
|
next_in = data,
|
||||||
next_in_index = 0,
|
next_in_index = 0,
|
||||||
avail_out = buffer.Length,
|
avail_out = buffer.Length,
|
||||||
next_out = buffer,
|
next_out = buffer,
|
||||||
next_out_index = 0
|
next_out_index = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
zs.deflateInit((int)level);
|
zs.deflateInit((int)level);
|
||||||
zs.deflate(zlibConst.Z_FINISH);
|
zs.deflate(zlibConst.Z_FINISH);
|
||||||
|
|
||||||
data = new byte[zs.next_out_index];
|
data = new byte[zs.next_out_index];
|
||||||
Array.Copy(zs.next_out, 0, data, 0, zs.next_out_index);
|
Array.Copy(zs.next_out, 0, data, 0, zs.next_out_index);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Inflate data.
|
/// Inflate data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static byte[] Decompress(byte[] data)
|
public static byte[] Decompress(byte[] data)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[4096];
|
byte[] buffer = new byte[4096];
|
||||||
|
|
||||||
ZStream zs = new ZStream()
|
ZStream zs = new ZStream()
|
||||||
{
|
{
|
||||||
avail_in = data.Length,
|
avail_in = data.Length,
|
||||||
next_in = data,
|
next_in = data,
|
||||||
next_in_index = 0,
|
next_in_index = 0,
|
||||||
avail_out = buffer.Length,
|
avail_out = buffer.Length,
|
||||||
next_out = buffer,
|
next_out = buffer,
|
||||||
next_out_index = 0
|
next_out_index = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
zs.inflateInit();
|
zs.inflateInit();
|
||||||
|
|
||||||
using (MemoryStream ms = new MemoryStream())
|
using (MemoryStream ms = new MemoryStream())
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
zs.avail_out = buffer.Length;
|
zs.avail_out = buffer.Length;
|
||||||
zs.next_out = buffer;
|
zs.next_out = buffer;
|
||||||
zs.next_out_index = 0;
|
zs.next_out_index = 0;
|
||||||
|
|
||||||
int result = zs.inflate(0);
|
int result = zs.inflate(0);
|
||||||
|
|
||||||
if (result != 0 && result != 1)
|
if (result != 0 && result != 1)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ms.Write(zs.next_out, 0, zs.next_out_index);
|
ms.Write(zs.next_out, 0, zs.next_out_index);
|
||||||
}
|
}
|
||||||
while (zs.avail_in > 0 || zs.avail_out == 0);
|
while (zs.avail_in > 0 || zs.avail_out == 0);
|
||||||
|
|
||||||
return ms.ToArray();
|
return ms.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,7 +2,6 @@
|
|||||||
using EFT;
|
using EFT;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace astealz.SmartSpawnController.Behaviors
|
namespace astealz.SmartSpawnController.Behaviors
|
||||||
@ -22,12 +21,12 @@ namespace astealz.SmartSpawnController.Behaviors
|
|||||||
private readonly List<Player> players = new List<Player>(playersPool);
|
private readonly List<Player> players = new List<Player>(playersPool);
|
||||||
private readonly Dictionary<string, int> playerCounters = new Dictionary<string, int>(playersPool);
|
private readonly Dictionary<string, int> playerCounters = new Dictionary<string, int>(playersPool);
|
||||||
|
|
||||||
private readonly List<WildSpawnType> rolesToLeave =
|
private readonly List<WildSpawnType> rolesToLeave =
|
||||||
new List<WildSpawnType>(Enum.GetValues(typeof(WildSpawnType)).Length) {
|
new List<WildSpawnType>(Enum.GetValues(typeof(WildSpawnType)).Length) {
|
||||||
WildSpawnType.assault,
|
WildSpawnType.assault,
|
||||||
WildSpawnType.assaultGroup,
|
WildSpawnType.assaultGroup,
|
||||||
WildSpawnType.cursedAssault,
|
WildSpawnType.cursedAssault,
|
||||||
WildSpawnType.pmcBot
|
WildSpawnType.pmcBot
|
||||||
};
|
};
|
||||||
|
|
||||||
public bool DEBUG_ENABLED => Globals.Config.Debug;
|
public bool DEBUG_ENABLED => Globals.Config.Debug;
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Converters;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace astealz.SmartSpawnController
|
namespace astealz.SmartSpawnController
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
using astealz.SmartSpawnController.Utils;
|
using astealz.SmartSpawnController.Utils;
|
||||||
using EFT;
|
using EFT;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace astealz.SmartSpawnController
|
namespace astealz.SmartSpawnController
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
using Comfort.Common;
|
using Comfort.Common;
|
||||||
using EFT;
|
using EFT;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace astealz.SmartSpawnController
|
namespace astealz.SmartSpawnController
|
||||||
@ -13,8 +9,10 @@ namespace astealz.SmartSpawnController
|
|||||||
{
|
{
|
||||||
public static Config Config { get; set; }
|
public static Config Config { get; set; }
|
||||||
|
|
||||||
public static MapConfig CurrentMapConfig {
|
public static MapConfig CurrentMapConfig
|
||||||
get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
MapConfig config = null;
|
MapConfig config = null;
|
||||||
if (!Config.Maps.TryGetValue(LocationId, out config))
|
if (!Config.Maps.TryGetValue(LocationId, out config))
|
||||||
{
|
{
|
||||||
@ -22,10 +20,11 @@ namespace astealz.SmartSpawnController
|
|||||||
return new MapConfig();
|
return new MapConfig();
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string LocationId {
|
public static string LocationId
|
||||||
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var game = GameObject.Find("GAME");
|
var game = GameObject.Find("GAME");
|
||||||
|
@ -1,14 +1,6 @@
|
|||||||
using System;
|
using astealz.SmartSpawnController.Utils;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using astealz.SmartSpawnController.Utils;
|
|
||||||
using Comfort.Common;
|
|
||||||
using EFT;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace astealz.SmartSpawnController
|
namespace astealz.SmartSpawnController
|
||||||
{
|
{
|
||||||
@ -25,13 +17,13 @@ namespace astealz.SmartSpawnController
|
|||||||
{
|
{
|
||||||
// start console initialization
|
// start console initialization
|
||||||
EFT.StaticManager.Instance.StaticUpdate += Instance_StaticUpdate;
|
EFT.StaticManager.Instance.StaticUpdate += Instance_StaticUpdate;
|
||||||
|
|
||||||
// get config from server
|
// get config from server
|
||||||
var json = Aki.SinglePlayer.Utils.RequestHandler.GetJson($"/mods/{Name.ToLower()}/config");
|
var json = Aki.SinglePlayer.Utils.RequestHandler.GetJson($"/mods/{Name.ToLower()}/config");
|
||||||
var config = JsonConvert.DeserializeObject<Config>(json);
|
var config = JsonConvert.DeserializeObject<Config>(json);
|
||||||
|
|
||||||
Globals.Config = config;
|
Globals.Config = config;
|
||||||
|
|
||||||
// apply patches
|
// apply patches
|
||||||
isApplyPatchesSuccess = Patches.BotSpawnerPatches.Apply();
|
isApplyPatchesSuccess = Patches.BotSpawnerPatches.Apply();
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
using EFT;
|
using EFT;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace astealz.SmartSpawnController.Patches
|
namespace astealz.SmartSpawnController.Patches
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@ namespace astealz.SmartSpawnController.Patches
|
|||||||
class BotSpawnManager
|
class BotSpawnManager
|
||||||
{
|
{
|
||||||
const int poolSize = 20;
|
const int poolSize = 20;
|
||||||
|
|
||||||
private bool enabled;
|
private bool enabled;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// internal spawn wave counter
|
/// internal spawn wave counter
|
||||||
@ -83,7 +83,7 @@ namespace astealz.SmartSpawnController.Patches
|
|||||||
if (DEBUG_ENABLED)
|
if (DEBUG_ENABLED)
|
||||||
Utils.Logger.Debug("OnStart(botZones)");
|
Utils.Logger.Debug("OnStart(botZones)");
|
||||||
var mapConfig = Globals.CurrentMapConfig;
|
var mapConfig = Globals.CurrentMapConfig;
|
||||||
|
|
||||||
this.enabled = mapConfig.EnableSpawnControl;
|
this.enabled = mapConfig.EnableSpawnControl;
|
||||||
|
|
||||||
if (mapConfig.EnableUnspawn)
|
if (mapConfig.EnableUnspawn)
|
||||||
@ -113,7 +113,7 @@ namespace astealz.SmartSpawnController.Patches
|
|||||||
this.botsPerZoneBase = mapConfig.BotsPerZoneBase;
|
this.botsPerZoneBase = mapConfig.BotsPerZoneBase;
|
||||||
this.scavSpawnZones.Clear();
|
this.scavSpawnZones.Clear();
|
||||||
this.bossSpawnZones.Clear();
|
this.bossSpawnZones.Clear();
|
||||||
|
|
||||||
SetScavRoles(mapConfig.ScavRoles);
|
SetScavRoles(mapConfig.ScavRoles);
|
||||||
SetBossRoles(mapConfig.BossRoles);
|
SetBossRoles(mapConfig.BossRoles);
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
using HarmonyLib;
|
using astealz.SmartSpawnController.Utils;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Reflection.Emit;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using astealz.SmartSpawnController.Utils;
|
|
||||||
|
|
||||||
namespace astealz.SmartSpawnController.Patches
|
namespace astealz.SmartSpawnController.Patches
|
||||||
{
|
{
|
||||||
@ -14,7 +11,8 @@ namespace astealz.SmartSpawnController.Patches
|
|||||||
{
|
{
|
||||||
private static float scavWaveRetrySpawnDeltaTime = 15f;
|
private static float scavWaveRetrySpawnDeltaTime = 15f;
|
||||||
private static float lastCheckTime = 0f;
|
private static float lastCheckTime = 0f;
|
||||||
public BotSpawnerDelayPatch() : base(prefix: nameof(PatchPrefix)) {
|
public BotSpawnerDelayPatch() : base(prefix: nameof(PatchPrefix))
|
||||||
|
{
|
||||||
scavWaveRetrySpawnDeltaTime = Globals.Config.ScavWaveRetryInterval;
|
scavWaveRetrySpawnDeltaTime = Globals.Config.ScavWaveRetryInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
using astealz.SmartSpawnController.Utils;
|
using astealz.SmartSpawnController.Utils;
|
||||||
using EFT;
|
using EFT;
|
||||||
using HarmonyLib;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace astealz.SmartSpawnController.Patches
|
namespace astealz.SmartSpawnController.Patches
|
||||||
{
|
{
|
||||||
@ -38,7 +35,8 @@ namespace astealz.SmartSpawnController.Patches
|
|||||||
var bossSpawnerType = botSpawnerType.GetField("BossSpawner").FieldType;
|
var bossSpawnerType = botSpawnerType.GetField("BossSpawner").FieldType;
|
||||||
var bossLateSpawnMethod = bossSpawnerType
|
var bossLateSpawnMethod = bossSpawnerType
|
||||||
.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
|
.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
|
||||||
.Single(m => {
|
.Single(m =>
|
||||||
|
{
|
||||||
var mp = m.GetParameters();
|
var mp = m.GetParameters();
|
||||||
if (mp.Length < methodParams.Count)
|
if (mp.Length < methodParams.Count)
|
||||||
return false;
|
return false;
|
||||||
@ -59,7 +57,7 @@ namespace astealz.SmartSpawnController.Patches
|
|||||||
bossWaveDataWrapper.SetData(wave, botZone);
|
bossWaveDataWrapper.SetData(wave, botZone);
|
||||||
|
|
||||||
botSpawnManager.OnActivateBoss(bossWaveDataWrapper);
|
botSpawnManager.OnActivateBoss(bossWaveDataWrapper);
|
||||||
|
|
||||||
botSpawnManager.Callback(false);
|
botSpawnManager.Callback(false);
|
||||||
|
|
||||||
bossWaveDataWrapper.ResetData();
|
bossWaveDataWrapper.ResetData();
|
||||||
@ -75,11 +73,13 @@ namespace astealz.SmartSpawnController.Patches
|
|||||||
|
|
||||||
public WildSpawnType WildSpawnType { get; private set; }
|
public WildSpawnType WildSpawnType { get; private set; }
|
||||||
|
|
||||||
public string ZoneName {
|
public string ZoneName
|
||||||
get => nameZone;
|
{
|
||||||
set {
|
get => nameZone;
|
||||||
|
set
|
||||||
|
{
|
||||||
Logger.Info("Can't change boss 'ZoneName'");
|
Logger.Info("Can't change boss 'ZoneName'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Count => 1;
|
public int Count => 1;
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
using astealz.SmartSpawnController.Utils;
|
using astealz.SmartSpawnController.Utils;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace astealz.SmartSpawnController.Patches
|
namespace astealz.SmartSpawnController.Patches
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
using astealz.SmartSpawnController.Utils;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace astealz.SmartSpawnController.Patches
|
namespace astealz.SmartSpawnController.Patches
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// Общие сведения об этой сборке предоставляются следующим набором
|
// Общие сведения об этой сборке предоставляются следующим набором
|
||||||
|
Loading…
x
Reference in New Issue
Block a user