示例#1
0
    public void Attach(ConditionAttachment attachment)
    {
        foreach (var subDispDef in attachment.condStruct.subDispDefs)
        {
            var     type        = subDispDef.dispType;
            ref var currentList = ref subDispNodes_[(int)type];
            if (currentList == null)
            {
                currentList = new SubDispatcherAttachment[1];
            }
            else
            {
                Array.Resize(ref currentList, currentList.Length + 1);
            }

            currentList[^ 1] = new SubDispatcherAttachment(subDispDef, attachment);
示例#2
0
    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);
            }
        }
    }