|
|
@@ -1,4 +1,5 @@ |
|
|
|
using System.Collections.Generic; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
using RobocraftX.Common; |
|
|
|
using RobocraftX.Schedulers; |
|
|
@@ -13,6 +14,7 @@ using Techblox.Environment.Transition; |
|
|
|
using Techblox.GameSelection; |
|
|
|
using TechbloxModdingAPI.Blocks; |
|
|
|
using TechbloxModdingAPI.Engines; |
|
|
|
using TechbloxModdingAPI.Players; |
|
|
|
using TechbloxModdingAPI.Utility; |
|
|
|
|
|
|
|
namespace TechbloxModdingAPI.App |
|
|
@@ -30,16 +32,32 @@ namespace TechbloxModdingAPI.App |
|
|
|
public EntitiesDB entitiesDB { set; private get; } |
|
|
|
|
|
|
|
private bool enteredGame; |
|
|
|
private bool loadingFinished; |
|
|
|
private bool playerJoined; |
|
|
|
|
|
|
|
public void Dispose() |
|
|
|
{ |
|
|
|
ExitGame.Invoke(this, new GameEventArgs { GameName = GetGameData().saveName, GamePath = GetGameData().gameID }); |
|
|
|
IsInGame = false; |
|
|
|
loadingFinished = false; |
|
|
|
playerJoined = false; |
|
|
|
enteredGame = false; |
|
|
|
} |
|
|
|
|
|
|
|
public void Ready() |
|
|
|
{ |
|
|
|
enteredGame = true; |
|
|
|
Player.Joined += OnPlayerJoined; |
|
|
|
} |
|
|
|
|
|
|
|
private void OnPlayerJoined(object sender, PlayerEventArgs args) |
|
|
|
{ |
|
|
|
Console.WriteLine("Player joined: " + args.PlayerId + " asd"); |
|
|
|
if (args.Player.Type != PlayerType.Local) return; |
|
|
|
Console.WriteLine("Player joined is local asd"); |
|
|
|
playerJoined = true; |
|
|
|
Player.Joined -= OnPlayerJoined; |
|
|
|
CheckJoinEvent(); |
|
|
|
} |
|
|
|
|
|
|
|
// game functionality |
|
|
@@ -142,9 +160,18 @@ namespace TechbloxModdingAPI.App |
|
|
|
public void Remove(ref LoadingActionEntityStruct entityComponent, EGID egid) |
|
|
|
{ // Finished loading |
|
|
|
if (!enteredGame) return; |
|
|
|
enteredGame = false; |
|
|
|
loadingFinished = true; |
|
|
|
Console.WriteLine("Loading finished - asd"); |
|
|
|
CheckJoinEvent(); |
|
|
|
} |
|
|
|
|
|
|
|
private void CheckJoinEvent() |
|
|
|
{ |
|
|
|
Console.WriteLine($"Check: {loadingFinished} {playerJoined}"); |
|
|
|
if (!loadingFinished || !playerJoined) return; |
|
|
|
EnterGame.Invoke(this, new GameEventArgs { GameName = GetGameData().saveName, GamePath = GetGameData().gameID }); |
|
|
|
IsInGame = true; |
|
|
|
enteredGame = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |