A stable modding interface between Techblox and mods https://mod.exmods.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

581 lines
21KB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Reflection.Emit;
  5. using Gamecraft.Blocks.BlockGroups;
  6. using Svelto.ECS;
  7. using Svelto.ECS.EntityStructs;
  8. using RobocraftX.Common;
  9. using RobocraftX.Blocks;
  10. using Unity.Mathematics;
  11. using Gamecraft.Blocks.GUI;
  12. using GamecraftModdingAPI.Blocks;
  13. using GamecraftModdingAPI.Utility;
  14. using RobocraftX.Rendering.GPUI;
  15. namespace GamecraftModdingAPI
  16. {
  17. /// <summary>
  18. /// A single (perhaps scaled) block. Properties may return default values if the block is removed and then setting them is ignored.
  19. /// For specific block type operations, use the specialised block classes in the GamecraftModdingAPI.Blocks namespace.
  20. /// </summary>
  21. public class Block : IEquatable<Block>, IEquatable<EGID>
  22. {
  23. protected static readonly PlacementEngine PlacementEngine = new PlacementEngine();
  24. protected static readonly MovementEngine MovementEngine = new MovementEngine();
  25. protected static readonly RotationEngine RotationEngine = new RotationEngine();
  26. protected static readonly RemovalEngine RemovalEngine = new RemovalEngine();
  27. protected static readonly SignalEngine SignalEngine = new SignalEngine();
  28. protected static readonly BlockEventsEngine BlockEventsEngine = new BlockEventsEngine();
  29. protected static readonly ScalingEngine ScalingEngine = new ScalingEngine();
  30. protected static readonly BlockCloneEngine BlockCloneEngine = new BlockCloneEngine();
  31. protected internal static readonly BlockEngine BlockEngine = new BlockEngine();
  32. /// <summary>
  33. /// Place a new block at the given position. If scaled, position means the center of the block. The default block size is 0.2 in terms of position.
  34. /// Place blocks next to each other to connect them.
  35. /// The placed block will be a complete block with a placement grid and collision which will be saved along with the game.
  36. /// </summary>
  37. /// <param name="block">The block's type</param>
  38. /// <param name="color">The block's color</param>
  39. /// <param name="material">The block's material</param>
  40. /// <param name="position">The block's position - default block size is 0.2</param>
  41. /// <param name="rotation">The block's rotation in degrees</param>
  42. /// <param name="uscale">The block's uniform scale - default scale is 1 (with 0.2 width)</param>
  43. /// <param name="scale">The block's non-uniform scale - 0 means <paramref name="uscale"/> is used</param>
  44. /// <param name="isFlipped">Whether the block should be flipped</param>
  45. /// <param name="autoWire">Whether the block should be auto-wired (if functional)</param>
  46. /// <param name="player">The player who placed the block</param>
  47. /// <returns>The placed block or null if failed</returns>
  48. public static Block PlaceNew(BlockIDs block, float3 position, bool autoWire = false, Player player = null)
  49. {
  50. return PlaceNew<Block>(block, position, autoWire, player);
  51. }
  52. /// <summary>
  53. /// Place a new block at the given position. If scaled, position means the center of the block. The default block size is 0.2 in terms of position.
  54. /// Place blocks next to each other to connect them.
  55. /// The placed block will be a complete block with a placement grid and collision which will be saved along with the game.
  56. /// </summary>
  57. /// <param name="block">The block's type</param>
  58. /// <param name="color">The block's color</param>
  59. /// <param name="material">The block's materialr</param>
  60. /// <param name="position">The block's position - default block size is 0.2</param>
  61. /// <param name="rotation">The block's rotation in degrees</param>
  62. /// <param name="uscale">The block's uniform scale - default scale is 1 (with 0.2 width)</param>
  63. /// <param name="scale">The block's non-uniform scale - 0 means <paramref name="uscale"/> is used</param>
  64. /// <param name="isFlipped">Whether the block should be flipped</param>
  65. /// <param name="autoWire">Whether the block should be auto-wired (if functional)</param>
  66. /// <param name="player">The player who placed the block</param>
  67. /// <returns>The placed block or null if failed</returns>
  68. public static T PlaceNew<T>(BlockIDs block, float3 position, bool autoWire = false, Player player = null)
  69. where T : Block
  70. {
  71. if (PlacementEngine.IsInGame && GameState.IsBuildMode())
  72. {
  73. var initializer = PlacementEngine.PlaceBlock(block, position, player, autoWire);
  74. var egid = initializer.EGID;
  75. var bl = New<T>(egid.entityID, egid.groupID);
  76. bl.InitData.Group = BlockEngine.InitGroup(initializer);
  77. bl.InitData.Reference = initializer.reference;
  78. Placed += bl.OnPlacedInit;
  79. return bl;
  80. }
  81. return null;
  82. }
  83. /// <summary>
  84. /// Returns the most recently placed block.
  85. /// </summary>
  86. /// <returns>The block object</returns>
  87. public static Block GetLastPlacedBlock()
  88. {
  89. return New<Block>(BlockIdentifiers.LatestBlockID);
  90. }
  91. /// <summary>
  92. /// An event that fires each time a block is placed.
  93. /// </summary>
  94. public static event EventHandler<BlockPlacedRemovedEventArgs> Placed
  95. {
  96. add => BlockEventsEngine.Placed += value;
  97. remove => BlockEventsEngine.Placed -= value;
  98. }
  99. /// <summary>
  100. /// An event that fires each time a block is removed.
  101. /// </summary>
  102. public static event EventHandler<BlockPlacedRemovedEventArgs> Removed
  103. {
  104. add => BlockEventsEngine.Removed += value;
  105. remove => BlockEventsEngine.Removed -= value;
  106. }
  107. private static Dictionary<Type, Func<EGID, Block>> initializers = new Dictionary<Type, Func<EGID, Block>>();
  108. private static Dictionary<Type, ExclusiveBuildGroup[]> typeToGroup =
  109. new Dictionary<Type, ExclusiveBuildGroup[]>
  110. {
  111. {typeof(LogicGate), new [] {CommonExclusiveGroups.LOGIC_BLOCK_GROUP}},
  112. {typeof(Motor), new[] {CommonExclusiveGroups.MOTOR_BLOCK_GROUP}},
  113. {typeof(MusicBlock), new[] {CommonExclusiveGroups.MUSIC_BLOCK_GROUP}},
  114. {typeof(ObjectIdentifier), new[]{CommonExclusiveGroups.OBJID_BLOCK_GROUP}},
  115. {typeof(Piston), new[] {CommonExclusiveGroups.PISTON_BLOCK_GROUP}},
  116. {typeof(Servo), new[] {CommonExclusiveGroups.SERVO_BLOCK_GROUP}},
  117. {
  118. typeof(SpawnPoint),
  119. new[]
  120. {
  121. CommonExclusiveGroups.SPAWNPOINT_BLOCK_GROUP,
  122. CommonExclusiveGroups.BUILDINGSPAWN_BLOCK_GROUP
  123. }
  124. },
  125. {
  126. typeof(SfxBlock),
  127. new[]
  128. {
  129. CommonExclusiveGroups.SIMPLESFX_BLOCK_GROUP,
  130. CommonExclusiveGroups.LOOPEDSFX_BLOCK_GROUP
  131. }
  132. },
  133. {typeof(DampedSpring), new [] {CommonExclusiveGroups.DAMPEDSPRING_BLOCK_GROUP}},
  134. {typeof(TextBlock), new[] {CommonExclusiveGroups.TEXT_BLOCK_GROUP}},
  135. {typeof(Timer), new[] {CommonExclusiveGroups.TIMER_BLOCK_GROUP}}
  136. };
  137. /// <summary>
  138. /// Constructs a new instance of T with the given ID and group using dynamically created delegates.
  139. /// It's equivalent to new T(EGID) with a minimal overhead thanks to caching the created delegates.
  140. /// </summary>
  141. /// <param name="id">The block ID</param>
  142. /// <param name="group">The block group</param>
  143. /// <typeparam name="T">The block's type or Block itself</typeparam>
  144. /// <returns>An instance of the provided type</returns>
  145. /// <exception cref="BlockTypeException">The block group doesn't match or cannot be found</exception>
  146. /// <exception cref="MissingMethodException">The block class doesn't have the needed constructor</exception>
  147. private static T New<T>(uint id, ExclusiveGroupStruct? group = null) where T : Block
  148. {
  149. var type = typeof(T);
  150. EGID egid;
  151. if (!group.HasValue)
  152. {
  153. if (typeToGroup.TryGetValue(type, out var gr) && gr.Length == 1)
  154. egid = new EGID(id, gr[0]);
  155. else
  156. egid = BlockEngine.FindBlockEGID(id) ?? throw new BlockTypeException("Could not find block group!");
  157. }
  158. else
  159. {
  160. egid = new EGID(id, group.Value);
  161. if (typeToGroup.TryGetValue(type, out var gr)
  162. && gr.All(egs => egs != group.Value)) //If this subclass has a specific group, then use that - so Block should still work
  163. throw new BlockTypeException($"Incompatible block type! Type {type.Name} belongs to group {gr.Select(g => ((uint)g).ToString()).Aggregate((a, b) => a + ", " + b)} instead of {(uint)group.Value}");
  164. }
  165. if (initializers.TryGetValue(type, out var func))
  166. {
  167. var bl = (T) func(egid);
  168. return bl;
  169. }
  170. //https://stackoverflow.com/a/10593806/2703239
  171. var ctor = type.GetConstructor(new[] {typeof(EGID)});
  172. if (ctor == null)
  173. throw new MissingMethodException("There is no constructor with an EGID parameter for this object");
  174. DynamicMethod dynamic = new DynamicMethod(string.Empty,
  175. type,
  176. new[] {typeof(EGID)},
  177. type);
  178. ILGenerator il = dynamic.GetILGenerator();
  179. //il.DeclareLocal(type);
  180. il.Emit(OpCodes.Ldarg_0); //Load EGID and pass to constructor
  181. il.Emit(OpCodes.Newobj, ctor); //Call constructor
  182. //il.Emit(OpCodes.Stloc_0); - doesn't seem like we need these
  183. //il.Emit(OpCodes.Ldloc_0);
  184. il.Emit(OpCodes.Ret);
  185. func = (Func<EGID, T>) dynamic.CreateDelegate(typeof(Func<EGID, T>));
  186. initializers.Add(type, func);
  187. var block = (T) func(egid);
  188. return block;
  189. }
  190. public Block(EGID id)
  191. {
  192. Id = id;
  193. var type = GetType();
  194. if (typeToGroup.TryGetValue(type, out var groups))
  195. {
  196. if (groups.All(gr => gr != id.groupID))
  197. throw new BlockTypeException("The block has the wrong group! The type is " + GetType() +
  198. " while the group is " + id.groupID);
  199. }
  200. else if (type != typeof(Block) && !typeof(CustomBlock).IsAssignableFrom(type))
  201. Logging.LogWarning($"Unknown block type! Add {type} to the dictionary.");
  202. }
  203. /// <summary>
  204. /// This overload searches for the correct group the block is in.
  205. /// It will throw an exception if the block doesn't exist.
  206. /// Use the EGID constructor where possible or subclasses of Block as those specify the group.
  207. /// </summary>
  208. public Block(uint id)
  209. {
  210. Id = BlockEngine.FindBlockEGID(id) ?? throw new BlockTypeException("Could not find the appropriate group for the block. The block probably doesn't exist or hasn't been submitted.");
  211. }
  212. /// <summary>
  213. /// Places a new block in the world.
  214. /// </summary>
  215. /// <param name="type">The block's type</param>
  216. /// <param name="position">The block's position (a block is 0.2 wide in terms of position)</param>
  217. /// <param name="autoWire">Whether the block should be auto-wired (if functional)</param>
  218. /// <param name="player">The player who placed the block</param>
  219. public Block(BlockIDs type, float3 position, bool autoWire = false, Player player = null)
  220. {
  221. if (!PlacementEngine.IsInGame || !GameState.IsBuildMode())
  222. throw new BlockException("Blocks can only be placed in build mode.");
  223. var initializer = PlacementEngine.PlaceBlock(type, position, player, autoWire);
  224. Id = initializer.EGID;
  225. InitData.Group = BlockEngine.InitGroup(initializer);
  226. Placed += OnPlacedInit;
  227. }
  228. public EGID Id { get; }
  229. internal BlockEngine.BlockInitData InitData;
  230. private EGID copiedFrom;
  231. /// <summary>
  232. /// The block's current position or zero if the block no longer exists.
  233. /// A block is 0.2 wide by default in terms of position.
  234. /// </summary>
  235. public float3 Position
  236. {
  237. get => MovementEngine.GetPosition(Id, InitData);
  238. set
  239. {
  240. MovementEngine.MoveBlock(Id, InitData, value);
  241. if (blockGroup != null)
  242. blockGroup.PosAndRotCalculated = false;
  243. BlockEngine.UpdateDisplayedBlock(Id);
  244. }
  245. }
  246. /// <summary>
  247. /// The block's current rotation in degrees or zero if the block doesn't exist.
  248. /// </summary>
  249. public float3 Rotation
  250. {
  251. get => RotationEngine.GetRotation(Id, InitData);
  252. set
  253. {
  254. RotationEngine.RotateBlock(Id, InitData, value);
  255. if (blockGroup != null)
  256. blockGroup.PosAndRotCalculated = false;
  257. BlockEngine.UpdateDisplayedBlock(Id);
  258. }
  259. }
  260. /// <summary>
  261. /// The block's non-uniform scale or zero if the block's invalid. Independent of the uniform scaling.
  262. /// The default scale of 1 means 0.2 in terms of position.
  263. /// </summary>
  264. public float3 Scale
  265. {
  266. get => BlockEngine.GetBlockInfo(this, (ScalingEntityStruct st) => st.scale);
  267. set
  268. {
  269. int uscale = UniformScale;
  270. if (value.x < 4e-5) value.x = uscale;
  271. if (value.y < 4e-5) value.y = uscale;
  272. if (value.z < 4e-5) value.z = uscale;
  273. BlockEngine.SetBlockInfo(this, (ref ScalingEntityStruct st, float3 val) => st.scale = val, value);
  274. if (!Exists) return; //UpdateCollision needs the block to exist
  275. ScalingEngine.UpdateCollision(Id);
  276. BlockEngine.UpdateDisplayedBlock(Id);
  277. }
  278. }
  279. /// <summary>
  280. /// The block's uniform scale or zero if the block's invalid. Also sets the non-uniform scale.
  281. /// The default scale of 1 means 0.2 in terms of position.
  282. /// </summary>
  283. public int UniformScale
  284. {
  285. get => BlockEngine.GetBlockInfo(this, (UniformBlockScaleEntityStruct st) => st.scaleFactor);
  286. set
  287. {
  288. if (value < 1) value = 1;
  289. BlockEngine.SetBlockInfo(this, (ref UniformBlockScaleEntityStruct st, int val) => st.scaleFactor = val,
  290. value);
  291. Scale = new float3(value, value, value);
  292. }
  293. }
  294. /**
  295. * Whether the block is flipped.
  296. */
  297. public bool Flipped
  298. {
  299. get => BlockEngine.GetBlockInfo(this, (ScalingEntityStruct st) => st.scale.x < 0);
  300. set
  301. {
  302. BlockEngine.SetBlockInfo(this, (ref ScalingEntityStruct st, bool val) =>
  303. st.scale.x = math.abs(st.scale.x) * (val ? -1 : 1), value);
  304. BlockEngine.SetBlockInfo(this, (ref GFXPrefabEntityStructGPUI st, bool val) =>
  305. {
  306. uint prefabId = PrefabsID.GetOrCreatePrefabID((ushort) Type, (byte) Material, 0, value);
  307. st.prefabID = prefabId;
  308. }, value);
  309. }
  310. }
  311. /// <summary>
  312. /// The block's type (ID). Returns BlockIDs.Invalid if the block doesn't exist anymore.
  313. /// </summary>
  314. public BlockIDs Type
  315. {
  316. get
  317. {
  318. return BlockEngine.GetBlockInfo(this, (DBEntityStruct st) => (BlockIDs) st.DBID, BlockIDs.Invalid);
  319. }
  320. }
  321. /// <summary>
  322. /// The block's color. Returns BlockColors.Default if the block no longer exists.
  323. /// </summary>
  324. public BlockColor Color
  325. {
  326. get
  327. {
  328. byte index = BlockEngine.GetBlockInfo(this, (ColourParameterEntityStruct st) => st.indexInPalette,
  329. byte.MaxValue);
  330. return new BlockColor(index);
  331. }
  332. set
  333. {
  334. BlockEngine.SetBlockInfo(this, (ref ColourParameterEntityStruct color, BlockColor val) =>
  335. { //TODO: Check if setting to 255 works
  336. color.indexInPalette = val.Index;
  337. color.hasNetworkChange = true;
  338. color.paletteColour = BlockEngine.ConvertBlockColor(color.indexInPalette);
  339. }, value);
  340. }
  341. }
  342. /// <summary>
  343. /// The block's exact color. Gets reset to the palette color (Color property) after reentering the game.
  344. /// </summary>
  345. public float4 CustomColor
  346. {
  347. get => BlockEngine.GetBlockInfo(this, (ColourParameterEntityStruct st) => st.paletteColour);
  348. set
  349. {
  350. BlockEngine.SetBlockInfo(this, (ref ColourParameterEntityStruct color, float4 val) =>
  351. {
  352. color.paletteColour = val;
  353. color.hasNetworkChange = true;
  354. }, value);
  355. }
  356. }
  357. /**
  358. * The block's material.
  359. */
  360. public BlockMaterial Material
  361. {
  362. get => BlockEngine.GetBlockInfo(this, (CubeMaterialStruct cmst) => (BlockMaterial) cmst.materialId, BlockMaterial.Default);
  363. set => BlockEngine.SetBlockInfo(this,
  364. (ref CubeMaterialStruct cmst, BlockMaterial val) => cmst.materialId = (byte) val, value);
  365. }
  366. /// <summary>
  367. /// The text displayed on the block if applicable, or null.
  368. /// Setting it is temporary to the session, it won't be saved.
  369. /// </summary>
  370. public string Label
  371. {
  372. get => BlockEngine.GetBlockInfoViewStruct(this, (TextLabelEntityViewStruct st) => st.textLabelComponent?.text);
  373. set
  374. {
  375. BlockEngine.SetBlockInfoViewStruct(this, (ref TextLabelEntityViewStruct text, string val) =>
  376. {
  377. if (text.textLabelComponent != null) text.textLabelComponent.text = val;
  378. }, value);
  379. }
  380. }
  381. private BlockGroup blockGroup;
  382. /// <summary>
  383. /// Returns the block group this block is a part of. Block groups can also be placed using blueprints.
  384. /// Returns null if not part of a group.<br />
  385. /// Setting the group after the block has been initialized will not update everything properly,
  386. /// so you can only set this property on blocks newly placed by your code.<br />
  387. /// To set it for existing blocks, you can use the Copy() method and set the property on the resulting block
  388. /// (and remove this block).
  389. /// </summary>
  390. public BlockGroup BlockGroup
  391. {
  392. get
  393. {
  394. if (blockGroup != null) return blockGroup;
  395. return blockGroup = BlockEngine.GetBlockInfo(this,
  396. (BlockGroupEntityComponent bgec) =>
  397. bgec.currentBlockGroup == -1 ? null : new BlockGroup(bgec.currentBlockGroup, this));
  398. }
  399. set
  400. {
  401. if (Exists)
  402. {
  403. Logging.LogWarning("Attempted to set group of existing block. This is not supported."
  404. + " Copy the block and set the group of the resulting block.");
  405. return;
  406. }
  407. blockGroup?.RemoveInternal(this);
  408. BlockEngine.SetBlockInfo(this,
  409. (ref BlockGroupEntityComponent bgec, BlockGroup val) => bgec.currentBlockGroup = val?.Id ?? -1,
  410. value);
  411. value?.AddInternal(this);
  412. blockGroup = value;
  413. }
  414. }
  415. /// <summary>
  416. /// Whether the block exists. The other properties will return a default value if the block doesn't exist.
  417. /// If the block was just placed, then this will also return false but the properties will work correctly.
  418. /// </summary>
  419. public bool Exists => BlockEngine.BlockExists(Id);
  420. /// <summary>
  421. /// Returns an array of blocks that are connected to this one. Returns an empty array if the block doesn't exist.
  422. /// </summary>
  423. public Block[] GetConnectedCubes() => BlockEngine.GetConnectedBlocks(Id);
  424. /// <summary>
  425. /// Removes this block.
  426. /// </summary>
  427. /// <returns>True if the block exists and could be removed.</returns>
  428. public bool Remove() => RemovalEngine.RemoveBlock(Id);
  429. /// <summary>
  430. /// Returns the rigid body of the chunk of blocks this one belongs to during simulation.
  431. /// Can be used to apply forces or move the block around while the simulation is running.
  432. /// </summary>
  433. /// <returns>The SimBody of the chunk or null if the block doesn't exist or not in simulation mode.</returns>
  434. public SimBody GetSimBody()
  435. {
  436. return BlockEngine.GetBlockInfo(this,
  437. (GridConnectionsEntityStruct st) => st.machineRigidBodyId != uint.MaxValue
  438. ? new SimBody(st.machineRigidBodyId, st.clusterId)
  439. : null);
  440. }
  441. /// <summary>
  442. /// Creates a copy of the block in the game with the same properties, stats and wires.
  443. /// </summary>
  444. /// <returns></returns>
  445. public T Copy<T>() where T : Block
  446. {
  447. var block = PlaceNew<T>(Type, Position);
  448. block.Rotation = Rotation;
  449. block.Color = Color;
  450. block.Material = Material;
  451. block.UniformScale = UniformScale;
  452. block.Scale = Scale;
  453. block.copiedFrom = Id;
  454. return block;
  455. }
  456. private void OnPlacedInit(object sender, BlockPlacedRemovedEventArgs e)
  457. { //Member method instead of lambda to avoid constantly creating delegates
  458. if (e.ID != Id) return;
  459. Placed -= OnPlacedInit; //And we can reference it
  460. InitData = default; //Remove initializer as it's no longer valid - if the block gets removed it shouldn't be used again
  461. if (copiedFrom != EGID.Empty)
  462. BlockCloneEngine.CopyBlockStats(copiedFrom, Id);
  463. }
  464. public override string ToString()
  465. {
  466. return $"{nameof(Id)}: {Id}, {nameof(Position)}: {Position}, {nameof(Type)}: {Type}, {nameof(Color)}: {Color}, {nameof(Exists)}: {Exists}";
  467. }
  468. public bool Equals(Block other)
  469. {
  470. if (ReferenceEquals(null, other)) return false;
  471. if (ReferenceEquals(this, other)) return true;
  472. return Id.Equals(other.Id);
  473. }
  474. public bool Equals(EGID other)
  475. {
  476. return Id.Equals(other);
  477. }
  478. public override bool Equals(object obj)
  479. {
  480. if (ReferenceEquals(null, obj)) return false;
  481. if (ReferenceEquals(this, obj)) return true;
  482. if (obj.GetType() != this.GetType()) return false;
  483. return Equals((Block) obj);
  484. }
  485. public override int GetHashCode()
  486. {
  487. return Id.GetHashCode();
  488. }
  489. public static void Init()
  490. {
  491. GameEngineManager.AddGameEngine(PlacementEngine);
  492. GameEngineManager.AddGameEngine(MovementEngine);
  493. GameEngineManager.AddGameEngine(RotationEngine);
  494. GameEngineManager.AddGameEngine(RemovalEngine);
  495. GameEngineManager.AddGameEngine(BlockEngine);
  496. GameEngineManager.AddGameEngine(BlockEventsEngine);
  497. GameEngineManager.AddGameEngine(ScalingEngine);
  498. GameEngineManager.AddGameEngine(SignalEngine);
  499. GameEngineManager.AddGameEngine(BlockCloneEngine);
  500. Wire.signalEngine = SignalEngine; // requires same functionality, no need to duplicate the engine
  501. }
  502. /// <summary>
  503. /// Convert the block to a specialised block class.
  504. /// </summary>
  505. /// <returns>The block.</returns>
  506. /// <typeparam name="T">The specialised block type.</typeparam>
  507. public T Specialise<T>() where T : Block
  508. {
  509. // What have I gotten myself into?
  510. // C# can't cast to a child of Block unless the object was originally that child type
  511. // And C# doesn't let me make implicit cast operators for child types
  512. // So thanks to Microsoft, we've got this horrible implementation using reflection
  513. //Lets improve that using delegates
  514. var block = New<T>(Id.entityID, Id.groupID);
  515. if (this.InitData.Group != null)
  516. {
  517. block.InitData = this.InitData;
  518. Placed += block.OnPlacedInit; //Reset InitData of new object
  519. }
  520. return block;
  521. }
  522. #if DEBUG
  523. public static EntitiesDB entitiesDB
  524. {
  525. get
  526. {
  527. return BlockEngine.GetEntitiesDB();
  528. }
  529. }
  530. #endif
  531. }
  532. }