public static void ApplyOperation(MyEntity entity, MyTrashRemovalOperation operation) { if ((operation & MyTrashRemovalOperation.Remove) == MyTrashRemovalOperation.Remove) { entity.Close(); return; } if ((operation & MyTrashRemovalOperation.Stop) == MyTrashRemovalOperation.Stop && entity.Physics != null) { entity.Physics.LinearVelocity = Vector3.Zero; entity.Physics.AngularVelocity = Vector3.Zero; } if ((operation & MyTrashRemovalOperation.Depower) == MyTrashRemovalOperation.Depower) { var grid = entity as MyCubeGrid; if (grid != null) { grid.ChangePowerProducerState(MyMultipleEnabledEnum.AllDisabled, 0); } } }
internal void CloseChildEntity(MyEntity child) { RemoveChildEntity(child); child.Close(); }
private void SwitchWeapon(ref IMyHandheldGunObject <MyDeviceBase> weapon, ref MyVRWeaponInfo weaponInfo, List <MyVRWeaponInfo> weapons, ControllerRole role, Vector2?touchpadPos) { int currentIndex = -1; if (weapon != null) { for (int i = 0; i < weapons.Count; ++i) { var info = weapons[i]; if (info.DefinitionId == weapon.DefinitionId) { currentIndex = i; break; } } } int nextIndex = 0; if (touchpadPos != null) { Vector2 pos = touchpadPos.Value; if (touchpadPos != Vector2.Zero) { pos.Normalize(); float anglePerWeaponSector = 360f / weapons.Count; float dot = Vector2.Dot(Vector2.UnitX, pos); float angle = (float)Math.Acos(Math.Abs(dot)); if (pos.Y >= 0) { if (dot < 0) { angle = 180 - angle; } } else { if (dot < 0) { angle = 180 + angle; } else { angle = 360 - angle; } } nextIndex = (int)Math.Floor(angle / anglePerWeaponSector); Debug.Assert(nextIndex < weapons.Count); } } if (nextIndex == currentIndex) { return; } if (weapon != null) { weapon.OnControlReleased(); MyEntity weaponEntity = (MyEntity)weapon; weaponEntity.Close(); weapon = null; } { weaponInfo = weapons[nextIndex]; weapon = CreateWeapon(weaponInfo.DefinitionId, weaponInfo.Reference); weapon.OnControlAcquired(null); MyEntity weaponEntity = (MyEntity)weapon; } var gunBase = weapon.GunBase as MyGunBase; Matrix holdingMatrix = gunBase != null ? gunBase.m_holdingDummyMatrix : Matrix.Identity; MyOpenVR.LMUAdd(holdingMatrix, m_worldMatrixOriginal, role, weaponInfo.Reference); }