/// <summary> /// Extracts an effect from Buffer, /// </summary> /// <param name="Buffer">Buffer to extract from</param> /// <param name="StartIndex">Index to start reading</param> /// <param name="Length">Bytes to read</param> /// <returns>Typed effect class instance or NULL</returns> public static Effect ExtractEffect(byte[] Buffer, int StartIndex, int Length) { Effect returnValue = null; EffectType effecttype = (EffectType)BitConverter.ToUInt16(Buffer, StartIndex); switch (effecttype) { case EffectType.Invert: // 1 returnValue = new EffectInvert(Buffer, StartIndex); break; case EffectType.Shake: // 2 returnValue = new EffectShake(Buffer, StartIndex); break; case EffectType.Paralyze: // 3 returnValue = new EffectParalyze(Buffer, StartIndex); break; case EffectType.Release: // 4 returnValue = new EffectRelease(Buffer, StartIndex); break; case EffectType.Blind: // 5 returnValue = new EffectBlind(Buffer, StartIndex); break; case EffectType.See: // 6 returnValue = new EffectSee(Buffer, StartIndex); break; case EffectType.Pain: // 7 returnValue = new EffectPain(Buffer, StartIndex); break; case EffectType.Blur: // 8 returnValue = new EffectBlur(Buffer, StartIndex); break; case EffectType.Raining: // 9 returnValue = new EffectRaining(Buffer, StartIndex); break; case EffectType.Snowing: // 10 returnValue = new EffectSnowing(Buffer, StartIndex); break; case EffectType.ClearWeather: // 11 returnValue = new EffectClearWeather(Buffer, StartIndex); break; case EffectType.Sand: // 12 returnValue = new EffectSand(Buffer, StartIndex); break; case EffectType.ClearSand: // 13 returnValue = new EffectClearSand(Buffer, StartIndex); break; case EffectType.Waver: // 14 returnValue = new EffectWaver(Buffer, StartIndex); break; case EffectType.FlashXLat: // 15 returnValue = new EffectFlashXLat(Buffer, StartIndex); break; case EffectType.WhiteOut: // 16 returnValue = new EffectWhiteOut(Buffer, StartIndex); break; case EffectType.XLatOverride: // 17 returnValue = new EffectXLatOverride(Buffer, StartIndex); break; default: returnValue = new EffectGeneric(Buffer, StartIndex, Length); break; } return(returnValue); }
/// <summary> /// Extracts an effect from Buffer, /// </summary> /// <param name="Buffer">Buffer to extract from</param> /// <param name="StartIndex">Index to start reading</param> /// <param name="Length">Bytes to read</param> /// <returns>Typed effect class instance or NULL</returns> public static Effect ExtractEffect(byte[] Buffer, int StartIndex, int Length) { Effect returnValue = null; EffectType effecttype = (EffectType)BitConverter.ToUInt16(Buffer, StartIndex); switch (effecttype) { case EffectType.Invert: // 1 returnValue = new EffectInvert(Buffer, StartIndex); break; case EffectType.Shake: // 2 returnValue = new EffectShake(Buffer, StartIndex); break; case EffectType.Paralyze: // 3 returnValue = new EffectParalyze(Buffer, StartIndex); break; case EffectType.Release: // 4 returnValue = new EffectRelease(Buffer, StartIndex); break; case EffectType.Blind: // 5 returnValue = new EffectBlind(Buffer, StartIndex); break; case EffectType.See: // 6 returnValue = new EffectSee(Buffer, StartIndex); break; case EffectType.Pain: // 7 returnValue = new EffectPain(Buffer, StartIndex); break; case EffectType.Blur: // 8 returnValue = new EffectBlur(Buffer, StartIndex); break; case EffectType.Raining: // 9 returnValue = new EffectRaining(Buffer, StartIndex); break; case EffectType.Snowing: // 10 returnValue = new EffectSnowing(Buffer, StartIndex); break; case EffectType.ClearWeather: // 11 returnValue = new EffectClearWeather(Buffer, StartIndex); break; case EffectType.Sand: // 12 returnValue = new EffectSand(Buffer, StartIndex); break; case EffectType.ClearSand: // 13 returnValue = new EffectClearSand(Buffer, StartIndex); break; case EffectType.Waver: // 14 returnValue = new EffectWaver(Buffer, StartIndex); break; case EffectType.FlashXLat: // 15 returnValue = new EffectFlashXLat(Buffer, StartIndex); break; case EffectType.WhiteOut: // 16 returnValue = new EffectWhiteOut(Buffer, StartIndex); break; case EffectType.XLatOverride: // 17 returnValue = new EffectXLatOverride(Buffer, StartIndex); break; default: returnValue = new EffectGeneric(Buffer, StartIndex, Length); break; } return returnValue; }