Fix build errors & warnings for latest GC & API updates
This commit is contained in:
parent
97ff83d2b1
commit
9a4cfd97bb
5 changed files with 36 additions and 91 deletions
|
@ -3,15 +3,14 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>net472</TargetFramework>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
<Version>0.0.1</Version>
|
<Version>1.0.0</Version>
|
||||||
<Authors>Me</Authors>
|
<Authors>NGnius</Authors>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageProjectUrl>https://git.exmods.org/modtainers/HelloModdingWorld</PackageProjectUrl>
|
<PackageProjectUrl>https://git.exmods.org/NGnius/leadercraft</PackageProjectUrl>
|
||||||
<NeutralLanguage>en-CA</NeutralLanguage>
|
<NeutralLanguage>en-CA</NeutralLanguage>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Lib.Harmony" Version="1.2.0.1" />
|
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -77,10 +76,6 @@
|
||||||
<HintPath>..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll</HintPath>
|
<HintPath>..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll</HintPath>
|
||||||
<HintPath>..\..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll</HintPath>
|
<HintPath>..\..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="ClusterToWireConversion.Mock">
|
|
||||||
<HintPath>..\ref\Gamecraft_Data\Managed\ClusterToWireConversion.Mock.dll</HintPath>
|
|
||||||
<HintPath>..\..\ref\Gamecraft_Data\Managed\ClusterToWireConversion.Mock.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="CommandLine">
|
<Reference Include="CommandLine">
|
||||||
<HintPath>..\ref\Gamecraft_Data\Managed\CommandLine.dll</HintPath>
|
<HintPath>..\ref\Gamecraft_Data\Managed\CommandLine.dll</HintPath>
|
||||||
<HintPath>..\..\ref\Gamecraft_Data\Managed\CommandLine.dll</HintPath>
|
<HintPath>..\..\ref\Gamecraft_Data\Managed\CommandLine.dll</HintPath>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
using IllusionPlugin;
|
using IllusionPlugin;
|
||||||
using GamecraftModdingAPI.Utility;
|
using GamecraftModdingAPI.Utility;
|
||||||
|
using Leadercraft.Scoring;
|
||||||
using Leadercraft.Server;
|
using Leadercraft.Server;
|
||||||
|
|
||||||
namespace Leadercraft
|
namespace Leadercraft
|
||||||
|
@ -21,14 +21,14 @@ namespace Leadercraft
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
"http://192.168.122.229:1337/token";
|
"http://192.168.122.229:1337/token";
|
||||||
#else
|
#else
|
||||||
"https://leadercraft.exmods.org/token";
|
"https://leadercraft.exmods.org/s/token";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private static string criteriaUrl =
|
private static string criteriaUrl =
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
"http://192.168.122.229:7048/criteria";
|
"http://192.168.122.229:7048/c/criteria";
|
||||||
#else
|
#else
|
||||||
"https://board.exmods.org/criteria";
|
"https://leadercraft.exmods.org/criteria";
|
||||||
#endif
|
#endif
|
||||||
public static void BuildApi()
|
public static void BuildApi()
|
||||||
{
|
{
|
||||||
|
@ -62,9 +62,10 @@ namespace Leadercraft
|
||||||
// check out the modding API docs here: https://mod.exmods.org/
|
// check out the modding API docs here: https://mod.exmods.org/
|
||||||
|
|
||||||
// Initialize this mod
|
// Initialize this mod
|
||||||
GamecraftModdingAPI.Utility.GameEngineManager.AddGameEngine(new Scoring.LeadercraftSimEventHandler());
|
GamecraftModdingAPI.App.Game.Simulate += (_, __) => State.StartPlayingGame();
|
||||||
GamecraftModdingAPI.Utility.GameEngineManager.AddGameEngine(new Scoring.LeadercraftGameEventHandler());
|
GamecraftModdingAPI.App.Game.Edit += (_, __) => State.StopPlayingGame();
|
||||||
GamecraftModdingAPI.Events.EventManager.AddEventHandler(new Scoring.GameLoop());
|
GamecraftModdingAPI.App.Game.Enter += (_, __) => State.EnterGame();
|
||||||
|
GamecraftModdingAPI.App.Game.Exit += (_, __) => State.ExitGame();
|
||||||
GamecraftModdingAPI.Utility.Logging.LogDebug($"{Name} has started up");
|
GamecraftModdingAPI.Utility.Logging.LogDebug($"{Name} has started up");
|
||||||
|
|
||||||
// Debug mode
|
// Debug mode
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
using System;
|
|
||||||
using GamecraftModdingAPI.Events;
|
|
||||||
namespace Leadercraft.Scoring
|
|
||||||
{
|
|
||||||
internal class LeadercraftGameEventHandler : SimpleEventHandlerEngine
|
|
||||||
{
|
|
||||||
public LeadercraftGameEventHandler(): base(State.EnterGame, State.ExitGame, EventType.GameSwitchedTo, "LeadercraftGameEventHandler")
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class LeadercraftSimEventHandler : SimpleEventHandlerEngine
|
|
||||||
{
|
|
||||||
public LeadercraftSimEventHandler() : base(State.StartPlayingGame, State.StopPlayingGame, EventType.SimulationSwitchedTo, "LeadercraftSimEventHandler")
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
using RobocraftX.Common;
|
|
||||||
using Gamecraft.Blocks.HUDFeedbackBlocks;
|
|
||||||
|
|
||||||
using GamecraftModdingAPI;
|
|
||||||
using GamecraftModdingAPI.Engines;
|
|
||||||
using GamecraftModdingAPI.Events;
|
|
||||||
using GamecraftModdingAPI.Players;
|
|
||||||
using GamecraftModdingAPI.Tasks;
|
|
||||||
using GamecraftModdingAPI.Utility;
|
|
||||||
using Svelto.ECS;
|
|
||||||
using Unity.Jobs;
|
|
||||||
|
|
||||||
using Leadercraft.Server;
|
|
||||||
|
|
||||||
namespace Leadercraft.Scoring
|
|
||||||
{
|
|
||||||
internal class GameLoop : SimpleEventHandlerEngine
|
|
||||||
{
|
|
||||||
|
|
||||||
private static Player localPlayer;
|
|
||||||
|
|
||||||
public GameLoop() : base (OnGameEnter, (_) => {}, EventType.GameSwitchedTo, "LeadercraftGameLoopGameEngine") { }
|
|
||||||
|
|
||||||
public static void OnGameEnter(EntitiesDB entitiesDB)
|
|
||||||
{
|
|
||||||
// schedule game loop async task
|
|
||||||
Action loop = () => { loopPass(entitiesDB); };
|
|
||||||
ISchedulable looper = new Repeatable(loop, () => { return State.IsInGame; }, LeadercraftPlugin.LoopDelay);
|
|
||||||
Scheduler.Schedule(looper);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void loopPass(EntitiesDB entitiesDB)
|
|
||||||
{
|
|
||||||
if (!State.IsPlayingGame) return;
|
|
||||||
if (localPlayer == null && Player.Exists(PlayerType.Local)) localPlayer = new Player(PlayerType.Local);
|
|
||||||
EntityCollection<FilteredChannelDataStruct> channelInfo = entitiesDB.QueryEntities<FilteredChannelDataStruct>(CommonExclusiveGroups.OWNED_BLOCKS_GROUP);
|
|
||||||
for (uint i = 0; i < channelInfo.count; i++)
|
|
||||||
{
|
|
||||||
FilteredChannelDataStruct data = channelInfo[i];
|
|
||||||
if(data.channelSignals.any && entitiesDB.Exists<GameOverHudBlockEntityStruct>(data.ID))
|
|
||||||
{
|
|
||||||
GameOverHudTextEntityStruct hudText = entitiesDB.QueryEntity<GameOverHudTextEntityStruct>(data.ID);
|
|
||||||
if (((string)hudText.headerText).ToLower().Contains("win") || ((string)hudText.bodyText).ToLower().Contains("win"))
|
|
||||||
{
|
|
||||||
State.StopPlayingGame();
|
|
||||||
//State.GamePlayTime.TotalSeconds
|
|
||||||
UploadJob scoreJob = new UploadJob(State.Score, State.GamePlayTime.TotalSeconds, localPlayer.Position, Tools.UserId, Tools.UserName, Tools.GameId);
|
|
||||||
scoreJob.RunInNewThread();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
|
using GamecraftModdingAPI;
|
||||||
|
using GamecraftModdingAPI.Players;
|
||||||
|
using GamecraftModdingAPI.Tasks;
|
||||||
using GamecraftModdingAPI.Utility;
|
using GamecraftModdingAPI.Utility;
|
||||||
|
|
||||||
|
using Leadercraft.Server;
|
||||||
|
|
||||||
namespace Leadercraft.Scoring
|
namespace Leadercraft.Scoring
|
||||||
{
|
{
|
||||||
internal static class State
|
internal static class State
|
||||||
|
@ -25,6 +30,8 @@ namespace Leadercraft.Scoring
|
||||||
|
|
||||||
public static bool IsGameSynced { get; private set; }
|
public static bool IsGameSynced { get; private set; }
|
||||||
|
|
||||||
|
private static Player localPlayer = null;
|
||||||
|
|
||||||
public static void EnterGame()
|
public static void EnterGame()
|
||||||
{
|
{
|
||||||
if (IsInGame) return;
|
if (IsInGame) return;
|
||||||
|
@ -50,6 +57,10 @@ namespace Leadercraft.Scoring
|
||||||
Score = 0;
|
Score = 0;
|
||||||
IsPlayingGame = true;
|
IsPlayingGame = true;
|
||||||
GameStartTime = DateTime.UtcNow;
|
GameStartTime = DateTime.UtcNow;
|
||||||
|
// schedule game loop async task
|
||||||
|
Action loop = () => { loopPass(); };
|
||||||
|
ISchedulable looper = new Repeatable(loop, () => { return State.IsInGame; }, LeadercraftPlugin.LoopDelay);
|
||||||
|
Scheduler.Schedule(looper);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void StopPlayingGame()
|
public static void StopPlayingGame()
|
||||||
|
@ -83,5 +94,19 @@ namespace Leadercraft.Scoring
|
||||||
Points = Score,
|
Points = Score,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void loopPass()
|
||||||
|
{
|
||||||
|
if (!State.IsPlayingGame) return;
|
||||||
|
if (localPlayer == null && Player.Exists(PlayerType.Local)) localPlayer = new Player(PlayerType.Local);
|
||||||
|
if (localPlayer == null) return;
|
||||||
|
if (localPlayer.GameOver && !localPlayer.Dead)
|
||||||
|
{
|
||||||
|
State.StopPlayingGame();
|
||||||
|
//State.GamePlayTime.TotalSeconds
|
||||||
|
UploadJob scoreJob = new UploadJob(State.Score, State.GamePlayTime.TotalSeconds, localPlayer.Position, Tools.UserId, Tools.UserName, Tools.GameId);
|
||||||
|
scoreJob.RunInNewThread();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue