public static void Write(Player.InputPackage input, ref BinaryWriter writer) { writer.Write(input.x); writer.Write(input.y); writer.Write(input.jmp); writer.Write(input.thrw); writer.Write(input.pckp); writer.Write(input.mp); writer.Write(input.gamePad); writer.Write(input.crouchToggle); Vector2Handler.Write(input.analogueDir, ref writer); writer.Write(input.downDiagonal); }
public static Player.InputPackage Read(Player.InputPackage input, ref BinaryReader reader) { input.x = reader.ReadInt32(); input.y = reader.ReadInt32(); input.jmp = reader.ReadBoolean(); input.thrw = reader.ReadBoolean(); input.pckp = reader.ReadBoolean(); input.mp = reader.ReadBoolean(); input.gamePad = reader.ReadBoolean(); input.crouchToggle = reader.ReadBoolean(); input.analogueDir = Vector2Handler.Read(ref reader); input.downDiagonal = reader.ReadInt32(); return(input); }
static bool CanSing(bool consious, Player.InputPackage input) { // sluggy should only be able to sing if consious and not moving or eating return(consious && !input.pckp && input.x == 0 && input.y == 0 && !input.jmp); }
public void Update(float timeStacker) { if (displaySprite.container != cam.ReturnFContainer("HUD2")) { cam.ReturnFContainer("HUD2").AddChild(displaySprite); } // Create a delegate that gets the current inputs if (_getInputs == null) { Type rwInput = Type.GetType("RWInput, Assembly-CSharp"); _getInputs = (GetRTInputs)Delegate.CreateDelegate(typeof(GetRTInputs), rwInput.GetMethod("PlayerInput", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static)); } // Move the input display when left bracket is pressed if (Input.GetKey(KeyCode.LeftBracket)) { origin = Input.mousePosition; Move(); } // Allow dragging the input display if (_dragging) { if (!Input.GetMouseButton(0)) { _dragging = false; } else { origin = (Vector2)Input.mousePosition + _dragOffset; Move(); } } else { if (Input.GetMouseButtonDown(0) && IsMouseOver) { _dragging = true; _dragOffset = origin - (Vector2)Input.mousePosition; } } // Change the lerp bar to display the current timeStacker _lerpBar.scaleX = timeStacker * _lerpBarWidth; // Cache the inputs at the start of the frame. It is not going to change while the buttons are updating rtInput = _getInputs(0, cam.game.rainWorld.options, cam.game.rainWorld.setup); foreach (InputButton button in buttons) { button.Update(); } // Update the analog input Vector2 aiCenter = new Vector2(DrawOrigin.x + _analogRelPos.x + _analogBoxSize * 0.5f - 0.5f, DrawOrigin.y + _analogRelPos.y + _analogBoxSize * 0.5f - 0.5f); float maxOffset = _analogBoxSize * 0.5f - 4f; _analogIndicator.SetPosition(aiCenter + CurrentInput.analogueDir * maxOffset); _analogRTIndicator.SetPosition(aiCenter + rtInput.analogueDir * maxOffset); _analogRTIndicator.isVisible = !hideRTIndicators; displaySprite.MoveToFront(); offscreenContainer.MoveToFront(); }