public void Process(DispatcherType type, D20DispatcherKey key, object dispIo) { if (_dispCounter > DISPATCHER_MAX) { Logger.Error("Dispatcher maximum recursion reached!"); return; } _dispCounter++; foreach (var subDispNode in GetSubDispatcher(type)) { if ((subDispNode.subDispDef.dispKey == key || subDispNode.subDispDef.dispKey == D20DispatcherKey.NONE) && !subDispNode.condNode.IsExpired) { DispIoTypeImmunityTrigger dispIoImmunity = DispIoTypeImmunityTrigger.Default; dispIoImmunity.condNode = subDispNode.condNode; if (type != DispatcherType.ImmunityTrigger || key != D20DispatcherKey.IMMUNITY_SPELL) { Process(DispatcherType.ImmunityTrigger, D20DispatcherKey.IMMUNITY_SPELL, dispIoImmunity); } if (dispIoImmunity.interrupt == 1 && type != DispatcherType.Unused63) { // dispType63 is essentially <. Minor globe of invulnerability dispIoImmunity.interrupt = 0; dispIoImmunity.val2 = 10; Process(DispatcherType.Unused63, D20DispatcherKey.NONE, dispIo); if (dispIoImmunity.interrupt == 0) { var args = new DispatcherCallbackArgs(subDispNode, _owner, type, key, dispIo); subDispNode.subDispDef.callback(in args); } } else { var args = new DispatcherCallbackArgs(subDispNode, _owner, type, key, dispIo); subDispNode.subDispDef.callback(in args); } } } _dispCounter--; }
public static void DispatcherProcessorForItems(ConditionSpec condStruct, Span <int> condArgs, DispatcherType dispType, D20DispatcherKey key, object dispIo) { var condAttachment = new ConditionAttachment(condStruct); for (int i = 0; i < condStruct.numArgs; i++) { condAttachment.args[i] = condArgs[i]; } for (int i = 0; i < condStruct.subDispDefs.Length; i++) { var sdd = condStruct.subDispDefs[i]; if (sdd.dispType == dispType && (sdd.dispKey == key || sdd.dispKey == D20DispatcherKey.NONE)) { var attachment = new SubDispatcherAttachment(); attachment.subDispDef = sdd; attachment.condNode = condAttachment; var callbackArgs = new DispatcherCallbackArgs(attachment, null, dispType, key, dispIo); sdd.callback(in callbackArgs); } } }