Braver/Ficedula.FF7/Util.cs
ficedula 552641c078 Fix up some more battle AI opcodes
Get basic battle AI memory chunk 4 working
Battle action queue basically working
2022-12-10 10:57:27 +00:00

30 lines
859 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ficedula.FF7 {
public class FFException : Exception {
public FFException(string msg) : base(msg) { }
}
public static class Util {
public static T? ValueOrNull<T>(T value, T nullValue) where T : struct {
return value.Equals(nullValue) ? null : value;
}
public static uint BSwap(uint i) {
return (i & 0xff00ff00) | ((i & 0xff) << 16) | ((i >> 16) & 0xff);
}
public static int IndexOf<T>(this IReadOnlyList<T> list, T value) where T : class {
foreach (int i in Enumerable.Range(0, list.Count))
if (list[i] == value)
return i;
return -1;
}
}
}