public MyPetaInputComponent() { AddShortcut(MyKeys.OemBackslash, true, true, false, false, () => "Debug draw physics clusters: " + MyDebugDrawSettings.DEBUG_DRAW_PHYSICS_CLUSTERS, delegate { MyDebugDrawSettings.DEBUG_DRAW_PHYSICS_CLUSTERS = !MyDebugDrawSettings.DEBUG_DRAW_PHYSICS_CLUSTERS; return(true); }); AddShortcut(MyKeys.OemBackslash, false, false, false, false, () => "Advance all moving entities", delegate { foreach (var entity in MyEntities.GetEntities().ToList()) { if (entity.Physics != null) { if (entity.Physics.LinearVelocity.Length() > 0.1f) { entity.PositionComp.SetPosition(entity.PositionComp.GetPosition() + entity.Physics.LinearVelocity * 10); } } } return(true); }); AddShortcut(MyKeys.S, true, true, false, false, () => "Insert controllable sphere", delegate { MyControllableSphere sphere = new MyControllableSphere(); sphere.Init(); MyEntities.Add(sphere); sphere.PositionComp.SetPosition(MySector.MainCamera.Position + 2 * MySector.MainCamera.ForwardVector); sphere.Physics.Enabled = false; MySession.LocalHumanPlayer.Controller.TakeControl(sphere); return(true); }); AddShortcut(MyKeys.Back, true, true, false, false, () => "Freeze gizmo: " + MyCubeBuilder.Static.FreezeGizmo, delegate { MyCubeBuilder.Static.FreezeGizmo = !MyCubeBuilder.Static.FreezeGizmo; return(true); }); AddShortcut(MyKeys.NumPad8, true, false, false, false, () => "Wave to friend", delegate { MySession.LocalCharacter.AddCommand(new MyAnimationCommand() { AnimationSubtypeName = "Wave", Mode = MyPlayAnimationMode.Play, BlendTime = 0.3f, TimeScale = 1, }, true); return(true); }); AddShortcut(MyKeys.NumPad9, true, false, false, false, () => "Dynamics multiplier: " + ((int)SI_DYNAMICS_MULTIPLIER).ToString(), delegate { SI_DYNAMICS_MULTIPLIER *= 10; if (SI_DYNAMICS_MULTIPLIER > 10000) { SI_DYNAMICS_MULTIPLIER = 1; } return(true); }); AddShortcut(MyKeys.NumPad7, true, false, false, false, () => "Use next ship", delegate { MyCharacterInputComponent.UseNextShip(); return(true); }); AddShortcut(MyKeys.NumPad5, true, false, false, false, () => "Insert tree", delegate { InsertTree(); return(true); }); AddShortcut(MyKeys.NumPad6, true, false, false, false, () => "SI Debug draw paths", delegate { MyDebugDrawSettings.ENABLE_DEBUG_DRAW = !MyDebugDrawSettings.ENABLE_DEBUG_DRAW; if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW) { MyStructuralIntegrity.Enabled = true; MyDebugDrawSettings.DEBUG_DRAW_STRUCTURAL_INTEGRITY = true; DEBUG_DRAW_PATHS = true; DEBUG_DRAW_TENSIONS = false; } //foreach (var entity in MyEntities.GetEntities()) //{ // if (entity.GetTopMostParent().Physics != null) // { // var body = entity.GetTopMostParent().Physics; // if (body.RigidBody != null) // { // Vector3 newVel = body.Entity.Physics.LinearVelocity; // float y = newVel.Y; // newVel.Y = -newVel.Z; // newVel.Z = y; // body.RigidBody.ApplyLinearImpulse(newVel * body.Mass * 20); // } // } //} return(true); }); AddShortcut(MyKeys.NumPad1, true, false, false, false, () => "Reorder clusters", delegate { if (MySession.ControlledEntity != null) { MySession.ControlledEntity.Entity.GetTopMostParent().Physics.ReorderClusters(); } return(true); }); AddShortcut(MyKeys.NumPad3, true, false, false, false, () => "SI Debug draw tensions", delegate { MyDebugDrawSettings.ENABLE_DEBUG_DRAW = !MyDebugDrawSettings.ENABLE_DEBUG_DRAW; if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW) { MyStructuralIntegrity.Enabled = true; MyDebugDrawSettings.DEBUG_DRAW_STRUCTURAL_INTEGRITY = true; DEBUG_DRAW_PATHS = false; DEBUG_DRAW_TENSIONS = true; } //foreach (var entity in MyEntities.GetEntities()) //{ // if (entity.GetTopMostParent().Physics != null) // { // var body = entity.GetTopMostParent().Physics; // if (body.RigidBody != null) // { // Vector3 newVel = body.Entity.Physics.LinearVelocity; // float x = newVel.X; // newVel.X = -newVel.X; // newVel.Z = x; // body.RigidBody.ApplyLinearImpulse(newVel * body.Mass * 20); // } // } //} return(true); }); AddShortcut(MyKeys.NumPad4, true, false, false, false, () => "Enable SI destructions: " + ENABLE_SI_DESTRUCTIONS, delegate { ENABLE_SI_DESTRUCTIONS = !ENABLE_SI_DESTRUCTIONS; return(true); }); AddShortcut(MyKeys.Up, true, false, false, false, () => "SI Selected cube up", delegate { MyAdvancedStaticSimulator.SelectedCube = new Vector3I(MyAdvancedStaticSimulator.SelectedCube.X, MyAdvancedStaticSimulator.SelectedCube.Y + 1, MyAdvancedStaticSimulator.SelectedCube.Z); return(true); }); AddShortcut(MyKeys.Down, true, false, false, false, () => "SI Selected cube down", delegate { MyAdvancedStaticSimulator.SelectedCube = new Vector3I(MyAdvancedStaticSimulator.SelectedCube.X, MyAdvancedStaticSimulator.SelectedCube.Y - 1, MyAdvancedStaticSimulator.SelectedCube.Z); return(true); }); AddShortcut(MyKeys.Left, true, false, false, false, () => "SI Selected cube left", delegate { MyAdvancedStaticSimulator.SelectedCube = new Vector3I(MyAdvancedStaticSimulator.SelectedCube.X - 1, MyAdvancedStaticSimulator.SelectedCube.Y, MyAdvancedStaticSimulator.SelectedCube.Z); return(true); }); AddShortcut(MyKeys.Right, true, false, false, false, () => "SI Selected cube right", delegate { MyAdvancedStaticSimulator.SelectedCube = new Vector3I(MyAdvancedStaticSimulator.SelectedCube.X + 1, MyAdvancedStaticSimulator.SelectedCube.Y, MyAdvancedStaticSimulator.SelectedCube.Z); return(true); }); AddShortcut(MyKeys.Up, true, true, false, false, () => "SI Selected cube forward", delegate { MyAdvancedStaticSimulator.SelectedCube = new Vector3I(MyAdvancedStaticSimulator.SelectedCube.X, MyAdvancedStaticSimulator.SelectedCube.Y, MyAdvancedStaticSimulator.SelectedCube.Z - 1); return(true); }); AddShortcut(MyKeys.Down, true, true, false, false, () => "SI Selected cube back", delegate { MyAdvancedStaticSimulator.SelectedCube = new Vector3I(MyAdvancedStaticSimulator.SelectedCube.X, MyAdvancedStaticSimulator.SelectedCube.Y, MyAdvancedStaticSimulator.SelectedCube.Z + 1); return(true); }); AddShortcut(MyKeys.NumPad2, true, false, false, false, () => "Debug draw fractures", delegate { MyDebugDrawSettings.ENABLE_DEBUG_DRAW = true; MyDebugDrawSettings.DEBUG_DRAW_FRACTURED_PIECES = !MyDebugDrawSettings.DEBUG_DRAW_FRACTURED_PIECES; foreach (var entity in MyEntities.GetEntities()) { if (entity is MyFracturedPiece) { foreach (var id in entity.Render.RenderObjectIDs) { VRageRender.MyRenderProxy.UpdateRenderObjectVisibility(id, !MyDebugDrawSettings.DEBUG_DRAW_FRACTURED_PIECES, false); } } } return(true); }); }
public MyTomasInputComponent() { AddShortcut(MyKeys.Delete, true, true, false, false, () => "Delete all characters", delegate { foreach (var obj in MyEntities.GetEntities().OfType <MyCharacter>()) { if (obj == MySession.ControlledEntity) { MySession.SetCameraController(MyCameraControllerEnum.Spectator); } obj.Close(); } foreach (var obj in MyEntities.GetEntities().OfType <MyCubeGrid>()) { foreach (var obj2 in obj.GetBlocks()) { if (obj2.FatBlock is MyCockpit) { var cockpit = obj2.FatBlock as MyCockpit; if (cockpit.Pilot != null) { cockpit.Pilot.Close(); } } } } return(true); }); AddShortcut(MyKeys.NumPad4, true, false, false, false, () => "Spawn cargo ship or barbarians", delegate { var theEvent = MyGlobalEvents.GetEventById(new MyDefinitionId(typeof(MyObjectBuilder_GlobalEventBase), "SpawnCargoShip")); if (theEvent == null) { theEvent = MyGlobalEvents.GetEventById(new MyDefinitionId(typeof(MyObjectBuilder_GlobalEventBase), "SpawnBarbarians")); } if (theEvent != null) { MyGlobalEvents.RemoveGlobalEvent(theEvent); theEvent.SetActivationTime(TimeSpan.FromSeconds(1)); MyGlobalEvents.AddGlobalEvent(theEvent); } return(true); }); AddShortcut(MyKeys.NumPad5, true, false, false, false, () => "Spawn random meteor", delegate { var camera = MySector.MainCamera; var target = camera.Position + MySector.MainCamera.ForwardVector * 20.0f; var spawnPosition = target + MySector.DirectionToSunNormalized * 1000.0f; if (MyUtils.GetRandomFloat(0.0f, 1.0f) < 0.2f) { MyMeteor.SpawnRandomLarge(spawnPosition, -MySector.DirectionToSunNormalized); } else { MyMeteor.SpawnRandomSmall(spawnPosition, -MySector.DirectionToSunNormalized); } return(true); }); AddShortcut(MyKeys.NumPad8, true, false, false, false, () => "Switch control to next entity", delegate { if (MySession.ControlledEntity != null) { //we already are controlling this object var cameraController = MySession.GetCameraControllerEnum(); if (cameraController != MyCameraControllerEnum.Entity && cameraController != MyCameraControllerEnum.ThirdPersonSpectator) { MySession.SetCameraController(MyCameraControllerEnum.Entity, MySession.ControlledEntity.Entity); } else { var entities = MyEntities.GetEntities().ToList(); int lastKnownIndex = entities.IndexOf(MySession.ControlledEntity.Entity); var entitiesList = new List <MyEntity>(); if (lastKnownIndex + 1 < entities.Count) { entitiesList.AddRange(entities.GetRange(lastKnownIndex + 1, entities.Count - lastKnownIndex - 1)); } if (lastKnownIndex != -1) { entitiesList.AddRange(entities.GetRange(0, lastKnownIndex + 1)); } MyCharacter newControlledObject = null; for (int i = 0; i < entitiesList.Count; i++) { var character = entitiesList[i] as MyCharacter; if (character != null) { newControlledObject = character; break; } } if (newControlledObject != null) { MySession.LocalHumanPlayer.Controller.TakeControl(newControlledObject); } } } return(true); }); AddShortcut(MyKeys.NumPad7, true, false, false, false, () => "Use next ship", delegate { MyCharacterInputComponent.UseNextShip(); return(true); }); AddShortcut(MyKeys.NumPad9, true, false, false, false, () => "Debug new grid screen", delegate { MyGuiSandbox.AddScreen(new DebugNewGridScreen()); return(true); }); AddShortcut(MyKeys.N, true, false, false, false, () => "Refill all batteries", delegate { foreach (var entity in MyEntities.GetEntities()) { MyCubeGrid grid = entity as MyCubeGrid; if (grid != null) { foreach (var block in grid.GetBlocks()) { MyBatteryBlock battery = block.FatBlock as MyBatteryBlock; if (battery != null) { battery.CurrentStoredPower = battery.MaxStoredPower; } } } } return(true); }); AddShortcut(MyKeys.U, true, false, false, false, () => "Spawn new character", delegate { var character = MyCharacterInputComponent.SpawnCharacter(); return(true); }); AddShortcut(MyKeys.NumPad2, true, false, false, false, () => "Merge static grids", delegate { // Try to merge all static large grids HashSet <MyCubeGrid> ignoredGrids = new HashSet <MyCubeGrid>(); while (true) { // Flag that we need new entities enumeration bool needNewEntitites = false; foreach (var entity in MyEntities.GetEntities()) { MyCubeGrid grid = entity as MyCubeGrid; if (grid != null && grid.IsStatic && grid.GridSizeEnum == MyCubeSize.Large) { if (ignoredGrids.Contains(grid)) { continue; } List <MySlimBlock> blocks = grid.GetBlocks().ToList(); foreach (var block in blocks) { var mergedGrid = grid.DetectMerge(block); if (mergedGrid == null) { continue; } needNewEntitites = true; // Grid merged to other grid? Then break and loop all entities again. if (mergedGrid != grid) { break; } } if (!needNewEntitites) { ignoredGrids.Add(grid); } } if (needNewEntitites) { break; } } if (!needNewEntitites) { break; } } return(true); }); AddShortcut(MyKeys.Add, true, false, false, false, () => "Increase wheel animation speed", delegate { USE_WHEEL_ANIMATION_SPEED += 0.05f; return(true); }); AddShortcut(MyKeys.Subtract, true, false, false, false, () => "Decrease wheel animation speed", delegate { USE_WHEEL_ANIMATION_SPEED -= 0.05f; return(true); }); AddShortcut(MyKeys.Divide, true, false, false, false, () => "Show model texture names", delegate { MyFakes.ENABLE_DEBUG_DRAW_TEXTURE_NAMES = !MyFakes.ENABLE_DEBUG_DRAW_TEXTURE_NAMES; return(true); }); AddShortcut(MyKeys.NumPad1, true, false, false, false, () => "Throw from spectator: " + Sandbox.Game.Components.MySessionComponentThrower.USE_SPECTATOR_FOR_THROW, delegate { Sandbox.Game.Components.MySessionComponentThrower.USE_SPECTATOR_FOR_THROW = !Sandbox.Game.Components.MySessionComponentThrower.USE_SPECTATOR_FOR_THROW; return(true); }); AddShortcut(MyKeys.F2, true, false, false, false, () => "Spectator to next small grid", () => SpectatorToNextGrid(MyCubeSize.Small)); AddShortcut(MyKeys.F3, true, false, false, false, () => "Spectator to next large grid", () => SpectatorToNextGrid(MyCubeSize.Large)); }