private void DebugDrawGeneratingBlock(MySlimBlock generatedBlock) { var generatingBlock = generatedBlock.CubeGrid.GetGeneratingBlock(generatedBlock); if (generatingBlock != null) { VRageRender.MyRenderProxy.DebugDrawText2D(new Vector2(0, 0), "Generated SubTypeId: " + generatedBlock.BlockDefinition.Id.SubtypeName + " " + generatedBlock.Min.ToString() + " " + generatedBlock.Orientation.ToString(), Color.Yellow, DEBUG_SCALE); VRageRender.MyRenderProxy.DebugDrawText2D(new Vector2(0, 14), "Generating SubTypeId: " + generatingBlock.BlockDefinition.Id.SubtypeName + " " + generatingBlock.Min.ToString() + " " + generatingBlock.Orientation.ToString(), Color.Yellow, DEBUG_SCALE); Vector4 blue = new Vector4(Color.Blue.ToVector3() * 0.8f, 1); MyCubeBuilder.DrawSemiTransparentBox(generatingBlock.CubeGrid, generatingBlock, Color.Blue, lineColor: blue); } }
public override void LoadData() { Static = this; MyCubeGrid.ShowStructuralIntegrity = false; }
protected virtual void InitSubBlocks() { if (!MyFakes.ENABLE_SUBBLOCKS) { return; } if (m_subBlocksInitialized) { return; } // if (!Sync.IsServer) // return; try { MyCubeBlockDefinition subBlockDefinition; MatrixD subBlockMatrix; Vector3 dummyPosition; var finalModel = Sandbox.Engine.Models.MyModels.GetModelOnlyDummies(BlockDefinition.Model); foreach (var dummy in finalModel.Dummies) { if (!MyCubeBlock.GetSubBlockDataFromDummy(BlockDefinition, dummy.Key, dummy.Value, true, out subBlockDefinition, out subBlockMatrix, out dummyPosition)) { continue; } string dummyName = dummy.Key.Substring(DUMMY_SUBBLOCK_ID.Length); MySlimBlock subblock = null; MyCubeGrid subgrid = null; MySubBlockLoadInfo subBlockLoadInfo; if (m_subBlockIds.TryGetValue(dummyName, out subBlockLoadInfo)) { MyEntity entity; if (MyEntities.TryGetEntityById(subBlockLoadInfo.GridId, out entity)) { subgrid = entity as MyCubeGrid; if (subgrid != null) { subblock = subgrid.GetCubeBlock(subBlockLoadInfo.SubBlockPosition); Debug.Assert(subblock != null, "Cannot find subblock in subgrid!"); if (subblock == null) { continue; } } else { Debug.Assert(false, "Loaded entity is not grid!"); continue; } } else { Debug.Assert(false, "Cannot load subgrid!"); continue; } } if (!m_subBlocksLoaded) { if (subgrid == null) { Debug.Assert(!subBlockMatrix.IsMirrored()); Matrix subGridWorldMatrix = subBlockMatrix * PositionComp.LocalMatrix * CubeGrid.WorldMatrix; //TODO: Try to find better way how to sync entity ID of subblocks.. subgrid = MyCubeBuilder.SpawnDynamicGrid(subBlockDefinition, subGridWorldMatrix, EntityId + SubBlocks.Count + 1); if (subgrid != null) { subblock = subgrid.GetCubeBlock(Vector3I.Zero); } } if (subgrid == null) { Debug.Assert(false, "SubGrid has not been set!"); continue; } if (subblock == null || subblock.FatBlock == null) { Debug.Assert(false, "Fatblock cannot be null for subblocks!"); continue; } } if (subblock != null) { SubBlocks.Add(dummyName, subblock); subblock.FatBlock.SubBlockName = dummyName; subblock.FatBlock.OwnerBlock = SlimBlock; subblock.FatBlock.OnClosing += SubBlock_OnClosing; Debug.Assert(SlimBlock != null); } } } finally { m_subBlockIds.Clear(); m_subBlocksInitialized = true; } }
public override void LoadData() { base.LoadData(); m_cubeBuildlerState = new MyCubeBuilderState(); Static = this; MyCubeGrid.ShowStructuralIntegrity = false; }