Moar Gamecraft commands!
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

52 líneas
1.8KB

  1. using System;
  2. using RobocraftX.GUI.CommandLine;
  3. using RobocraftX.Multiplayer;
  4. using RobocraftX.StateSync;
  5. using RobocraftX.Character;
  6. using RobocraftX.Common;
  7. using Svelto.ECS;
  8. using Svelto.ECS.EntityStructs;
  9. using Unity.Entities;
  10. using UnityEngine;
  11. using uREPL;
  12. using Svelto.Context;
  13. using RobocraftX;
  14. namespace ExtraCommands.Building
  15. {
  16. [CustomCommand("MoveBlocks", "Move blocks from their original position")]
  17. class MoveBlocksCommandEngine : CustomCommandEngine
  18. {
  19. public MoveBlocksCommandEngine(UnityContext<FullGameCompositionRoot> ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams)
  20. {
  21. }
  22. public override void Ready()
  23. {
  24. uREPL.RuntimeCommands.Register<float, float, float>("MoveBlocks", MoveBlocksCommand, "Move blocks from their original position");
  25. }
  26. private void MoveBlocksCommand(float x, float y, float z)
  27. {
  28. uint loopCount;
  29. for (loopCount = 0; loopCount < CommonExclusiveGroups.CurrentBlockEntityID; loopCount++)
  30. {
  31. ref PositionEntityStruct posStruct = ref this.entitiesDB.QueryEntity<PositionEntityStruct>(loopCount, CommonExclusiveGroups.OWNED_BLOCKS_GROUP);
  32. if (!posStruct.Equals(null) && !posStruct.position.Equals(null))
  33. {
  34. posStruct.position.x += x;
  35. posStruct.position.y += y;
  36. posStruct.position.z += z;
  37. } else {
  38. uREPL.Log.Warn("Null position found for ID "+loopCount);
  39. }
  40. }
  41. }
  42. public override void Dispose()
  43. {
  44. uREPL.RuntimeCommands.Unregister("MoveBlocks");
  45. }
  46. }
  47. }