Example #1
0
        public SeObservation GetObservation()
        {
            var entity = new SeEntity()
            {
                Id       = "Ente",
                Position = new PlainVec3D(3, 2, 1)
            };

            var entities = new List <SeEntity>
            {
                entity
            };

            var block = new SeBlock()
            {
                Id             = "blk",
                Position       = new PlainVec3D(5, 5, 5),
                MaxIntegrity   = 10f,
                BuildIntegrity = 1.0f,
                Integrity      = 5.0f
            };

            var blocks = new List <SeBlock>
            {
                block
            };

            return(new SeObservation()
            {
                AgentID = "Mock",
                Position = new PlainVec3D(4, 2, 0),
                Entities = entities,
                Blocks = blocks
            });
        }
Example #2
0
        private List <SeBlock> CollectSurroundingBlocks(BoundingSphereD sphere)
        {
            var ivBlocks = new List <SeBlock>();             // iv4XR interface blocks ("SE blocks" from the outside)

            foreach (MyEntity entity in EnumerateSurroundingEntities(sphere))
            {
                var grid = entity as MyCubeGrid;
                if (grid is null)
                {
                    continue;
                }

                var foundBlocks = new HashSet <MySlimBlock>();
                grid.GetBlocksInsideSphere(ref sphere, foundBlocks);                  // NOTE: This might be slow (profiled ages ago)

                foreach (IMySlimBlock sourceBlock in foundBlocks)
                {
                    var ivBlock = new SeBlock
                    {
                        // TODO(PP): generate some Id?
                        Position       = new PlainVec3D(grid.GridIntegerToWorld(sourceBlock.Position)),
                        MaxIntegrity   = sourceBlock.MaxIntegrity,
                        BuildIntegrity = sourceBlock.BuildIntegrity,
                        Integrity      = sourceBlock.Integrity
                    };

                    ivBlocks.Add(ivBlock);

                    if (ivBlocks.Count() > 1000)                      // TODO(PP): Define as param.
                    {
                        Log?.WriteLine($"{nameof(CollectSurroundingBlocks)}: Too many blocks!");
                        break;
                    }
                }
            }

            return(ivBlocks);
        }