Add method to get selected blocks by player
This commit is contained in:
parent
448cf3af48
commit
3dcce18ceb
3 changed files with 32 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
|||
<PackageLicenseExpression>GNU General Public Licence 3+</PackageLicenseExpression>
|
||||
<PackageProjectUrl>https://git.exmods.org/modtainers/GamecraftModdingAPI</PackageProjectUrl>
|
||||
<NeutralLanguage>en-CA</NeutralLanguage>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -366,6 +366,15 @@ namespace GamecraftModdingAPI
|
|||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the blocks that are in the player's current selection.
|
||||
/// </summary>
|
||||
/// <returns>An array of blocks or an empty array</returns>
|
||||
public Block[] GetSelectedBlocks()
|
||||
{
|
||||
return playerEngine.GetSelectedBlocks(Id);
|
||||
}
|
||||
|
||||
public bool Equals(Player other)
|
||||
{
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
|
|
|
@ -5,6 +5,7 @@ using RobocraftX.Character;
|
|||
using RobocraftX.Character.Movement;
|
||||
using RobocraftX.Common.Players;
|
||||
using RobocraftX.Common.Input;
|
||||
using RobocraftX.CR.MachineEditing.BoxSelect;
|
||||
using RobocraftX.Physics;
|
||||
using RobocraftX.Blocks.Ghost;
|
||||
using RobocraftX.Character.Camera;
|
||||
|
@ -408,5 +409,26 @@ namespace GamecraftModdingAPI.Players
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
public unsafe Block[] GetSelectedBlocks(uint playerid)
|
||||
{
|
||||
if (!entitiesDB.Exists<BoxSelectStateEntityStruct>(playerid,
|
||||
BoxSelectExclusiveGroups.BoxSelectVolumeExclusiveGroup))
|
||||
return new Block[0];
|
||||
var state = entitiesDB.QueryEntity<BoxSelectStateEntityStruct>(playerid,
|
||||
BoxSelectExclusiveGroups.BoxSelectVolumeExclusiveGroup);
|
||||
var blocks = entitiesDB.QueryEntity<SelectedBlocksStruct>(playerid,
|
||||
BoxSelectExclusiveGroups.BoxSelectVolumeExclusiveGroup);
|
||||
if (!state.active) return new Block[0];
|
||||
var pointer = (EGID*) blocks.selectedBlocks.ToPointer();
|
||||
var ret = new Block[blocks.count];
|
||||
for (int j = 0; j < blocks.count; j++)
|
||||
{
|
||||
var egid = pointer[j];
|
||||
ret[j] = new Block(egid);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue