public MyFloatingObjectPhysicsStateGroup(MyFloatingObject entity, IMyReplicable owner) : base(entity, owner) { m_lowPrecisionOrientation = true; m_prioritySettings.AcceleratingPriority /= 2; m_prioritySettings.LinearMovingPriority /= 2; m_prioritySettings.StoppedPriority /= 2; m_prioritySettings.AcceleratingUpdateCount *= 2; m_prioritySettings.LinearMovingUpdateCount *= 2; m_prioritySettings.StoppedUpdateCount *= 2; }
private void OnCutFloatingObjectConfirm(MyFloatingObject floatingObj) { Debug.Assert(floatingObj != null); if (MyEntities.Exist(floatingObj)) { DeactivateCopyPasteVoxel(true); DeactivateCopyPaste(true); m_floatingObjectClipboard.CutFloatingObject(floatingObj); } }
private void MakeTransparent(MyFloatingObject floatingObject) { floatingObject.Render.Transparency = MyGridConstants.BUILDER_TRANSPARENCY; }
private void CopyFloatingObjectInternal(MyFloatingObject toCopy) { m_copiedFloatingObjects.Add((MyObjectBuilder_FloatingObject)toCopy.GetObjectBuilder(true)); if (m_copiedFloatingObjects.Count == 1) { MatrixD pasteMatrix = GetPasteMatrix(); Vector3 dragPointGlobal = toCopy.WorldMatrix.Translation; m_dragPointToPositionLocal = Vector3D.TransformNormal(toCopy.PositionComp.GetPosition() - dragPointGlobal, toCopy.PositionComp.WorldMatrixNormalizedInv); m_dragDistance = (float)(dragPointGlobal - pasteMatrix.Translation).Length(); m_pasteDirUp = toCopy.WorldMatrix.Up; m_pasteDirForward = toCopy.WorldMatrix.Forward; m_pasteOrientationAngle = 0.0f; } m_copiedFloatingObjectOffsets.Add(toCopy.WorldMatrix.Translation - m_copiedFloatingObjects[0].PositionAndOrientation.Value.Position); }
public void CopyfloatingObject(MyFloatingObject floatingObject) { if (floatingObject == null) return; m_copiedFloatingObjects.Clear(); m_copiedFloatingObjectOffsets.Clear(); CopyFloatingObjectInternal(floatingObject); Activate(); }
public void CutFloatingObject(MyFloatingObject floatingObject) { if (floatingObject == null) return; CopyfloatingObject(floatingObject); MyFloatingObjects.RemoveFloatingObject(floatingObject, true); Deactivate(); }
public void PickupItem(MyFloatingObject obj, MyFixedPoint amount) { MyMultiplayer.RaiseEvent(this, x => x.PickupItem_Implementation, obj.EntityId, amount); }
public void TakeFloatingObject(MyFloatingObject obj) { MyFixedPoint amount = obj.Item.Amount; if (MyPerGameSettings.ConstrainInventory()) { amount = MyFixedPoint.Min(ComputeAmountThatFits(obj.Item.Content.GetObjectId()), amount); } if (obj.MarkedForClose) return; if (amount > 0) { if (Sync.IsServer) { MyFloatingObjects.RemoveFloatingObject(obj, amount); AddItemsInternal(amount, obj.Item.Content); } } }
private static bool ComputeFloatingObjectAmount(MyFloatingObject obj, ref MyFixedPoint amount, MyInventory inv) { amount = obj.Item.Amount; if (!MySession.Static.CreativeMode) amount = MyFixedPoint.Min(amount, inv.ComputeAmountThatFits(obj.Item.Content.GetId())); if (amount <= 0) // does not fit into inventory return false; return true; }
private static bool TakeFloatingObjectPrepare(long ownerEntityId, long floatingObjectId, byte inventoryIndex, out MyFloatingObject obj, out MyFixedPoint amount) { obj = null; amount = 0; if (!MyEntities.EntityExists(ownerEntityId) || !MyEntities.EntityExists(floatingObjectId)) return false; obj = MyEntities.GetEntityById(floatingObjectId) as MyFloatingObject; if (obj.MarkedForClose) return false; var owner = MyEntities.GetEntityById(ownerEntityId) as IMyInventoryOwner; var inv = owner.GetInventory(inventoryIndex); return ComputeFloatingObjectAmount(obj, ref amount, inv); }
public void TakeFloatingObjectRequest(MyInventory inv, MyFloatingObject obj) { var msg = new TakeFloatingObjectMsg(); msg.OwnerEntityId = inv.Owner.EntityId; msg.InventoryIndex = inv.InventoryIdx; msg.FloatingObjectId = obj.EntityId; Sync.Layer.SendMessageToServer(ref msg, MyTransportMessageEnum.Request); }
public void OnWorldPosChanged(ref MatrixD newTransform) { MatrixD worldPos = newTransform; m_caster.OnWorldPositionChanged(ref worldPos); var entitiesInRange = this.m_caster.EntitiesInRange; float closestDistance = float.MaxValue; MyEntity closestEntity = null; if (!m_isPointOfRefSet) m_pointOfReference = worldPos.Translation; if (entitiesInRange != null && entitiesInRange.Count > 0) { // int i = 0; foreach (var entity in entitiesInRange.Values) { float distanceSq = (float)Vector3D.DistanceSquared(entity.DetectionPoint, m_pointOfReference); if (entity.Entity.Physics != null && entity.Entity.Physics.Enabled) { if (distanceSq < closestDistance) { closestEntity = entity.Entity; this.m_distanceToHitSq = distanceSq; this.m_hitPosition = entity.DetectionPoint; closestDistance = distanceSq; } } // ++i; } } this.m_hitCubeGrid = closestEntity as MyCubeGrid; this.m_hitBlock = null; this.m_hitDestroaybleObj = closestEntity as IMyDestroyableObject; this.m_hitFloatingObject = closestEntity as MyFloatingObject; this.m_hitCharacter = closestEntity as MyCharacter; if (m_hitCubeGrid != null) { var invWorld = m_hitCubeGrid.PositionComp.WorldMatrixNormalizedInv; var gridLocalPos = Vector3D.Transform(this.m_hitPosition, invWorld); Vector3I blockPos; m_hitCubeGrid.FixTargetCube(out blockPos, gridLocalPos / m_hitCubeGrid.GridSize); m_hitBlock = m_hitCubeGrid.GetCubeBlock(blockPos); } }
public override void OnAddedToContainer() { base.OnAddedToContainer(); m_floatingObject = Container.Entity as MyFloatingObject; }
public void CutFloatingObject(MyFloatingObject floatingObject) { if (floatingObject == null) return; CopyfloatingObject(floatingObject); floatingObject.SyncObject.SendCloseRequest(); Deactivate(); }
public FloatingObjectWrapper( MyFloatingObject entity ) { Entity = entity; }
public override void OnAddedToContainer(MyComponentContainer container) { base.OnAddedToContainer(container); m_floatingObject = Entity as MyFloatingObject; }