예제 #1
0
        public static void DecodeNGRealTimer(TriggerTargetType targetType, TriggerType triggerType, ushort target, ushort realTimer, short triggerFlags, out ushort?timer, out ushort?extra)
        {
            switch (triggerType)
            {
            case TriggerType.ConditionNg:
                timer = (ushort)(realTimer & 255);
                var conditionTrigger = NgCatalog.ConditionTrigger.MainList.TryGetOrDefault(timer.Value);
                if (conditionTrigger != null && conditionTrigger.Extra.IsEmpty)
                {
                    extra = null;
                }
                else
                {
                    extra = (ushort)(~(triggerFlags >> 1) & 0x1f);     //   (realTimer >> 8);
                }
                return;

            default:
                switch (targetType)
                {
                case TriggerTargetType.ActionNg:
                    timer = (ushort)(realTimer & 255);
                    var actionTrigger = NgCatalog.ActionTrigger.MainList.TryGetOrDefault(timer.Value);
                    if (actionTrigger != null && actionTrigger.Extra.IsEmpty)
                    {
                        extra = null;
                    }
                    else
                    {
                        extra = (ushort)(realTimer >> 8);
                    }
                    return;

                case TriggerTargetType.TimerfieldNg:
                    timer = realTimer;
                    extra = null;
                    return;

                case TriggerTargetType.FlipEffect:
                    var flipEffectTrigger = NgCatalog.FlipEffectTrigger.MainList.TryGetOrDefault(target);
                    if (flipEffectTrigger != null && flipEffectTrigger.Extra.IsEmpty)
                    {
                        timer = realTimer;
                        extra = null;
                    }
                    else
                    {
                        timer = (ushort)(realTimer & 255);
                        extra = (ushort)(realTimer >> 8);
                    }
                    return;

                default:
                    timer = realTimer;
                    extra = null;
                    return;
                }
            }
        }
예제 #2
0
        public static ushort EncodeNGRealTimer(TriggerTargetType targetType, TriggerType triggerType, ushort target, ushort upperBound, BoundedValueCallback timer, BoundedValueCallback extra)
        {
            ushort timerUpperBound = (ushort)(upperBound & 255);
            ushort extraUpperBound = (ushort)(upperBound >> 8);

            switch (triggerType)
            {
            case TriggerType.ConditionNg:
                // Bit 8 is one shot in trigger setup so we must shift by 9
                return((ushort)(timer(timerUpperBound) | (extra(extraUpperBound) << 9)));

            default:
                switch (targetType)
                {
                case TriggerTargetType.ActionNg:
                    return((ushort)(timer(timerUpperBound) | (extra(extraUpperBound) << 8)));

                case TriggerTargetType.TimerfieldNg:
                    return(timer(upperBound));

                case TriggerTargetType.FlipEffect:
                    NgTriggerSubtype flipEffectSubtriggerType = NgCatalog.FlipEffectTrigger.MainList.TryGetOrDefault(target);
                    if (flipEffectSubtriggerType != null && flipEffectSubtriggerType.Extra.IsEmpty)
                    {
                        return(timer(upperBound));
                    }
                    else
                    {
                        return((ushort)(timer(timerUpperBound) | (extra(extraUpperBound) << 8)));
                    }

                default:
                    return(timer(upperBound));
                }
            }
        }
예제 #3
0
        public static NgParameterRange GetTimerRange(LevelSettings levelSettings, TriggerType triggerType, TriggerTargetType targetType, ITriggerParameter target)
        {
            switch (triggerType)
            {
            case TriggerType.ConditionNg:
                return(new NgParameterRange(NgCatalog.ConditionTrigger.MainList.DicSelect(e => (TriggerParameterUshort)e.Value)));

            default:
                switch (targetType)
                {
                case TriggerTargetType.FlipEffect:
                    if (!(target is TriggerParameterUshort))
                    {
                        return(new NgParameterRange(NgParameterKind.Empty));
                    }
                    NgTriggerSubtype flipEffectSubtriggerType = NgCatalog.FlipEffectTrigger.MainList.TryGetOrDefault(((TriggerParameterUshort)target).Key);
                    return(flipEffectSubtriggerType?.Timer ?? new NgParameterRange(NgParameterKind.Empty));

                case TriggerTargetType.ActionNg:
                    return(new NgParameterRange(NgCatalog.ActionTrigger.MainList.DicSelect(e => (TriggerParameterUshort)e.Value)));

                case TriggerTargetType.TimerfieldNg:
                    return(new NgParameterRange(NgParameterKind.Empty));

                default:
                    return(new NgParameterRange(NgParameterKind.AnyNumber));
                }
            }
        }
예제 #4
0
        public static NgParameterRange GetExtraRange(LevelSettings levelSettings, TriggerType triggerType, TriggerTargetType targetType, ITriggerParameter target, ITriggerParameter timer)
        {
            switch (triggerType)
            {
            case TriggerType.ConditionNg:
                if (!(timer is TriggerParameterUshort))
                {
                    return(new NgParameterRange(NgParameterKind.Empty));
                }
                NgTriggerSubtype conditionSubtriggerType = NgCatalog.ConditionTrigger.MainList.TryGetOrDefault(((TriggerParameterUshort)timer).Key);
                return(conditionSubtriggerType?.Extra ?? new NgParameterRange(NgParameterKind.Empty));

            default:
                switch (targetType)
                {
                case TriggerTargetType.FlipEffect:
                    if (!(target is TriggerParameterUshort))
                    {
                        return(new NgParameterRange(NgParameterKind.Empty));
                    }
                    NgTriggerSubtype flipEffectSubtriggerType = NgCatalog.FlipEffectTrigger.MainList.TryGetOrDefault(((TriggerParameterUshort)target).Key);
                    return(flipEffectSubtriggerType?.Extra ?? new NgParameterRange(NgParameterKind.Empty));

                case TriggerTargetType.ActionNg:
                    if (!(timer is TriggerParameterUshort))
                    {
                        return(new NgParameterRange(NgParameterKind.Empty));
                    }
                    NgTriggerSubtype actionSubtriggerType = NgCatalog.ActionTrigger.MainList.TryGetOrDefault(((TriggerParameterUshort)timer).Key);
                    return(actionSubtriggerType?.Extra ?? new NgParameterRange(NgParameterKind.Empty));

                default:
                    return(new NgParameterRange(NgParameterKind.Empty));
                }
            }
        }
예제 #5
0
        public static NgParameterRange GetTargetRange(LevelSettings levelSettings, TriggerType triggerType, TriggerTargetType targetType, ITriggerParameter timer)
        {
            switch (triggerType)
            {
            case TriggerType.ConditionNg:
                if (!(timer is TriggerParameterUshort))
                {
                    return(new NgParameterRange(NgParameterKind.Empty));
                }
                NgTriggerSubtype conditionSubtriggerType = NgCatalog.ConditionTrigger.MainList.TryGetOrDefault(((TriggerParameterUshort)timer).Key);
                return(conditionSubtriggerType?.Target ?? new NgParameterRange(NgParameterKind.Empty));

            default:
                switch (targetType)
                {
                case TriggerTargetType.Object:
                    return(new NgParameterRange(NgParameterKind.MoveablesInLevel));

                case TriggerTargetType.Camera:
                    return(new NgParameterRange(NgParameterKind.CamerasInLevel));

                case TriggerTargetType.Sink:
                    return(new NgParameterRange(NgParameterKind.SinksInLevel));

                case TriggerTargetType.Target:
                    // Actually it is possible to not only target Target objects, but all movables.
                    // This is also useful: It makes sense to target egg a trap or an enemy.
                    return(new NgParameterRange(NgParameterKind.MoveablesInLevel));

                case TriggerTargetType.FlyByCamera:
                    return(new NgParameterRange(NgParameterKind.FlybyCamerasInLevel));

                case TriggerTargetType.FlipEffect:
                    if (levelSettings.GameVersion == TRVersion.Game.TRNG)
                    {
                        return(new NgParameterRange(NgCatalog.FlipEffectTrigger.MainList.DicSelect(e => (TriggerParameterUshort)e.Value)));
                    }
                    else if (levelSettings.GameVersion == TRVersion.Game.TR4)
                    {
                        return(new NgParameterRange(NgCatalog.FlipEffectTrigger.MainList
                                                    .DicWhere(entry => entry.Value.Name.Contains("OldFlip"))
                                                    .DicSelect(e => (TriggerParameterUshort)e.Value)));
                    }
                    else
                    {
                        return(new NgParameterRange(NgParameterKind.AnyNumber));
                    }

                case TriggerTargetType.ActionNg:
                    if (!(timer is TriggerParameterUshort))
                    {
                        return(new NgParameterRange(NgParameterKind.Empty));
                    }
                    NgTriggerSubtype actionSubtriggerType = NgCatalog.ActionTrigger.MainList.TryGetOrDefault(((TriggerParameterUshort)timer).Key);
                    return(actionSubtriggerType?.Target ?? new NgParameterRange(NgParameterKind.Empty));

                case TriggerTargetType.TimerfieldNg:
                    return(NgCatalog.TimerFieldTrigger);

                default:
                    return(new NgParameterRange(NgParameterKind.AnyNumber));
                }
            }
        }