Jazz2::Compatibility::EventConverter class

Maps original events to extended event descriptions.

Holds a registry of per-event conversion functions that turn an original JJ2 event ID and its packed parameter integer into the engine's native EventType with unpacked parameters. Default converters are registered on construction and can be extended or overridden.

Public types

using ConversionFunction = Function<ConversionResult(JJ2Level* level, std::uint32_t e)>
Signature of a function that converts a single original event.

Public static functions

static void ConvertParamInt(std::uint32_t paramInt, const ArrayView<const Pair<std::int32_t, std::int32_t>>& paramTypes, std::uint8_t eventParams[16])
Decodes a packed parameter integer into individual event parameters.
static void ConvertParamInt(std::uint32_t paramInt, const std::initializer_list<const Pair<std::int32_t, std::int32_t>> paramTypes, std::uint8_t eventParams[16])

Constructors, destructors, conversion operators

EventConverter()
Creates a new instance.

Public functions

auto TryConvert(JJ2Level* level, JJ2Event old, std::uint32_t eventParams) -> ConversionResult
Converts the specified original event to an extended event description.
void Add(JJ2Event originalEvent, ConversionFunction&& converter)
Registers a converter for the specified original event.
void Override(JJ2Event originalEvent, ConversionFunction&& converter)
Registers a converter for the specified original event, replacing any existing one.
auto NoParamList(EventType ev) -> ConversionFunction
Returns a converter that maps to the specified event with no parameters.
auto ConstantParamList(EventType ev, const std::array<std::uint8_t, 16>& eventParams) -> ConversionFunction
Returns a converter that maps to the specified event with constant parameters.
auto ParamIntToParamList(EventType ev, const std::array<Pair<std::int32_t, std::int32_t>, 6>& paramDefs) -> ConversionFunction
Returns a converter that maps to the specified event by extracting parameters from the original parameter integer.

Function documentation

static void Jazz2::Compatibility::EventConverter::ConvertParamInt(std::uint32_t paramInt, const std::initializer_list<const Pair<std::int32_t, std::int32_t>> paramTypes, std::uint8_t eventParams[16])

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.