Skip to content

Commit

Permalink
Renamed GetUnityToSim() and ToSystemList
Browse files Browse the repository at this point in the history
  • Loading branch information
gurrenm3 committed Mar 13, 2021
1 parent 0605161 commit 8267a87
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static List<T> ToIl2CppList<T>(this IEnumerable<T> enumerable) where T :
return il2CppList;
}

public static System.Collections.Generic.List<T> ToSystemList<T>(this IEnumerable<T> enumerable) where T : Il2CppSystem.Object
public static System.Collections.Generic.List<T> ToList<T>(this IEnumerable<T> enumerable) where T : Il2CppSystem.Object
{
System.Collections.Generic.List<T> list = new System.Collections.Generic.List<T>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ namespace BTD_Mod_Helper.Extensions
{
public static partial class Il2CppGenericsExt
{
/// <summary>
/// Not tested
/// </summary>
public static System.Collections.Generic.List<T> ToSystemList<T>(this List<T> il2CppList)
public static System.Collections.Generic.List<T> ToList<T>(this List<T> il2CppList)
{
System.Collections.Generic.List<T> newList = new System.Collections.Generic.List<T>();
foreach (T item in il2CppList)
Expand All @@ -19,9 +16,6 @@ public static System.Collections.Generic.List<T> ToSystemList<T>(this List<T> il
return newList;
}

/// <summary>
/// Not tested
/// </summary>
public static T[] ToArray<T>(this List<T> il2CppList)
{
T[] newArray = new T[] { };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static Il2CppSystem.Object GetItem(this IEnumerator enumerator, int index
}


public static List<Il2CppSystem.Object> ToSystemList(this IEnumerator enumerator)
public static List<Il2CppSystem.Object> ToList(this IEnumerator enumerator)
{
List<Il2CppSystem.Object> newList = new List<Il2CppSystem.Object>();
while (enumerator.MoveNext())
Expand Down
12 changes: 6 additions & 6 deletions BTD Mod Helper Core/Extensions/InGameExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static Map GetMap(this InGame inGame)
/// </summary>
public static Simulation GetSimulation(this InGame inGame)
{
return inGame.GetUnityToSim()?.simulation;
return inGame.GetUnityToSimulation()?.simulation;
}

/// <summary>
Expand Down Expand Up @@ -63,7 +63,7 @@ public static List<Tower> GetTowers(this InGame inGame)

public static List<TowerToSimulation> GetTowerSims(this InGame inGame)
{
return inGame.GetUnityToSim()?.GetAllTowers()?.ToSystemList();
return inGame.GetUnityToSimulation()?.GetAllTowers()?.ToList();
}

public static List<Bloon> GetBloons(this InGame inGame)
Expand All @@ -73,7 +73,7 @@ public static List<Bloon> GetBloons(this InGame inGame)

public static List<BloonToSimulation> GetBloonSims(this InGame inGame)
{
return inGame.GetUnityToSim()?.GetAllBloons()?.ToSystemList();
return inGame.GetUnityToSimulation()?.GetAllBloons()?.ToList();
}

public static List<Projectile> GetProjectiles(this InGame inGame)
Expand All @@ -92,14 +92,14 @@ public static TowerManager GetTowerManager(this InGame inGame)
public static List<AbilityToSimulation> GetAbilities(this InGame inGame)
{
#if BloonsTD6
return inGame.GetUnityToSim()?.GetAllAbilities(true)?.ToSystemList();
return inGame.GetUnityToSimulation()?.GetAllAbilities(true)?.ToList();
#elif BloonsAT
return inGame.GetUnityToSim()?.GetAllAbilities()?.ToSystemList();
return inGame.GetUnityToSimulation()?.GetAllAbilities()?.ToList();
#endif
}


public static UnityToSimulation GetUnityToSim(this InGame inGame)
public static UnityToSimulation GetUnityToSimulation(this InGame inGame)
{
#if BloonsTD6
return inGame.bridge;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void SpawnBloonModel(this BloonModel bloonModel)
#if BloonsTD6
Il2CppSystem.Collections.Generic.List<Bloon.ChargedMutator> chargedMutators = new Il2CppSystem.Collections.Generic.List<Bloon.ChargedMutator>();
Il2CppSystem.Collections.Generic.List<BehaviorMutator> nonChargedMutators = new Il2CppSystem.Collections.Generic.List<BehaviorMutator>();
spawner.Emit(bloonModel, InGame.instance.GetUnityToSim().GetCurrentRound(), 0, chargedMutators, nonChargedMutators);
spawner.Emit(bloonModel, InGame.instance.GetUnityToSimulation().GetCurrentRound(), 0, chargedMutators, nonChargedMutators);
#elif BloonsAT
spawner.Emit(bloonModel);
#endif
Expand Down Expand Up @@ -63,11 +63,11 @@ public static Il2CppReferenceArray<BloonEmissionModel> CreateBloonEmissionModel(
/// </summary>
public static List<BloonToSimulation> GetBloonSims(this BloonModel bloonModel)
{
Il2CppSystem.Collections.Generic.List<BloonToSimulation> bloonSims = InGame.instance?.GetUnityToSim()?.GetAllBloons();
Il2CppSystem.Collections.Generic.List<BloonToSimulation> bloonSims = InGame.instance?.GetUnityToSimulation()?.GetAllBloons();
if (bloonSims is null || !bloonSims.Any())
return null;

List<BloonToSimulation> results = bloonSims.Where(b => b.GetBaseModel().IsEqual(bloonModel)).ToSystemList();
List<BloonToSimulation> results = bloonSims.Where(b => b.GetBaseModel().IsEqual(bloonModel)).ToList();
return results;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static partial class BloonExt
/// </summary>
public static BloonToSimulation GetBloonToSim(this Bloon bloon)
{
return InGame.instance.GetUnityToSim().GetAllBloons().FirstOrDefault(b => b.id == bloon.Id);
return InGame.instance.GetUnityToSimulation().GetAllBloons().FirstOrDefault(b => b.id == bloon.Id);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void SellTower(this Tower tower)
/// </summary>
public static TowerToSimulation GetTowerSim(this Tower tower)
{
var towerSims = InGame.instance?.GetUnityToSim()?.GetAllTowers();
var towerSims = InGame.instance?.GetUnityToSimulation()?.GetAllTowers();

#if BloonsTD6
return towerSims.FirstOrDefault(sim => sim.tower == tower);
Expand Down
2 changes: 1 addition & 1 deletion BloonsTD6 Mod Helper/Extensions/GameExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static UI GetUI(this Game game)
/// </summary>
public static List<TowerModel> GetTowerListForTowerType(this Game game, string towerSet)
{
return Helpers.GetTowerListForTowerType(towerSet).ToSystemList();
return Helpers.GetTowerListForTowerType(towerSet).ToList();
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions BloonsTD6 Mod Helper/Extensions/InGameExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,17 @@ public static void SpawnBloons(this InGame inGame, string bloonName, int number,

public static void SpawnBloons(this InGame inGame, System.Collections.Generic.List<BloonEmissionModel> bloonEmissionModels)
{
inGame.GetUnityToSim().SpawnBloons(bloonEmissionModels.ToIl2CppReferenceArray(), inGame.GetUnityToSim().GetCurrentRound(), 0);
inGame.GetUnityToSimulation().SpawnBloons(bloonEmissionModels.ToIl2CppReferenceArray(), inGame.GetUnityToSimulation().GetCurrentRound(), 0);
}

public static void SpawnBloons(this InGame inGame, List<BloonEmissionModel> bloonEmissionModels)
{
inGame.GetUnityToSim().SpawnBloons(bloonEmissionModels.ToIl2CppReferenceArray(), inGame.GetUnityToSim().GetCurrentRound(), 0);
inGame.GetUnityToSimulation().SpawnBloons(bloonEmissionModels.ToIl2CppReferenceArray(), inGame.GetUnityToSimulation().GetCurrentRound(), 0);
}

public static void SpawnBloons(this InGame inGame, Il2CppReferenceArray<BloonEmissionModel> bloonEmissionModels)
{
inGame.GetUnityToSim().SpawnBloons(bloonEmissionModels, inGame.GetUnityToSim().GetCurrentRound(), 0);
inGame.GetUnityToSimulation().SpawnBloons(bloonEmissionModels, inGame.GetUnityToSimulation().GetCurrentRound(), 0);
}

public static void SpawnBloons(this InGame inGame, int round)
Expand Down

0 comments on commit 8267a87

Please sign in to comment.