示例#1
0
        public StructurePlayerModel(long builtBy, IEnumerable <MyObjectBuilder_CubeBlock> cubes)
            : base(null)
        {
            var identity = SpaceEngineersCore.WorldResource.Checkpoint.Identities.FirstOrDefault(p => p.PlayerId == builtBy);

            if (identity != null)
            {
                DisplayName = identity.DisplayName;
            }
            else
            {
                DisplayName = "Nobody";
            }
            _blockStatistics = new BlockStatistics(cubes);
            CountBlocks(cubes);
        }
        public StructureProjectorModel(MyObjectBuilder_CubeGrid grid, MyObjectBuilder_Projector proj)
            : base(null)
        {
            var identity = SpaceEngineersCore.WorldResource.Checkpoint.Identities.FirstOrDefault(p => p.PlayerId == proj.Owner);

            if (identity != null)
            {
                _ownerName = identity.DisplayName;
            }
            else
            {
                _ownerName = "Nobody";
            }
            _gridName = grid.DisplayName;
            identity  = SpaceEngineersCore.WorldResource.Checkpoint.Identities.FirstOrDefault(p => p.PlayerId == proj.BuiltBy);
            if (identity != null)
            {
                _builderName = identity.DisplayName;
            }
            else
            {
                _builderName = "Nobody";
            }
            _builderName = $"(by {_builderName})";
            identity     = SpaceEngineersCore.WorldResource.Checkpoint.Identities.FirstOrDefault(p => p.PlayerId == grid.GetTopBuilderId());
            if (identity != null)
            {
                _gridBuilderName = identity.DisplayName;
            }
            else
            {
                _gridBuilderName = "Nobody";
            }
            _gridBuilderName = $"(by {_gridBuilderName})";
            DisplayName      = proj.GetBlockName(grid);
            _enabled         = proj.Enabled && proj.ProjectedGrid != null;
            if (proj.ProjectedGrid == null)
            {
                return;
            }
            _blockStatistics = new BlockStatistics(proj.ProjectedGrid.CubeBlocks);
            BlockCount       = proj.ProjectedGrid.CubeBlocks.Count;
            _blockCountStr   = $"{proj.ProjectedGrid.CubeBlocks.Count} ({((decimal)proj.ProjectedGrid.CubeBlocks.Count / grid.CubeBlocks.Count * 100):F1}% of self)";
        }