Add method to get ghost block
This commit is contained in:
parent
ddaa933e7d
commit
0ec47cd38b
5 changed files with 45 additions and 0 deletions
|
@ -289,6 +289,7 @@ namespace TechbloxModdingAPI
|
|||
color.indexInPalette = value.Index;
|
||||
color.hasNetworkChange = true;
|
||||
color.paletteColour = BlockEngine.ConvertBlockColor(color.indexInPalette); //Setting to 255 results in black
|
||||
BlockEngine.UpdateBlockColor(Id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -157,6 +157,11 @@ namespace TechbloxModdingAPI.Blocks.Engines
|
|||
//Phyiscs prefab: prefabAssetID, set on block creation from the CubeListData
|
||||
}
|
||||
|
||||
public void UpdateBlockColor(EGID id)
|
||||
{
|
||||
entitiesDB.PublishEntityChange<ColourParameterEntityStruct>(id);
|
||||
}
|
||||
|
||||
public bool BlockExists(EGID blockID)
|
||||
{
|
||||
return entitiesDB.Exists<BlockTagEntityStruct>(blockID);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using Gamecraft.Wires;
|
||||
using RobocraftX.Blocks.Ghost;
|
||||
using RobocraftX.Character;
|
||||
using RobocraftX.Character.Movement;
|
||||
using Unity.Mathematics;
|
||||
|
@ -527,6 +528,15 @@ namespace TechbloxModdingAPI
|
|||
return playerEngine.GetSelectedBlocks(Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the ghost block that shows the block to be placed in build mode.
|
||||
/// </summary>
|
||||
/// <returns>A block instance or null if not found</returns>
|
||||
public Block GetGhostBlock()
|
||||
{
|
||||
return playerEngine.GetGhostBlock(Id);
|
||||
}
|
||||
|
||||
public bool Equals(Player other)
|
||||
{
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
|
|
|
@ -9,6 +9,7 @@ using RobocraftX.CR.MachineEditing.BoxSelect;
|
|||
using RobocraftX.Physics;
|
||||
using RobocraftX.Blocks.Ghost;
|
||||
using Gamecraft.GUI.HUDFeedbackBlocks;
|
||||
using RobocraftX.Common;
|
||||
using RobocraftX.Multiplayer;
|
||||
using RobocraftX.SimulationModeState;
|
||||
using Svelto.ECS;
|
||||
|
@ -270,5 +271,11 @@ namespace TechbloxModdingAPI.Players
|
|||
.QueryUniqueEntity<NetworkStatsEntityStruct>(MultiplayerExclusiveGroups.MultiplayerStateGroup)
|
||||
.networkStats.PingMs;
|
||||
}
|
||||
|
||||
public Block GetGhostBlock(uint playerId)
|
||||
{
|
||||
var egid = new EGID(playerId, GHOST_BLOCKS_ENABLED.Group);
|
||||
return entitiesDB.Exists<DBEntityStruct>(egid) ? Block.New(egid) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -343,6 +343,28 @@ namespace TechbloxModdingAPI.Tests
|
|||
Logging.CommandLog(asset);
|
||||
}
|
||||
}).Build();
|
||||
|
||||
bool shouldTestGhostBlock = false;
|
||||
CommandBuilder.Builder("testGhostBlock")
|
||||
.Action(() =>
|
||||
{
|
||||
if (shouldTestGhostBlock)
|
||||
{
|
||||
shouldTestGhostBlock = false;
|
||||
Logging.CommandLog("Test disabled");
|
||||
}
|
||||
|
||||
shouldTestGhostBlock = true;
|
||||
Scheduler.Schedule(new Repeatable(() =>
|
||||
{
|
||||
var ghostBlock = Player.LocalPlayer.GetGhostBlock();
|
||||
if (ghostBlock == null) return;
|
||||
ghostBlock.Position = Player.LocalPlayer.Position + 2;
|
||||
ghostBlock.Color = new BlockColor(BlockColors.Lime);
|
||||
}, () => shouldTestGhostBlock));
|
||||
Logging.CommandLog("Test enabled");
|
||||
}).Build();
|
||||
|
||||
Client.EnterMenu += (sender, args) => Scheduler.Schedule(new Once(() => Client.Instance.CloseBetaPopup()));
|
||||
|
||||
Game.Enter += (sender, args) =>
|
||||
|
|
Loading…
Reference in a new issue