/// <summary> /// Adds static entity to the world /// </summary> /// <param name="entity"></param> /// <param name="sourceDynamicId">Parent entity that issues adding</param> public void AddEntity(IStaticEntity entity, uint sourceDynamicId = 0) { Vector3I entityBlockPosition; //If the entity is of type IBlockLinkedEntity, then it needs to be store inside the chunk where the LinkedEntity belong. var blockLinkedEntity = entity as IBlockLinkedEntity; if (blockLinkedEntity != null && blockLinkedEntity.Linked) { entityBlockPosition = blockLinkedEntity.LinkedCube; // you probably forget to set LinkedCube property of the entity if (Vector3D.DistanceSquared(entity.Position, blockLinkedEntity.LinkedCube) > 256) { throw new InvalidOperationException("Invalid linked block"); } } else { entityBlockPosition = (Vector3I)entity.Position; } var entityChunk = _manager.GetChunkFromBlock(entityBlockPosition); entityChunk.Entities.Add(entity, sourceDynamicId == 0 ? OwnerDynamicId : sourceDynamicId); }
public string GetDebugInfo() { var chunk = _landscapeManager.GetChunkFromBlock(new Vector3I(Player.Position.X, Player.Position.Y, Player.Position.Z)); return(string.Format("Player {0} Pos: [{1:000}; {2:000}; {3:000}] Chunk : {4}", PlayerCharacter.CharacterName, Math.Round(Player.Position.X, 1), Math.Round(Player.Position.Y, 1), Math.Round(Player.Position.Z, 1), chunk == null ?"" : chunk.Position.ToString() )); }