SEToolbox.Models.CubeItemModel.SetProperties C# (CSharp) Method

SetProperties() private method

private SetProperties ( Sandbox.Common.ObjectBuilders.MyObjectBuilder_CubeBlock cube, MyCubeBlockDefinition definition ) : void
cube Sandbox.Common.ObjectBuilders.MyObjectBuilder_CubeBlock
definition MyCubeBlockDefinition
return void
        private void SetProperties(MyObjectBuilder_CubeBlock cube, MyCubeBlockDefinition definition)
        {
            Cube = cube;
            Position = new BindablePoint3DIModel(cube.Min);
            SetColor(cube.ColorMaskHSV);
            BuildPercent = cube.BuildPercent;

            if (definition == null)
            {
                // Obsolete block or Mod not loaded.
                return;
            }

            CubeSize = definition.CubeSize;
            FriendlyName = SpaceEngineersApi.GetResourceName(definition.DisplayNameText);

            var identity = SpaceEngineersCore.WorldResource.Checkpoint.Identities.FirstOrDefault(p => p.PlayerId == Owner);
            var dead = " (dead)";
            if (SpaceEngineersCore.WorldResource.Checkpoint.AllPlayersData != null)
            {
                var player = SpaceEngineersCore.WorldResource.Checkpoint.AllPlayersData.Dictionary.FirstOrDefault(kvp => kvp.Value.IdentityId == Owner);
                dead = player.Value == null ? " (dead)" : "";
            }
            OwnerName = identity == null ? null : identity.DisplayName + dead;
            TypeId = definition.Id.TypeId;
            SubtypeId = definition.Id.SubtypeName;

            if (Inventory == null)
                Inventory = new ObservableCollection<InventoryEditorModel>();

            foreach (var item in cube.ComponentContainer.GetInventory(definition))
                Inventory.Add(item);

            while (Inventory.Count < 2)
            {
                Inventory.Add(new InventoryEditorModel(false));
            }
        }