소스 검색

Add some state info and save method

tags/v1.3.0
NGnius (Graham) 3 년 전
부모
커밋
b6a5074fd2
3개의 변경된 파일61개의 추가작업 그리고 0개의 파일을 삭제
  1. +9
    -0
      GamecraftModdingAPI/App/Client.cs
  2. +24
    -0
      GamecraftModdingAPI/App/Game.cs
  3. +28
    -0
      GamecraftModdingAPI/App/GameGameEngine.cs

+ 9
- 0
GamecraftModdingAPI/App/Client.cs 파일 보기

@@ -65,6 +65,15 @@ namespace GamecraftModdingAPI.App
}
}

/// <summary>
/// Whether Gamecraft is in the Main Menu
/// </summary>
/// <value><c>true</c> if in menu; <c>false</c> when loading or in a game.</value>
public bool InMenu
{
get => appEngine.IsInMenu;
}

internal static void Init()
{
MenuEngineManager.AddMenuEngine(appEngine);


+ 24
- 0
GamecraftModdingAPI/App/Game.cs 파일 보기

@@ -7,6 +7,8 @@ using RobocraftX.GUI.MyGamesScreen;
using RobocraftX.StateSync;
using Svelto.ECS;

using GamecraftModdingAPI;
using GamecraftModdingAPI.Blocks;
using GamecraftModdingAPI.Tasks;
using GamecraftModdingAPI.Utility;

@@ -414,6 +416,28 @@ namespace GamecraftModdingAPI.App
return debugIds.Remove(id);
}

/// <summary>
/// Gets the blocks in the game.
/// This returns null when in a loading state, and throws AppStateException when in menu.
/// </summary>
/// <returns>The blocks in game.</returns>
/// <param name="filter">The block to search for. BlockIDs.Invalid will return all blocks.</param>
public Block[] GetBlocksInGame(BlockIDs filter = BlockIDs.Invalid)
{
if (!VerifyMode()) return null;
if (menuMode)
{
throw new AppStateException("Game object references a menu item but GetBlocksInGame only works on the currently-loaded game");
}
EGID[] blockEGIDs = gameEngine.GetAllBlocksInGame(filter);
Block[] blocks = new Block[blockEGIDs.Length];
for (int b = 0; b < blockEGIDs.Length; b++)
{
blocks[b] = new Block(blockEGIDs[b]);
}
return blocks;
}

~Game()
{
foreach (string id in debugIds)


+ 28
- 0
GamecraftModdingAPI/App/GameGameEngine.cs 파일 보기

@@ -10,6 +10,7 @@ using Svelto.ECS;
using Svelto.Tasks;
using Svelto.Tasks.Lean;

using GamecraftModdingAPI.Blocks;
using GamecraftModdingAPI.Engines;
using GamecraftModdingAPI.Utility;

@@ -93,5 +94,32 @@ namespace GamecraftModdingAPI.App
{
TimeRunningModeUtil.ToggleTimeRunningState(entitiesDB);
}

public EGID[] GetAllBlocksInGame(BlockIDs filter = BlockIDs.Invalid)
{
EntityCollection<DBEntityStruct> blocks = entitiesDB.QueryEntities<DBEntityStruct>(CommonExclusiveGroups.OWNED_BLOCKS_GROUP);
if (filter == BlockIDs.Invalid)
{
EGID[] blockEGIDs = new EGID[blocks.count];
for (uint b = 0; b < blocks.count; b++)
{
blockEGIDs[b] = blocks[b].ID;
}
return blockEGIDs;
}
else
{
uint dbidFilter = (uint)filter;
List<EGID> blockEGIDs = new List<EGID>();
for (uint b = 0; b < blocks.count; b++)
{
if (blocks[b].DBID == dbidFilter)
{
blockEGIDs.Add(blocks[b].ID);
}
}
return blockEGIDs.ToArray();
}
}
}
}

불러오는 중...
취소
저장