private void ChangeClipboardPreview(bool visible) { if ((this.m_copiedFloatingObjects.Count == 0) || !visible) { foreach (MyFloatingObject local1 in this.m_previewFloatingObjects) { Vector4? color = null; Vector3? inflateAmount = null; MyStringId?lineMaterial = null; Sandbox.Game.Entities.MyEntities.EnableEntityBoundingBoxDraw(local1, false, color, 0.01f, inflateAmount, lineMaterial); local1.Close(); } this.m_previewFloatingObjects.Clear(); this.m_visible = false; } else { Sandbox.Game.Entities.MyEntities.RemapObjectBuilderCollection((IEnumerable <MyObjectBuilder_EntityBase>) this.m_copiedFloatingObjects); using (List <MyObjectBuilder_FloatingObject> .Enumerator enumerator2 = this.m_copiedFloatingObjects.GetEnumerator()) { while (enumerator2.MoveNext()) { MyFloatingObject floatingObject = Sandbox.Game.Entities.MyEntities.CreateFromObjectBuilder(enumerator2.Current, false) as MyFloatingObject; if (floatingObject == null) { this.ChangeClipboardPreview(false); break; } this.MakeTransparent(floatingObject); this.IsActive = visible; this.m_visible = visible; Sandbox.Game.Entities.MyEntities.Add(floatingObject, true); MyFloatingObjects.UnregisterFloatingObject(floatingObject); floatingObject.Save = false; this.DisablePhysicsRecursively(floatingObject); this.m_previewFloatingObjects.Add(floatingObject); } } } }
private void ChangeClipboardPreview(bool visible) { if (m_copiedFloatingObjects.Count == 0 || !visible) { foreach (var grid in m_previewFloatingObjects) { MyEntities.EnableEntityBoundingBoxDraw(grid, false); grid.Close(); } m_previewFloatingObjects.Clear(); m_visible = false; return; } MyEntities.RemapObjectBuilderCollection(m_copiedFloatingObjects); foreach (var gridBuilder in m_copiedFloatingObjects) { var previewFloatingObject = MyEntities.CreateFromObjectBuilder(gridBuilder) as MyFloatingObject; if (previewFloatingObject == null) { ChangeClipboardPreview(false); return;// Not enough memory to create preview grid or there was some error. } MakeTransparent(previewFloatingObject); IsActive = visible; m_visible = visible; MyEntities.Add(previewFloatingObject); // MW: we want the floating object to be added to the scene, but we dont want to treat it as a real floating object MyFloatingObjects.UnregisterFloatingObject(previewFloatingObject); previewFloatingObject.Save = false; DisablePhysicsRecursively(previewFloatingObject); m_previewFloatingObjects.Add(previewFloatingObject); } }
protected override void Closing() { MyFloatingObjects.UnregisterFloatingObject(this); base.Closing(); }