diff --git a/Si_SpawnConfigs/Si_SpawnConfigs.cs b/Si_SpawnConfigs/Si_SpawnConfigs.cs
index 2f7a96a..aa93286 100644
--- a/Si_SpawnConfigs/Si_SpawnConfigs.cs
+++ b/Si_SpawnConfigs/Si_SpawnConfigs.cs
@@ -21,17 +21,26 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
+#if NET6_0
using Il2Cpp;
+#else
+using System.Reflection;
+#endif
+
using MelonLoader;
using Si_SpawnConfigs;
using UnityEngine;
-using AdminExtension;
using MelonLoader.Utils;
-using System.Text.Json;
-using static Si_SpawnConfigs.SpawnConfigs;
-
-[assembly: MelonInfo(typeof(SpawnConfigs), "Admin Spawn Configs", "0.8.8", "databomb")]
+using System;
+using System.Collections.Generic;
+using SilicaAdminMod;
+using System.Linq;
+using System.IO;
+using Newtonsoft.Json;
+
+[assembly: MelonInfo(typeof(SpawnConfigs), "Admin Spawn Configs", "0.9.0", "databomb", "https://github.com/data-bomb/Silica")]
[assembly: MelonGame("Bohemia Interactive", "Silica")]
+[assembly: MelonOptionalDependencies("Admin Mod")]
namespace Si_SpawnConfigs
{
@@ -190,7 +199,7 @@ public override void OnLateInitializeMelon()
}
}
- public void Command_UndoSpawn(Il2Cpp.Player callerPlayer, String args)
+ public static void Command_UndoSpawn(Player callerPlayer, String args)
{
// validate argument count
int argumentCount = args.Split(' ').Length - 1;
@@ -214,7 +223,7 @@ public void Command_UndoSpawn(Il2Cpp.Player callerPlayer, String args)
HelperMethods.AlertAdminAction(callerPlayer, "destroyed last spawned item (" + name + ")");
}
- public void Command_Spawn(Il2Cpp.Player callerPlayer, String args)
+ public static void Command_Spawn(Player callerPlayer, String args)
{
// validate argument count
int argumentCount = args.Split(' ').Length - 1;
@@ -229,11 +238,11 @@ public void Command_Spawn(Il2Cpp.Player callerPlayer, String args)
return;
}
- Vector3 playerPosition = callerPlayer.m_ControlledUnit.WorldPhysicalCenter;
- Quaternion playerRotation = callerPlayer.m_ControlledUnit.GetFacingRotation();
+ Vector3 playerPosition = callerPlayer.ControlledUnit.WorldPhysicalCenter;
+ Quaternion playerRotation = callerPlayer.ControlledUnit.GetFacingRotation();
String spawnName = args.Split(' ')[1];
- int teamIndex = callerPlayer.m_Team.Index;
+ int teamIndex = callerPlayer.Team.Index;
GameObject? spawnedObject = SpawnAtLocation(spawnName, playerPosition, playerRotation, teamIndex);
if (spawnedObject == null)
{
@@ -283,17 +292,24 @@ public void Command_Spawn(Il2Cpp.Player callerPlayer, String args)
{
// set team information
BaseGameObject baseObject = spawnedObject.GetBaseGameObject();
- if (baseObject.m_Team.Index != teamIndex)
+ if (baseObject.Team.Index != teamIndex)
{
baseObject.Team = Team.Teams[teamIndex];
- baseObject.m_Team = Team.Teams[teamIndex];
+ //baseObject.m_Team = Team.Teams[teamIndex];
+#if NET6_0
baseObject.UpdateToCurrentTeam();
+#else
+ Type baseOjbectType = typeof(BaseGameObject);
+ MethodInfo updateToCurrentTeamMethod = baseOjbectType.GetMethod("UpdateToCurrentTeam");
+
+ updateToCurrentTeamMethod.Invoke(baseObject, null);
+#endif
}
}
return spawnedObject;
}
- public void Command_SaveSetup(Il2Cpp.Player callerPlayer, String args)
+ public static void Command_SaveSetup(Player callerPlayer, String args)
{
String commandName = args.Split(' ')[0];
@@ -360,12 +376,7 @@ public void Command_SaveSetup(Il2Cpp.Player callerPlayer, String args)
SpawnSetup spawnSetup = GenerateSpawnSetup();
// save to file
- String JsonRaw = JsonSerializer.Serialize(
- spawnSetup,
- new JsonSerializerOptions
- {
- WriteIndented = true
- });
+ String JsonRaw = JsonConvert.SerializeObject(spawnSetup, Newtonsoft.Json.Formatting.Indented);
File.WriteAllText(configFileFullPath, JsonRaw);
@@ -377,7 +388,7 @@ public void Command_SaveSetup(Il2Cpp.Player callerPlayer, String args)
}
}
- public void Command_AddSetup(Il2Cpp.Player callerPlayer, String args)
+ public static void Command_AddSetup(Player callerPlayer, String args)
{
String commandName = args.Split(' ')[0];
@@ -430,20 +441,20 @@ public void Command_AddSetup(Il2Cpp.Player callerPlayer, String args)
// check global config options
String JsonRaw = File.ReadAllText(configFileFullPath);
- SpawnSetup? spawnSetup = JsonSerializer.Deserialize(JsonRaw);
+ SpawnSetup? spawnSetup = JsonConvert.DeserializeObject(JsonRaw);
if (spawnSetup == null)
{
HelperMethods.ReplyToCommand(commandName + ": json error in configuration file");
return;
}
- if (spawnSetup.Map != null && spawnSetup.Map != NetworkGameServer.GetServerMapName())
+ if (spawnSetup.Map != null && spawnSetup.Map != NetworkGameServer.GetServerMap())
{
HelperMethods.ReplyToCommand(commandName + ": incompatible map specified");
return;
}
- MP_Strategy strategyInstance = GameObject.FindObjectOfType();
+ MP_Strategy strategyInstance = GameObject.FindObjectOfType();
if (spawnSetup.VersusMode != null && spawnSetup.VersusMode != strategyInstance.TeamsVersus.ToString())
{
HelperMethods.ReplyToCommand(commandName + ": incompatible mode specified");
@@ -464,7 +475,7 @@ public void Command_AddSetup(Il2Cpp.Player callerPlayer, String args)
}
}
- public void Command_LoadSetup(Il2Cpp.Player callerPlayer, String args)
+ public static void Command_LoadSetup(Player callerPlayer, String args)
{
String commandName = args.Split(' ')[0];
@@ -517,20 +528,20 @@ public void Command_LoadSetup(Il2Cpp.Player callerPlayer, String args)
// check global config options
String JsonRaw = File.ReadAllText(configFileFullPath);
- SpawnSetup? spawnSetup = JsonSerializer.Deserialize(JsonRaw);
+ SpawnSetup? spawnSetup = JsonConvert.DeserializeObject(JsonRaw);
if (spawnSetup == null)
{
HelperMethods.ReplyToCommand(commandName + ": json error in configuration file");
return;
}
- if (spawnSetup.Map != null && spawnSetup.Map != NetworkGameServer.GetServerMapName())
+ if (spawnSetup.Map != null && spawnSetup.Map != NetworkGameServer.GetServerMap())
{
HelperMethods.ReplyToCommand(commandName + ": incompatible map specified");
return;
}
- MP_Strategy strategyInstance = GameObject.FindObjectOfType();
+ MP_Strategy strategyInstance = GameObject.FindObjectOfType();
if (spawnSetup.VersusMode != null && spawnSetup.VersusMode != strategyInstance.TeamsVersus.ToString())
{
HelperMethods.ReplyToCommand(commandName + ": incompatible mode specified");
@@ -653,8 +664,19 @@ public static bool LoadUnits(SpawnSetup addSetup)
{
MelonLogger.Msg("Adding unit " + spawnEntry.Classname);
- Vector3 position = new(spawnEntry.Position[0], spawnEntry.Position[1], spawnEntry.Position[2]);
- Quaternion rotation = new(spawnEntry.Rotation[0], spawnEntry.Rotation[1], spawnEntry.Rotation[2], spawnEntry.Rotation[3]);
+ Vector3 position = new Vector3
+ {
+ x = spawnEntry.Position[0],
+ y = spawnEntry.Position[1],
+ z = spawnEntry.Position[2]
+ };
+ Quaternion rotation = new Quaternion
+ {
+ x = spawnEntry.Rotation[0],
+ y = spawnEntry.Rotation[1],
+ z = spawnEntry.Rotation[2],
+ w = spawnEntry.Rotation[3]
+ };
GameObject? spawnedObject = SpawnAtLocation(spawnEntry.Classname, position, rotation, spawnEntry.TeamIndex);
if (spawnedObject == null)
{
@@ -688,8 +710,19 @@ public static bool LoadStructures(SpawnSetup addSetup)
{
MelonLogger.Msg("Adding structure " + spawnEntry.Classname);
- Vector3 position = new(spawnEntry.Position[0], spawnEntry.Position[1], spawnEntry.Position[2]);
- Quaternion rotation = new(spawnEntry.Rotation[0], spawnEntry.Rotation[1], spawnEntry.Rotation[2], spawnEntry.Rotation[3]);
+ Vector3 position = new Vector3
+ {
+ x = spawnEntry.Position[0],
+ y = spawnEntry.Position[1],
+ z = spawnEntry.Position[2]
+ };
+ Quaternion rotation = new Quaternion
+ {
+ x = spawnEntry.Rotation[0],
+ y = spawnEntry.Rotation[1],
+ z = spawnEntry.Rotation[2],
+ w = spawnEntry.Rotation[3]
+ };
GameObject? spawnedObject = SpawnAtLocation(spawnEntry.Classname, position, rotation, spawnEntry.TeamIndex);
if (spawnedObject == null)
{
@@ -709,7 +742,15 @@ public static bool LoadStructures(SpawnSetup addSetup)
if (thisStructure != null)
{
thisStructure.StructureTechnologyTier = (int)spawnEntry.TechTier;
+
+#if NET6_0
thisStructure.RPC_SynchTechnologyTier();
+#else
+ Type structureType = typeof(Structure);
+ MethodInfo synchTechMethod = structureType.GetMethod("RPC_SynchTechnologyTier");
+
+ synchTechMethod.Invoke(thisStructure, null);
+#endif
}
}
@@ -733,7 +774,7 @@ public static void LoadTeams(SpawnSetup addSetup)
foreach (TeamSpawn spawnEntry in addSetup.Teams)
{
Team.Teams[spawnEntry.TeamIndex].StartingResources = spawnEntry.Resources;
- Team.Teams[spawnEntry.TeamIndex].m_StartingResources = spawnEntry.Resources;
+ //Team.Teams[spawnEntry.TeamIndex].m_StartingResources = spawnEntry.Resources;
}
}
}
@@ -760,9 +801,9 @@ public static bool ExecuteBatchSpawn(SpawnSetup spawnSetup)
public static SpawnSetup GenerateSpawnSetup(bool includeNetIDs = false)
{
// set global config options
- SpawnSetup spawnSetup = new();
- spawnSetup.Map = NetworkGameServer.GetServerMapName();
- MP_Strategy strategyInstance = GameObject.FindObjectOfType();
+ SpawnSetup spawnSetup = new SpawnSetup();
+ spawnSetup.Map = NetworkGameServer.GetServerMap();
+ MP_Strategy strategyInstance = GameObject.FindObjectOfType();
spawnSetup.VersusMode = strategyInstance.TeamsVersus.ToString();
// create a list of all structures and units
@@ -777,8 +818,8 @@ public static SpawnSetup GenerateSpawnSetup(bool includeNetIDs = false)
continue;
}
- TeamSpawn thisTeamSpawn = new();
- thisTeamSpawn.Resources = team.m_StartingResources;
+ TeamSpawn thisTeamSpawn = new TeamSpawn();
+ thisTeamSpawn.Resources = team.StartingResources;
thisTeamSpawn.TeamIndex = team.Index;
spawnSetup.Teams.Add(thisTeamSpawn);
@@ -790,7 +831,7 @@ public static SpawnSetup GenerateSpawnSetup(bool includeNetIDs = false)
continue;
}
- StructureSpawn thisSpawnEntry = new();
+ StructureSpawn thisSpawnEntry = new StructureSpawn();
BaseGameObject structureBaseObject = structure.gameObject.GetBaseGameObject();
float[] position = new float[]
@@ -840,7 +881,7 @@ public static SpawnSetup GenerateSpawnSetup(bool includeNetIDs = false)
foreach (Unit unit in team.Units)
{
- UnitSpawn thisSpawnEntry = new();
+ UnitSpawn thisSpawnEntry = new UnitSpawn();
float[] position = new float[]
{
diff --git a/Si_SpawnConfigs/Si_SpawnConfigs.csproj b/Si_SpawnConfigs/Si_SpawnConfigs.csproj
index 704eac7..414a13a 100644
--- a/Si_SpawnConfigs/Si_SpawnConfigs.csproj
+++ b/Si_SpawnConfigs/Si_SpawnConfigs.csproj
@@ -1,42 +1,14 @@
- net6.0
- enable
+ net6.0;netstandard2.1
enable
-
- ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Silica\MelonLoader\net6\0Harmony.dll
-
-
- ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Silica\MelonLoader\Il2CppAssemblies\Assembly-CSharp.dll
-
-
- ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Silica\MelonLoader\net6\Il2CppInterop.Runtime.dll
-
-
- ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Silica\MelonLoader\Il2CppAssemblies\Il2Cppmscorlib.dll
-
-
- ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Silica\MelonLoader\net6\MelonLoader.dll
-
-
- ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Silica\MelonLoader\net6\Si_AdminExtension.dll
-
-
- ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Silica\MelonLoader\Il2CppAssemblies\UnityEngine.dll
-
-
- ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Silica\MelonLoader\Il2CppAssemblies\UnityEngine.CoreModule.dll
-
-
- ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Silica\MelonLoader\Il2CppAssemblies\UnityEngine.InputLegacyModule.dll
-
-
- ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Silica\MelonLoader\Il2CppAssemblies\UnityEngine.PhysicsModule.dll
-
+
+
+
diff --git a/Si_SpawnConfigs/Si_SpawnConfigs.sln b/Si_SpawnConfigs/Si_SpawnConfigs.sln
new file mode 100644
index 0000000..1cba810
--- /dev/null
+++ b/Si_SpawnConfigs/Si_SpawnConfigs.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.6.33723.286
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Si_SpawnConfigs", "Si_SpawnConfigs.csproj", "{305AE3B9-B67D-4F6B-AC9F-E9F18CC45C5E}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {305AE3B9-B67D-4F6B-AC9F-E9F18CC45C5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {305AE3B9-B67D-4F6B-AC9F-E9F18CC45C5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {305AE3B9-B67D-4F6B-AC9F-E9F18CC45C5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {305AE3B9-B67D-4F6B-AC9F-E9F18CC45C5E}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {68A72EA6-C4B6-4C2F-BCA8-AAFA066176A8}
+ EndGlobalSection
+EndGlobal