// Token: 0x0600000D RID: 13 RVA: 0x00002534 File Offset: 0x00000734 public void RecordPlayer() { InputRecord inputRecord = new InputRecord { Line = this.inputIndex + 1, Frames = this.currentFrame }; Manager.GetCurrentInputs(inputRecord); if (this.currentFrame == 0 && inputRecord == this.Current) { return; } if (inputRecord != this.Current && !Manager.IsLoading()) { this.Current.Frames = this.currentFrame - this.Current.Frames; this.inputIndex++; if (this.Current.Frames != 0) { byte[] bytes = Encoding.ASCII.GetBytes(this.Current.ToString() + "\r\n"); using (FileStream fileStream = new FileStream(this.filePath, (this.inputIndex == 1) ? FileMode.Create : FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite)) { fileStream.Position = fileStream.Length; fileStream.Write(bytes, 0, bytes.Length); fileStream.Close(); } } this.Current = inputRecord; } this.currentFrame++; }
public InputRecord Clone() { InputRecord clone = new InputRecord(Line, Frames.ToString() + ActionsToString()); clone.Command = Command; return(clone); }
public static void SetInputs(InputRecord input) { GamePadDPad pad; GamePadThumbSticks sticks; pad = new GamePadDPad( input.HasActions(Actions.Up) ? ButtonState.Pressed : ButtonState.Released, input.HasActions(Actions.Down) ? ButtonState.Pressed : ButtonState.Released, input.HasActions(Actions.Left) ? ButtonState.Pressed : ButtonState.Released, input.HasActions(Actions.Right) ? ButtonState.Pressed : ButtonState.Released ); sticks = new GamePadThumbSticks(new Vector2(0, 0), new Vector2(0, 0)); GamePadState state = new GamePadState( sticks, new GamePadTriggers(), new GamePadButtons( (input.HasActions(Actions.Jump) ? Buttons.A : 0) | (input.HasActions(Actions.Map) ? Buttons.Y : 0) | (input.HasActions(Actions.Feathers) ? Buttons.B : 0) | (input.HasActions(Actions.Attack) ? Buttons.X : 0) | (input.HasActions(Actions.ToggleRight) ? Buttons.RightShoulder : 0) | (input.HasActions(Actions.Menu) ? Buttons.Start : 0) | (input.HasActions(Actions.ToggleLeft) ? Buttons.LeftShoulder : 0) ), pad ); Input.TasGamepadState = state; }
private static void SetFeather(InputRecord input, ref GamePadDPad pad, ref GamePadThumbSticks sticks) { pad = new GamePadDPad(ButtonState.Released, ButtonState.Released, ButtonState.Released, ButtonState.Released); Vector2 aim = ValidateFeatherInput(input); sticks = new GamePadThumbSticks(aim, new Vector2(0, 0)); }
// Token: 0x0600003B RID: 59 RVA: 0x000035D8 File Offset: 0x000017D8 public static bool GetButton(int button) { InputRecord inputRecord = Manager.controller.Current; switch (button) { case 0: return(inputRecord.HasActions(Actions.Jump)); case 1: return(inputRecord.HasActions(Actions.Goo)); case 2: return(inputRecord.HasActions(Actions.Bouncy)); case 3: return(inputRecord.HasActions(Actions.Water)); case 4: return(inputRecord.HasActions(Actions.Start)); case 5: return(inputRecord.HasActions(Actions.Select)); case 6: return(inputRecord.HasActions(Actions.LeftBumper)); case 7: return(inputRecord.HasActions(Actions.RightBumper)); default: return(false); } }
// Token: 0x0600002C RID: 44 RVA: 0x00002F10 File Offset: 0x00001110 public static int GetAxisDown(string AxisName) { InputRecord inputRecord = Manager.controller.Current; if (AxisName == "Horizontal") { return(-(int)inputRecord.GetXMax()); } if (AxisName == "Vertical") { return(-(int)inputRecord.GetYMax()); } if (AxisName == "DPadX") { return((int)inputRecord.GetXMax()); } if (AxisName == "DPadY") { return((int)inputRecord.GetYMax()); } if (AxisName == "LeftStickX") { return((int)inputRecord.GetXMax()); } if (!(AxisName == "LeftStickY")) { return(0); } return((int)inputRecord.GetYMax()); }
// Token: 0x0600002A RID: 42 RVA: 0x00002E78 File Offset: 0x00001078 public static float GetAxis(string axisName) { InputRecord inputRecord = Manager.controller.Current; if (axisName == "Horizontal") { return(-inputRecord.GetX()); } if (axisName == "Vertical") { return(-inputRecord.GetY()); } if (axisName == "DPadX") { return(inputRecord.GetXMax()); } if (axisName == "DPadY") { return(inputRecord.GetYMax()); } if (axisName == "LeftStickX") { return(inputRecord.GetX()); } if (!(axisName == "LeftStickY")) { return(0f); } return(inputRecord.GetY()); }
// Token: 0x06000031 RID: 49 RVA: 0x00003414 File Offset: 0x00001614 public static void GetCurrentInputs(InputRecord record) { float axisRaw = Input.GetAxisRaw("Horizontal"); if (axisRaw > 0f) { record.Actions |= Actions.Right; } else if (axisRaw < 0f) { record.Actions |= Actions.Left; } if (Input.GetKey(KeyCode.JoystickButton2)) { record.Actions |= Actions.Water; } if (Input.GetKey(KeyCode.JoystickButton0)) { record.Actions |= Actions.Jump; } if (Input.GetKey(KeyCode.JoystickButton7)) { record.Actions |= Actions.Start; } if (Input.GetKey(KeyCode.JoystickButton6)) { record.Actions |= Actions.Select; } }
/* * public void WriteInputs() { * using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)) { * for (int i = 0; i < inputs.Count; i++) { * InputRecord record = inputs[i]; * byte[] data = Encoding.ASCII.GetBytes(record.ToString() + "\r\n"); * fs.Write(data, 0, data.Length); * } * fs.Close(); * } * } */ public bool ReadFile(string filePath = "Celeste.tas", int startLine = 0, int endLine = int.MaxValue, int studioLine = 0) { try { if (filePath == "Celeste.tas" && startLine == 0) { inputs.Clear(); fastForwards.Clear(); if (!File.Exists(filePath)) { return(false); } } int subLine = 0; using (StreamReader sr = new StreamReader(filePath)) { while (!sr.EndOfStream) { string line = sr.ReadLine(); if (filePath == "Celeste.tas") { studioLine++; } subLine++; if (subLine < startLine) { continue; } if (subLine > endLine) { break; } if (InputCommands.TryExecuteCommand(this, line, studioLine)) { return(true); } InputRecord input = new InputRecord(studioLine, line); if (input.FastForward) { fastForwards.Add(input); if (inputs.Count > 0) { inputs[inputs.Count - 1].ForceBreak = input.ForceBreak; inputs[inputs.Count - 1].FastForward = true; } } else if (input.Frames != 0) { inputs.Add(input); } } } return(true); } catch { return(false); } }
public void RecordPlayer() { InputRecord input = new InputRecord() { Line = inputIndex + 1, Frames = currentFrame }; GetCurrentInputs(input); if (currentFrame == 0 && input == Current) { return; } else if (input != Current && !Manager.IsLoading()) { Current.Frames = currentFrame - Current.Frames; inputIndex++; if (Current.Frames != 0) { inputs.Add(Current); } Current = input; } currentFrame++; }
public static bool GetButtonDown(InputGamepadButton button) { if (controller.CurrentInputFrame != 1) { return(false); } InputRecord input = controller.Current; switch (button) { case InputGamepadButton.Action: return(input.HasActions(Actions.Jump)); case InputGamepadButton.Back: return(input.HasActions(Actions.Goo)); case InputGamepadButton.AltAction: return(input.HasActions(Actions.Water)); case InputGamepadButton.Menu: return(input.HasActions(Actions.Bouncy)); case InputGamepadButton.Start: return(input.HasActions(Actions.Start)); case InputGamepadButton.Select: return(input.HasActions(Actions.Select)); case InputGamepadButton.RB: return(input.HasActions(Actions.RightBumper)); case InputGamepadButton.LB: return(input.HasActions(Actions.LeftBumper)); } return(false); }
public bool HasInputReleased(Actions action) { InputRecord current = Current; InputRecord previous = Previous; return(!current.HasActions(action) && previous != null && previous.HasActions(action) && CurrentInputFrame == 1); }
public static bool GetInput(InputType button) { InputRecord input = controller.Current; switch (button) { case InputType.MoveLeft: return(input.HasActions(Actions.Left)); case InputType.MoveRight: return(input.HasActions(Actions.Right)); case InputType.MoveUp: return(input.HasActions(Actions.Up)); case InputType.MoveDown: return(input.HasActions(Actions.Down)); case InputType.Jump: return(input.HasActions(Actions.Jump)); case InputType.Positive: return(input.HasActions(Actions.Positive)); case InputType.Negative: return(input.HasActions(Actions.Negative)); case InputType.Blink: return(input.HasActions(Actions.Blink)); case InputType.SuitPositive: return(input.HasActions(Actions.CloakPositive)); case InputType.SuitNegative: return(input.HasActions(Actions.CloakNegative)); case InputType.Menu: return(input.HasActions(Actions.Start)); case InputType.Map: return(input.HasActions(Actions.Map)); case InputType.Suit: return(input.HasActions(Actions.ToggleCloak)); } return(false); }
public void InitializeRecording() { currentFrame = 0; inputIndex = 0; Current = new InputRecord(); frameToNext = 0; inputs.Clear(); }
// Token: 0x0600000B RID: 11 RVA: 0x000020F0 File Offset: 0x000002F0 public void InitializeRecording() { this.currentFrame = 0; this.inputIndex = 0; this.Current = new InputRecord(); this.frameToNext = 0; this.inputs.Clear(); }
private static void SetDPad(InputRecord input, ref GamePadDPad pad, ref GamePadThumbSticks sticks) { pad = new GamePadDPad( input.HasActions(Actions.Up) ? ButtonState.Pressed : ButtonState.Released, input.HasActions(Actions.Down) ? ButtonState.Pressed : ButtonState.Released, input.HasActions(Actions.Left) ? ButtonState.Pressed : ButtonState.Released, input.HasActions(Actions.Right) ? ButtonState.Pressed : ButtonState.Released ); sticks = new GamePadThumbSticks(new Vector2(0, 0), new Vector2(0, 0)); }
public static void GetCurrentInputs(InputRecord record) { if (TeslagradInput.GetKey(InputType.MoveLeft)) { record.Actions |= Actions.Left; } if (TeslagradInput.GetKey(InputType.MoveRight)) { record.Actions |= Actions.Right; } if (TeslagradInput.GetKey(InputType.MoveUp)) { record.Actions |= Actions.Up; } if (TeslagradInput.GetKey(InputType.MoveDown)) { record.Actions |= Actions.Down; } if (TeslagradInput.GetKey(InputType.Jump)) { record.Actions |= Actions.Jump; } if (TeslagradInput.GetKey(InputType.Positive)) { record.Actions |= Actions.Positive; } if (TeslagradInput.GetKey(InputType.Negative)) { record.Actions |= Actions.Negative; } if (TeslagradInput.GetKey(InputType.Blink)) { record.Actions |= Actions.Blink; } if (TeslagradInput.GetKey(InputType.SuitPositive)) { record.Actions |= Actions.CloakPositive; } if (TeslagradInput.GetKey(InputType.SuitNegative)) { record.Actions |= Actions.CloakNegative; } if (TeslagradInput.GetKey(InputType.Menu)) { record.Actions |= Actions.Start; } if (TeslagradInput.GetKey(InputType.Map)) { record.Actions |= Actions.Map; } if (TeslagradInput.GetKey(InputType.Suit)) { record.Actions |= Actions.ToggleCloak; } }
public static void SetInputs(InputRecord input) { GamePadDPad pad; GamePadThumbSticks sticks; if (input.HasActions(Actions.Feather)) { pad = new GamePadDPad(ButtonState.Released, ButtonState.Released, ButtonState.Released, ButtonState.Released); sticks = new GamePadThumbSticks(new Vector2(input.GetX(), input.GetY()), new Vector2(0, 0)); } else { pad = new GamePadDPad( input.HasActions(Actions.Up) ? ButtonState.Pressed : ButtonState.Released, input.HasActions(Actions.Down) ? ButtonState.Pressed : ButtonState.Released, input.HasActions(Actions.Left) ? ButtonState.Pressed : ButtonState.Released, input.HasActions(Actions.Right) ? ButtonState.Pressed : ButtonState.Released ); sticks = new GamePadThumbSticks(new Vector2(0, 0), new Vector2(0, 0)); } GamePadState state = new GamePadState( sticks, new GamePadTriggers(input.HasActions(Actions.Journal) ? 1f : 0f, 0), new GamePadButtons( (input.HasActions(Actions.Jump) ? Buttons.A : (Buttons)0) | (input.HasActions(Actions.Jump2) ? Buttons.Y : (Buttons)0) | (input.HasActions(Actions.Dash) ? Buttons.B : (Buttons)0) | (input.HasActions(Actions.Dash2) ? Buttons.X : (Buttons)0) | (input.HasActions(Actions.Grab) ? Buttons.RightShoulder : (Buttons)0) | (input.HasActions(Actions.Start) ? Buttons.Start : (Buttons)0) | (input.HasActions(Actions.Restart) ? Buttons.LeftShoulder : (Buttons)0) ), pad ); bool found = false; for (int i = 0; i < 4; i++) { MInput.GamePads[i].Update(); if (MInput.GamePads[i].Attached) { found = true; MInput.GamePads[i].CurrentState = state; } } if (!found) { MInput.GamePads[0].CurrentState = state; MInput.GamePads[0].Attached = true; } MInput.UpdateVirtualInputs(); }
public void WriteInputs() { using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)) { for (int i = 0; i < inputs.Count; i++) { InputRecord record = inputs[i]; byte[] data = Encoding.ASCII.GetBytes(record.ToString() + "\r\n"); fs.Write(data, 0, data.Length); } fs.Close(); } }
// Token: 0x06000009 RID: 9 RVA: 0x00002398 File Offset: 0x00000598 public void InitializePlayback() { this.ReadFile(); this.currentFrame = 0; this.inputIndex = 0; if (this.inputs.Count > 0) { this.Current = this.inputs[0]; this.frameToNext = this.Current.Frames; return; } this.Current = new InputRecord(); this.frameToNext = 1; }
private static void GetCurrentInputs(InputRecord record) { if (Input.Held(Input.Actions.Up)) { record.Actions |= Actions.Up; } if (Input.Held(Input.Actions.Down)) { record.Actions |= Actions.Down; } if (Input.Held(Input.Actions.Left)) { record.Actions |= Actions.Left; } if (Input.Held(Input.Actions.Right)) { record.Actions |= Actions.Right; } if (Input.Held(Input.Actions.Jump)) { record.Actions |= Actions.Jump; } if (Input.Held(Input.Actions.Attack)) { record.Actions |= Actions.Attack; } if (Input.Held(Input.Actions.Feathers)) { record.Actions |= Actions.Feathers; } if (Input.Held(Input.Actions.ToggleLeft)) { record.Actions |= Actions.ToggleLeft; } if (Input.Held(Input.Actions.ToggleRight)) { record.Actions |= Actions.ToggleRight; } if (Input.Held(Input.Actions.Menu)) { record.Actions |= Actions.Menu; } if (Input.Held(Input.Actions.Map)) { record.Actions |= Actions.Map; } }
public void InitializePlayback() { ReadFile(); currentFrame = 0; inputIndex = 0; if (inputs.Count > 0) { Current = inputs[0]; frameToNext = Current.Frames; } else { Current = new InputRecord(); frameToNext = 1; } }
private static void SetState(InputRecord input, ref GamePadState state, ref GamePadDPad pad, ref GamePadThumbSticks sticks) { state = new GamePadState( sticks, new GamePadTriggers(input.HasActions(Actions.Journal) ? 1f : 0f, 0), new GamePadButtons( (input.HasActions(Actions.Jump) ? Buttons.A : 0) | (input.HasActions(Actions.Jump2) ? Buttons.Y : 0) | (input.HasActions(Actions.Dash) ? Buttons.B : 0) | (input.HasActions(Actions.Dash2) ? Buttons.X : 0) | (input.HasActions(Actions.Grab) ? grabButton : 0) | (input.HasActions(Actions.Start) ? Buttons.Start : 0) | (input.HasActions(Actions.Restart) ? Buttons.LeftShoulder : 0) ), pad ); }
private void ReadFile(string extraFile, int lines) { int index = extraFile.IndexOf(','); string filePath = index > 0 ? extraFile.Substring(0, index) : extraFile; int skipLines = 0; if (index > 0) { int.TryParse(extraFile.Substring(index + 1), out skipLines); } if (!File.Exists(filePath)) { return; } int subLine = 0; using (StreamReader sr = new StreamReader(filePath)) { while (!sr.EndOfStream) { string line = sr.ReadLine(); subLine++; if (subLine <= skipLines) { continue; } InputRecord input = new InputRecord(lines, line); if (input.FastForward) { fastForwards.Add(input); if (inputs.Count > 0) { inputs[inputs.Count - 1].FastForward = true; } } else if (input.Frames != 0) { inputs.Add(input); } } } }
public static void SetInputs(InputRecord input) { GamePadDPad pad = default; GamePadThumbSticks sticks = default; GamePadState state = default; if (input.HasActions(Actions.Feather)) { SetFeather(input, ref pad, ref sticks); } else { SetDPad(input, ref pad, ref sticks); } SetState(input, ref state, ref pad, ref sticks); bool found = false; for (int i = 0; i < 4; i++) { MInput.GamePads[i].Update(); if (MInput.GamePads[i].Attached) { found = true; MInput.GamePads[i].CurrentState = state; } } if (!found) { MInput.GamePads[0].CurrentState = state; MInput.GamePads[0].Attached = true; } if (input.HasActions(Actions.Confirm)) { MInput.Keyboard.CurrentState = new KeyboardState(Keys.Enter); } else { MInput.Keyboard.CurrentState = new KeyboardState(); } UpdateVirtualInputs(); }
private bool ReadFile() { try { inputs.Clear(); fastForwards.Clear(); if (!File.Exists(filePath)) { return(false); } int lines = 0; using (StreamReader sr = new StreamReader(filePath)) { while (!sr.EndOfStream) { string line = sr.ReadLine(); if (line.IndexOf("Read", System.StringComparison.OrdinalIgnoreCase) == 0 && line.Length > 5) { lines++; ReadFile(line.Substring(5), lines); lines--; } InputRecord input = new InputRecord(++lines, line); if (input.FastForward) { fastForwards.Add(input); if (inputs.Count > 0) { inputs[inputs.Count - 1].ForceBreak = input.ForceBreak; inputs[inputs.Count - 1].FastForward = true; } } else if (input.Frames != 0) { inputs.Add(input); } } } return(true); } catch { return(false); } }
public void ReloadPlayback() { int playedBackFrames = currentFrame; InitializePlayback(); currentFrame = playedBackFrames; while (currentFrame >= frameToNext) { if (inputIndex + 1 >= inputs.Count) { inputIndex++; return; } Current = inputs[++inputIndex]; frameToNext += Current.Frames; } }
public void PlaybackPlayer() { if (inputIndex < inputs.Count && !Manager.IsLoading()) { if (currentFrame >= frameToNext) { if (inputIndex + 1 >= inputs.Count) { inputIndex++; return; } Current = inputs[++inputIndex]; frameToNext += Current.Frames; } currentFrame++; } }
private static Vector2 ValidateFeatherInput(InputRecord input) { const float maxShort = short.MaxValue; short X; short Y; switch (analogueMode) { case AnalogueMode.Ignore: return(new Vector2(input.GetX(), input.GetY())); case AnalogueMode.Circle: X = (short)(input.GetX() * maxShort); Y = (short)(input.GetY() * maxShort); break; case AnalogueMode.Square: float x = input.GetX(); float y = input.GetY(); float mult = 1 / Math.Max(Math.Abs(x), Math.Abs(y)); x *= mult; y *= mult; X = (short)(x * maxShort); Y = (short)(y * maxShort); break; case AnalogueMode.Precise: if (input.Angle == 0) { X = 0; Y = short.MaxValue; break; } GetPreciseFeatherPos(input.GetX(), input.GetY(), out X, out Y); break; default: throw new Exception("what the f**k"); } // SDL2_FNAPlatform.GetGamePadState() // (float)SDL.SDL_GameControllerGetAxis(intPtr, SDL.SDL_GameControllerAxis.SDL_CONTROLLER_AXIS_LEFTX) / 32767f return(new Vector2((float)X / maxShort, (float)Y / maxShort)); }
private static void GetCurrentInputs(InputRecord record) { if (Input.Jump.Check || Input.MenuConfirm.Check) { record.Actions |= Actions.Jump; } if (Input.Dash.Check || Input.MenuCancel.Check || Input.Talk.Check) { record.Actions |= Actions.Dash; } if (Input.Grab.Check) { record.Actions |= Actions.Grab; } if (Input.MenuJournal.Check) { record.Actions |= Actions.Journal; } if (Input.Pause.Check) { record.Actions |= Actions.Start; } if (Input.QuickRestart.Check) { record.Actions |= Actions.Restart; } if (Input.MenuLeft.Check || Input.MoveX.Value < 0) { record.Actions |= Actions.Left; } if (Input.MenuRight.Check || Input.MoveX.Value > 0) { record.Actions |= Actions.Right; } if (Input.MenuUp.Check || Input.MoveY.Value < 0) { record.Actions |= Actions.Up; } if (Input.MenuDown.Check || Input.MoveY.Value > 0) { record.Actions |= Actions.Down; } }