-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged r9212, 9201, 9198, 9193, 9190, 9189 to branches/release
- Loading branch information
Showing
47 changed files
with
1,279 additions
and
432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace BizHawk.Client.Common | ||
{ | ||
public class AutoPatternBool | ||
{ | ||
public bool SkipsLag = true; | ||
private bool[] _pattern; | ||
private int _index; | ||
|
||
/// <summary> | ||
/// Autohold. | ||
/// </summary> | ||
public AutoPatternBool() | ||
{ | ||
SkipsLag = true; | ||
_index = 0; | ||
_pattern = new bool[] { true }; | ||
} | ||
/// <summary> | ||
/// Simple on/off pattern. | ||
/// </summary> | ||
/// <param name="on"></param> | ||
/// <param name="off"></param> | ||
public AutoPatternBool(int on, int off, bool skip_lag = true, int offset = 0) | ||
{ | ||
SkipsLag = skip_lag; | ||
_index = offset; | ||
_pattern = new bool[on + off]; | ||
for (int i = 0; i < on; i++) | ||
_pattern[i] = true; | ||
} | ||
public AutoPatternBool(bool[] pattern, bool skip_lag = true, int offset = 0) | ||
{ | ||
SkipsLag = skip_lag; | ||
_pattern = pattern; | ||
_index = offset; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the next value and increments index. | ||
/// </summary> | ||
/// <returns></returns> | ||
public bool GetNextValue() | ||
{ | ||
bool ret = _pattern[_index]; | ||
_index++; | ||
_index = _index % _pattern.Length; | ||
|
||
return ret; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the next value without incrementing index. | ||
/// </summary> | ||
/// <returns></returns> | ||
public bool PeekNextValue() | ||
{ return _pattern[_index]; } | ||
} | ||
|
||
public class AutoPatternFloat | ||
{ | ||
public bool SkipsLag = true; | ||
private float[] _pattern; | ||
private int _index; | ||
|
||
/// <summary> | ||
/// Defaults to 0. | ||
/// </summary> | ||
public AutoPatternFloat() | ||
{ | ||
SkipsLag = true; | ||
_pattern = new float[] { 0f }; | ||
_index = 0; | ||
} | ||
/// <summary> | ||
/// Sinple on/off pattern, using the given values as on/off. | ||
/// </summary> | ||
public AutoPatternFloat(float valueOn, int on, float valueOff, int off, bool skip_lag = true, int offset = 0) | ||
{ | ||
SkipsLag = skip_lag; | ||
_index = offset; | ||
_pattern = new float[on + off]; | ||
for (int i = 0; i < on; i++) | ||
_pattern[i] = valueOn; | ||
for (int i = on; i < _pattern.Length; i++) | ||
_pattern[i] = valueOff; | ||
} | ||
public AutoPatternFloat(float[] pattern, bool skip_lag = true, int offset = 0) | ||
{ | ||
SkipsLag = skip_lag; | ||
_pattern = pattern; | ||
_index = offset; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the next value and increments index. | ||
/// </summary> | ||
/// <returns></returns> | ||
public float GetNextValue() | ||
{ | ||
float ret = _pattern[_index]; | ||
_index++; | ||
_index = _index % _pattern.Length; | ||
|
||
return ret; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the next value without incrementing index. | ||
/// </summary> | ||
/// <returns></returns> | ||
public float PeekNextValue() | ||
{ return _pattern[_index]; } | ||
} | ||
} |
Oops, something went wrong.