コード例 #1
0
        public static ConcealedGridsResponse FromBytes(byte[] bytes)
        {
            VRage.ByteStream stream = new VRage.ByteStream(bytes, bytes.Length);
            ConcealedGridsResponse response = new ConcealedGridsResponse();

            ConcealableGrid grid;
            ushort count = stream.getUShort();
            for (int i = 0; i < count; i++) {
                grid = new ConcealableGrid();
                grid.RemoveFromByteStream(stream);
                response.ConcealedGrids.Add(grid);
            }

            return response;
        }
コード例 #2
0
        private void SaveBuilders()
        {
            String GridBuildersFileName = "build_list_test.txt";
            List<MyObjectBuilder_CubeGrid> concealedGridBuilderList;

            HashSet<IMyEntity> allGrids = new HashSet<IMyEntity>();
            MyAPIGateway.Entities.GetEntities(allGrids, (x) => x is IMyCubeGrid);

            /*
            concealedGridBuilderList =
                allGrids.Select(x => x.GetObjectBuilder() as MyObjectBuilder_CubeGrid).ToList();

            Log.Trace("Trying to save pulled from world", "Save");
            GardenGateway.Files.Overwrite(
                MyAPIGateway.Utilities.
                    SerializeToXML<List<MyObjectBuilder_CubeGrid>>(concealedGridBuilderList),
                GridBuildersFileName
            );
            Log.Trace("Finished saving pulled from world!!!", "Save");
            */

            // Fails
            //concealedGridBuilderList =
            //    RevealedGrids.Select(kvp => kvp.Value.Builder).ToList();
            /*
            concealedGridBuilderList =
                allGrids.Select((x) => {
                    var concealable = new ConcealableGrid();
                    concealable.LoadFromCubeGrid(x)
                    return x.GetObjectBuilder() as MyObjectBuilder_CubeGrid;
                }).ToList();
            */

            concealedGridBuilderList =
                allGrids.Select((x) => {
                    IMyCubeGrid grid = x as IMyCubeGrid;

                    //return x.GetObjectBuilder() as MyObjectBuilder_CubeGrid;
                    //return grid.GetObjectBuilder() as MyObjectBuilder_CubeGrid;

                    var concealable = new ConcealableGrid();
                    concealable.LoadFromCubeGrid(grid);

                    //return concealable.IngameGrid.GetObjectBuilder() as MyObjectBuilder_CubeGrid;

                    // /\ success

                    return concealable.Builder;

                    // \/ failure

                    //return concealable.Builder;
                }).ToList();

            GardenGateway.Files.Overwrite(
                MyAPIGateway.Utilities.
                    SerializeToXML<List<MyObjectBuilder_CubeGrid>>(concealedGridBuilderList),
                "real_" + GridBuildersFileName
            );

            /*

            List<MyObjectBuilder_EntityBase> concealedGridBuilderList =
                ConcealedGrids.Values.Select(x => x.Builder).ToList();

            BuilderListHelper.Save(concealedGridBuilderList, GridBuildersFileName);
             *
            *//*

            if (!GardenGateway.Files.Exists(GridBuildersFileName)) {
                Log.Error("Error saving grid builders", "SaveBuilders");
            } else {
                Log.Trace("Saved Builders", "SaveBuilders");
            }
               * */
        }
コード例 #3
0
        public void AddIngameEntity(IMyEntity entity)
        {
            Log.Trace("Adding entity " + entity.EntityId + " of type " +
                entity.GetType(), "AddIngameEntity");

            if (entity.Transparent) {
                Log.Trace("It's Transparent, skipping", "AddIngameEntity");
                return;
            }

            // TODO: Store other types of entities
            if (entity is IMyCubeGrid) {
                Log.Trace("It's a CubeGrid.", "AddIngameEntity");
                IMyCubeGrid grid = entity as IMyCubeGrid;
                var revealedGrid = new ConcealableGrid();
                revealedGrid.LoadFromCubeGrid(grid);
                RevealedGrids[grid.EntityId] = revealedGrid;
            }
            if (entity is IMyCharacter) {
                Log.Trace("It's a Character", "AddIngameEntity");
            }
            if (entity is IMyCubeBlock) {
                Log.Trace("It's a CubeBlock", "AddIngameEntity");
            }
            if (entity is IMyCubeBuilder) {
                Log.Trace("It's a CubeBuilder", "AddIngameEntity");
            }
        }