public bool PasteFloatingObject(MyInventory buildInventory = null) { if (this.m_copiedFloatingObjects.Count == 0) { return(false); } if ((this.m_copiedFloatingObjects.Count > 0) && !this.IsActive) { if (this.CheckPastedFloatingObjects()) { this.Activate(); } else { MyHud.Notifications.Add(MyNotificationSingletons.CopyPasteBlockNotAvailable); MyGuiAudio.PlaySound(MyGuiSounds.HudUnable); } return(true); } if (!this.m_canBePlaced) { MyGuiAudio.PlaySound(MyGuiSounds.HudUnable); return(false); } MyGuiAudio.PlaySound(MyGuiSounds.HudPlaceItem); Sandbox.Game.Entities.MyEntities.RemapObjectBuilderCollection((IEnumerable <MyObjectBuilder_EntityBase>) this.m_copiedFloatingObjects); bool flag = false; int num = 0; foreach (MyObjectBuilder_FloatingObject local1 in this.m_copiedFloatingObjects) { local1.PersistentFlags = MyPersistentEntityFlags2.InScene | MyPersistentEntityFlags2.Enabled; local1.PositionAndOrientation = new MyPositionAndOrientation(this.m_previewFloatingObjects[num].WorldMatrix); num++; MyFloatingObjects.RequestSpawnCreative(local1); flag = true; } this.Deactivate(); return(flag); }
public bool PasteFloatingObject(MyInventory buildInventory = null) { if (m_copiedFloatingObjects.Count == 0) { return(false); } if ((m_copiedFloatingObjects.Count > 0) && !IsActive) { if (CheckPastedFloatingObjects()) { Activate(); } else { MyHud.Notifications.Add(MyNotificationSingletons.CopyPasteBlockNotAvailable); MyGuiAudio.PlaySound(MyGuiSounds.HudUnable); } return(true); } if (!m_canBePlaced) { MyGuiAudio.PlaySound(MyGuiSounds.HudUnable); return(false); } MyGuiAudio.PlaySound(MyGuiSounds.HudPlaceItem); MyEntities.RemapObjectBuilderCollection(m_copiedFloatingObjects); bool retVal = false; int i = 0; foreach (var floatingObjectBuilder in m_copiedFloatingObjects) { floatingObjectBuilder.PersistentFlags = MyPersistentEntityFlags2.InScene | MyPersistentEntityFlags2.Enabled; //MyFloatingObject pastedFloatingObject = MyEntities.CreateFromObjectBuilderAndAdd(floatingObjectBuilder) as MyFloatingObject; //if (i == 0) firstPastedFloatingObject = pastedFloatingObject; //if (pastedFloatingObject == null) //{ // retVal = true; // continue; //} floatingObjectBuilder.PositionAndOrientation = new MyPositionAndOrientation(m_previewFloatingObjects[i].WorldMatrix); i++; // No velocity saving :) //floatingObjectBuilder.LinearVelocity = m_objectVelocity; //if (MySession.Static.ControlledEntity != null && MySession.Static.ControlledEntity.Entity.Physics != null && m_calculateVelocity) //{ // pastedFloatingObject.Physics.AngularVelocity = MySession.Static.ControlledEntity.Entity.Physics.AngularVelocity; //} MyFloatingObjects.RequestSpawnCreative(floatingObjectBuilder); retVal = true; } Deactivate(); return(retVal); }