Ejemplo n.º 1
0
        void UpdateEffectGenerator(EffectEnvelope s, EffectDef d)
        {
            byte f = (byte)AdvanceEffectEnvelope(s, d);

            if ((f & 1) != 0)
            {
                switch (d.type)
                {
                case 0:
                    _operator2Tl = (byte)(s.startLevel + d.phase);
                    break;

                case 13:
                    _operator1Tl = (byte)(s.startLevel + d.phase);
                    break;

                case 30:
                    d.s.modWheelState = (sbyte)d.phase;
                    break;

                case 31:
                    d.s.modWheelSensitivity = (sbyte)d.phase;
                    break;
                }
            }

            if ((f & 2) != 0)
            {
                if (d.loopRefresh != 0)
                {
                    KeyOn();
                }
            }
        }
Ejemplo n.º 2
0
            static float GetEffectMix(EffectDef effect, float mix, float alpha)
            {
                if (effect != null)
                {
                    if (effect is BiQuadFilterDef bqf && bqf.FilterType == FilterType.Peak)
                    {
                        mix *= BASE_LASER_MIX;
                        if (alpha < 0.2f)
                        {
                            mix *= alpha / 0.2f;
                        }
                        else if (alpha > 0.8f)
                        {
                            mix *= 1 - (alpha - 0.8f) / 0.2f;
                        }
                    }
                    else
                    {
                        // TODO(local): a lot of these (all?) don't need to have special mixes. idk why these got here but they're needed for some reason? fix
                        switch (effect)
                        {
                        case BitCrusherDef _:
                            mix = effect.Mix.Sample(alpha);
                            break;

                        case GateDef _:
                        case RetriggerDef _:
                        case TapeStopDef _:
                            mix = effect.Mix.Sample(alpha);
                            break;

                        case BiQuadFilterDef _: break;
                        }
                    }
                }
Ejemplo n.º 3
0
        public override void EmitEffect(ClientNPC _from, ClientNPC _target, bool _needUpdate = true)
        {
            Target                  = _target;
            Parent                  = _from;
            transform.parent        = Target.transform;
            transform.localPosition = Vector3.zero;
            ClientNpcAnimState cna = Target.animState;

            if (cna == null)
            {
                transform.localPosition = Vector3.up * 2f;
            }
            else
            {
                ed = GetComponent <EffectDef>();
                Transform cm = cna.getModelPart(ed.End);
                if (cm != null)
                {
                    transform.parent        = cm;
                    transform.localPosition = Vector3.up * 0.5f;
                }
                else
                {
                    transform.localPosition = Vector3.up * 2f;
                }
            }
//            transform.parent = Target.transform;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates an EffectDef from a prefab.
        /// The prefab must have an the following components: EffectComponent, VFXAttributes
        /// </summary>
        /// <param name="effect">The prefab of the effect to be added</param>
        /// <returns>The newly created EffectDef</returns>
        public static EffectDef CreateGenericEffectDef(GameObject effect)
        {
            if (!effect)
            {
                LogCore.LogE(string.Format("Effect prefab: \"{0}\" is null", effect.name));

                return(null);
            }

            var effectComp = effect.GetComponent <EffectComponent>();

            if (effectComp == null)
            {
                LogCore.LogE(string.Format("Effect prefab: \"{0}\" does not have an EffectComponent.", effect.name));
                return(null);
            }

            var vfxAttrib = effect.GetComponent <VFXAttributes>();

            if (vfxAttrib == null)
            {
                LogCore.LogE(string.Format("Effect prefab: \"{0}\" does not have a VFXAttributes component.", effect.name));
                return(null);
            }

            var def = new EffectDef
            {
                prefab = effect,
                //cullMethod = new Func<EffectData, bool>()
            };

            return(def);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates an EffectDef from a prefab and adds it to the EffectCatalog.
        /// The prefab must have an the following components: EffectComponent, VFXAttributes
        /// For more control over the EffectDef, use RegisterEffect(EffectDef)
        /// </summary>
        /// <param name="effect">The prefab of the effect to be added</param>
        public static void RegisterGenericEffect(GameObject effect)
        {
            if (!effect)
            {
                LogCore.LogE(string.Format("Effect prefab: \"{0}\" is null", effect.name));
            }

            var effectComp = effect.GetComponent <EffectComponent>();

            if (effectComp == null)
            {
                LogCore.LogE(string.Format("Effect prefab: \"{0}\" does not have an EffectComponent.", effect.name));
            }

            var vfxAttrib = effect.GetComponent <VFXAttributes>();

            if (vfxAttrib == null)
            {
                LogCore.LogE(string.Format("Effect prefab: \"{0}\" does not have a VFXAttributes component.", effect.name));
            }

            var def = new EffectDef
            {
                prefab = effect,
                prefabEffectComponent = effectComp,
                prefabVfxAttributes   = vfxAttrib,
                prefabName            = effect.name,
                spawnSoundEventName   = effectComp.soundName,
                //cullMethod = new Func<EffectData, bool>()
            };

            RegisterEffect(def);
        }
Ejemplo n.º 6
0
        int AdvanceEffectEnvelope(EffectEnvelope s, EffectDef d)
        {
            if (s.duration != 0)
            {
                s.duration -= 17;
                if (s.duration <= 0)
                {
                    s.state = EnvelopeState.Ready;
                    return(0);
                }
            }

            int t = s.currentLevel + s.incrPerStep;

            s.incrCountRem += s.incrPerStepRem;
            if (s.incrCountRem >= s.numSteps)
            {
                s.incrCountRem -= s.numSteps;
                t += s.dir;
            }

            int retFlags = 0;

            if (t != s.currentLevel || (s.modWheelState != s.modWheelLast))
            {
                s.currentLevel = t;
                s.modWheelLast = s.modWheelState;
                t = GetEffectModLevel(t, s.modWheelState);
                if (t != d.phase)
                {
                    d.phase   = t;
                    retFlags |= 1;
                }
            }

            if ((--s.stepCounter) != 0)
            {
                return(retFlags);
            }

            if (++s.state > EnvelopeState.Releasing)
            {
                if (s.loop == 0)
                {
                    s.state = EnvelopeState.Ready;
                    return(retFlags);
                }
                s.state   = EnvelopeState.Attacking;
                retFlags |= 2;
            }

            InitNextEnvelopeState(s);

            return(retFlags);
        }
Ejemplo n.º 7
0
        public void WriteValue(EffectDef effectDef)
        {
            WriteStartStructure();

            WritePropertyName("type");
            WriteValue(EffectDef.GetEffectIdByType(effectDef.GetType()));

            WritePropertiesFromReflection(effectDef);

            WriteEndStructure();
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Adds an EffectDef to the EffectCatalog.
 /// </summary>
 /// <param name="effectDef">The EffectDef to add</param>
 public static void RegisterEffect(EffectDef effectDef)
 {
     //Check if the SurvivorDef has already been registered.
     if (EffectDefDefinitions.Contains(effectDef) || !effectDef.prefab)
     {
         LogCore.LogE(effectDef + " has already been registered to the EffectDef Catalog, please do not register the same EffectDef twice. Or, the EffectDef does not have a prefab.");
         return;
     }
     //If not, add it to our SurvivorDefinitions
     EffectDefDefinitions.Add(effectDef);
 }
Ejemplo n.º 9
0
        public int Add(EffectDef effect)
        {
            int index = m_effects.IndexOf(effect);

            if (index < 0)
            {
                index = m_effects.Count;
                m_effects.Add(effect);
            }
            return(index);
        }
Ejemplo n.º 10
0
        private static void AddNewEffectDef(GameObject effectPrefab, string soundName)
        {
            EffectDef newEffectDef = new EffectDef();

            newEffectDef.prefab = effectPrefab;
            newEffectDef.prefabEffectComponent = effectPrefab.GetComponent <EffectComponent>();
            newEffectDef.prefabName            = effectPrefab.name;
            newEffectDef.prefabVfxAttributes   = effectPrefab.GetComponent <VFXAttributes>();
            newEffectDef.spawnSoundEventName   = soundName;

            effectDefs.Add(newEffectDef);
        }
Ejemplo n.º 11
0
        internal static void EarlyLoad()
        {
            RoR2Content = new RoR2Content();

            RoR2Content.contentPack.identifier = RoR2Content.identifier;

            RoR2Content.contentPack.bodyPrefabs.Add(Resources.LoadAll <GameObject>("Prefabs/CharacterBodies/"));
            RoR2Content.contentPack.masterPrefabs.Add(Resources.LoadAll <GameObject>("Prefabs/CharacterMasters/"));
            RoR2Content.contentPack.projectilePrefabs.Add(Resources.LoadAll <GameObject>("Prefabs/Projectiles/"));
            RoR2Content.contentPack.gameModePrefabs.Add(Resources.LoadAll <GameObject>("Prefabs/GameModes/"));
            RoR2Content.contentPack.networkedObjectPrefabs.Add(Resources.LoadAll <GameObject>("Prefabs/NetworkedObjects/"));
            RoR2Content.contentPack.skillDefs.Add(Resources.LoadAll <SkillDef>("SkillDefs/"));
            RoR2Content.contentPack.skillFamilies.Add(Resources.LoadAll <SkillFamily>("SkillDefs/"));
            RoR2Content.contentPack.unlockableDefs.Add(Resources.LoadAll <UnlockableDef>("UnlockableDefs/"));
            RoR2Content.contentPack.surfaceDefs.Add(Resources.LoadAll <SurfaceDef>("SurfaceDefs/"));
            RoR2Content.contentPack.sceneDefs.Add(Resources.LoadAll <SceneDef>("SceneDefs/"));
            RoR2Content.contentPack.networkSoundEventDefs.Add(Resources.LoadAll <NetworkSoundEventDef>("NetworkSoundEventDefs/"));
            RoR2Content.contentPack.musicTrackDefs.Add(Resources.LoadAll <MusicTrackDef>("MusicTrackDefs/"));
            RoR2Content.contentPack.gameEndingDefs.Add(Resources.LoadAll <GameEndingDef>("GameEndingDefs/"));
            RoR2Content.contentPack.itemDefs.Add(Resources.LoadAll <ItemDef>("ItemDefs/"));
            RoR2Content.contentPack.equipmentDefs.Add(Resources.LoadAll <EquipmentDef>("EquipmentDefs/"));
            RoR2Content.contentPack.buffDefs.Add(Resources.LoadAll <BuffDef>("BuffDefs/"));
            RoR2Content.contentPack.eliteDefs.Add(Resources.LoadAll <EliteDef>("EliteDefs/"));
            RoR2Content.contentPack.survivorDefs.Add(Resources.LoadAll <SurvivorDef>("SurvivorDefs/"));
            RoR2Content.contentPack.artifactDefs.Add(Resources.LoadAll <ArtifactDef>("ArtifactDefs/"));
            var effectDefs = new List <EffectDef>();

            foreach (var effect in Resources.LoadAll <GameObject>("Prefabs/Effects/"))
            {
                var effectDef = new EffectDef(effect);
                effectDefs.Add(effectDef);
            }
            RoR2Content.contentPack.effectDefs.Add(effectDefs.ToArray());
            RoR2Content.contentPack.entityStateConfigurations.Add(Resources.LoadAll <EntityStateConfiguration>("EntityStateConfigurations/"));
            RoR2Content.contentPack.entityStateTypes.Add((from type in typeof(EntityState).Assembly.GetTypes()
                                                          where typeof(EntityState).IsAssignableFrom(type)
                                                          select type).ToArray());

            ContentLoadHelper.PopulateTypeFields <ArtifactDef>(typeof(RoR2Content.Artifacts), RoR2Content.contentPack.artifactDefs);
            ContentLoadHelper.PopulateTypeFields <ItemDef>(typeof(RoR2Content.Items), RoR2Content.contentPack.itemDefs);
            ContentLoadHelper.PopulateTypeFields <EquipmentDef>(typeof(RoR2Content.Equipment), RoR2Content.contentPack.equipmentDefs);
            ContentLoadHelper.PopulateTypeFields <BuffDef>(typeof(RoR2Content.Buffs), RoR2Content.contentPack.buffDefs);
            ContentLoadHelper.PopulateTypeFields <EliteDef>(typeof(RoR2Content.Elites), RoR2Content.contentPack.eliteDefs);
            ContentLoadHelper.PopulateTypeFields <GameEndingDef>(typeof(RoR2Content.GameEndings), RoR2Content.contentPack.gameEndingDefs);
            ContentLoadHelper.PopulateTypeFields <SurvivorDef>(typeof(RoR2Content.Survivors), RoR2Content.contentPack.survivorDefs);

            RoR2Content.contentPack.effectDefs.Find("CoinEmitter").cullMethod = (EffectData effectData) => SettingsConVars.cvExpAndMoneyEffects.value;

            _ror2ContentLoaded = true;
        }
Ejemplo n.º 12
0
    private void ParseGameEffect_SpawnMinionThrow(TextFieldParser parser, EffectDef def)
    {
        Debug.Log("Hey are you parsing SpawnMinonThrow?");
        TagWeights tagWeights = Utils.ParseTagWeights(parser, "Params", true);

        if (tagWeights == null)
        {
            def.worldMethod = GameEffectManager.CreateMethod_LogMessage(LogLevel.Error, "Broken SpawnMinionThrow GameEffect for: " + def.id);
        }
        else
        {
            int    level;
            string tagAndWeight = tagWeights.GetTagAndWeight(0, out level);
            def.worldMethod = CreateMethod_SpawnMinionThrow(tagAndWeight, level, Utils.TryParseFloat(parser, "Radius", null), Utils.TryParseFloat(parser, "Duration", null));
        }
    }
Ejemplo n.º 13
0
        /// <summary>
        /// Adds an EffectDef to the EffectCatalog when the catalog inits.
        /// </summary>
        /// <param name="effect">The EffectDef to addZ</param>
        /// <returns>False if the EffectDef was null</returns>
        public static bool AddEffect(EffectDef effect)
        {
            if (!IsLoaded)
            {
                R2API.Logger.LogError("EffectAPI is not loaded. Please use [R2API.Utils.SubModuleDependency]");
                return(false);
            }
            if (effect == null)
            {
                R2API.Logger.LogError("EffectDef was null.");
                return(false);
            }

            getAdditionalEntries += (list) => list.Add(effect);
            return(true);
        }
Ejemplo n.º 14
0
 private void ParseGameEffect_MaybeSpawnMinions(TextFieldParser parser, EffectDef def)
 {
     // 20% chance to spawn minions?
     if (UnityEngine.Random.Range(0, 100) < 5)
     {
         TagWeights tagWeights = Utils.ParseTagWeights(parser, "Params", true);
         if (tagWeights == null)
         {
             def.worldMethod = GameEffectManager.CreateMethod_LogMessage(LogLevel.Error, "Broken SpawnMinions GameEffect for: " + def.id);
         }
         else
         {
             string tagAndWeight = tagWeights.GetTagAndWeight(0, out int level);
             def.worldMethod = GameEffectManager.CreateMethod_SpawnMinions(tagAndWeight, level, Utils.TryParseFloat(parser, "Radius", null), Utils.TryParseFloat(parser, "Duration", null));
         }
     }
 }
Ejemplo n.º 15
0
        private void SpawnEffect___void_EffectIndex_EffectData_Boolean_Il(ILContext il)
        {
            ILCursor c = new ILCursor(il);

            c.GotoNext(MoveType.Before, x => x.MatchCall(typeof(RoR2.EffectCatalog), "GetEffectDef"));
            c.Remove();
            c.Emit(OpCodes.Ldarg_1);
            c.EmitDelegate <Func <EffectIndex, EffectData, EffectDef> >((index, data) =>
            {
                if (skinnedEffectCache.ContainsKey(index))
                {
                    var cache   = skinnedEffectCache[index];
                    var skinInd = data.genericUInt;
                    if (cache.ContainsKey(skinInd))
                    {
                        return(cache[skinInd]);
                    }
                    else
                    {
                        var origDef        = EffectCatalog.GetEffectDef(index);
                        var skinnedPrefab  = origDef.prefab.ClonePrefab("CachedEffect", false);
                        var skinController = skinnedPrefab.GetComponent <BitSkinController>();
                        skinController.Apply(WispBitSkin.GetWispSkin(skinInd));
                        Destroy(skinController);
                        var newDef = new EffectDef()
                        {
                            cullMethod            = origDef.cullMethod,
                            index                 = index,
                            prefab                = skinnedPrefab,
                            prefabEffectComponent = skinnedPrefab.GetComponent <EffectComponent>(),
                            prefabName            = origDef.prefabName,
                            prefabVfxAttributes   = skinnedPrefab.GetComponent <VFXAttributes>(),
                            spawnSoundEventName   = origDef.spawnSoundEventName
                        };


                        cache[skinInd] = newDef;
                        return(newDef);
                    }
                }
                else
                {
                    return(EffectCatalog.GetEffectDef(index));
                }
            });
        }
Ejemplo n.º 16
0
        public void SetupEffects(int index, byte flags, byte[] effectData, int offset)
        {
            ushort[] effectMaxLevel = { 0x2FF, 0x1F, 0x07, 0x3F, 0x0F, 0x0F, 0x0F, 0x03, 0x3F, 0x0F, 0x0F, 0x0F, 0x03, 0x3E, 0x1F };
            byte[]   effectType     = { 0x1D, 0x1C, 0x1B, 0x00, 0x03, 0x04, 0x07, 0x08, 0x0D, 0x10, 0x11, 0x14, 0x15, 0x1e, 0x1f, 0x00 };

            EffectEnvelope s = _effectEnvelopes[index];
            EffectDef      d = _effectDefs[index];

            d.phase               = 0;
            d.useModWheel         = (byte)(flags & 0x40);
            s.loop                = (byte)(flags & 0x20);
            d.loopRefresh         = (byte)(flags & 0x10);
            d.type                = effectType[flags & 0x0f];
            s.maxLevel            = effectMaxLevel[flags & 0x0f];
            s.modWheelSensitivity = 31;
            s.modWheelState       = (sbyte)((d.useModWheel != 0) ? _in._modWheel >> 2 : 31);

            switch (d.type)
            {
            case 0:
                s.startLevel = _operator2Tl;
                break;

            case 13:
                s.startLevel = _operator1Tl;
                break;

            case 30:
                s.startLevel      = 31;
                d.s.modWheelState = 0;
                break;

            case 31:
                s.startLevel            = 0;
                d.s.modWheelSensitivity = 0;
                break;

            default:
                s.startLevel = GetEffectStartLevel(d.type);
                break;
            }

            StartEffect(s, effectData, offset);
        }
Ejemplo n.º 17
0
        public TownsMidiOutputChannel(MidiDriver_TOWNS driver, int chanIndex)
        {
            _driver = driver;
            _chan   = (byte)chanIndex;

            _effectEnvelopes = new EffectEnvelope[2];
            for (int i = 0; i < _effectEnvelopes.Length; i++)
            {
                _effectEnvelopes[i] = new EffectEnvelope();
            }
            _effectDefs = new EffectDef[2];
            for (int i = 0; i < _effectEnvelopes.Length; i++)
            {
                _effectDefs[i] = new EffectDef();
            }

            _effectDefs[0].s = _effectEnvelopes[1];
            _effectDefs[1].s = _effectEnvelopes[0];
        }
Ejemplo n.º 18
0
        public TownsMidiOutputChannel(MidiDriver_TOWNS driver, int chanIndex)
        {
            _driver = driver;
            _chan = (byte)chanIndex;

            _effectEnvelopes = new EffectEnvelope[2];
            for (int i = 0; i < _effectEnvelopes.Length; i++)
            {
                _effectEnvelopes[i] = new EffectEnvelope();
            }
            _effectDefs = new EffectDef[2];
            for (int i = 0; i < _effectEnvelopes.Length; i++)
            {
                _effectDefs[i] = new EffectDef();
            }

            _effectDefs[0].s = _effectEnvelopes[1];
            _effectDefs[1].s = _effectEnvelopes[0];
        }
Ejemplo n.º 19
0
        public static void AddEffect(EffectDef effect)
        {
            if (!loaded)
            {
                throw new CoreNotLoadedException(nameof(EffectsCore));
            }

            if (effect == null)
            {
                throw new ArgumentNullException("effect");
            }

            if (addedEffectSet.Contains(effect))
            {
                return;
            }

            _ = addedEffectSet.Add(effect);
            addedEffects.Add(effect);
        }
Ejemplo n.º 20
0
        // Gathers all GameObjects with VFXAttributes attached and creates an EffectDef for each one.
        // Without this, the Effect is unable to be spawned.
        // Any VFX elements must have a NetWorkIdentity, VFXAttributes and EffectComponent on the base in order to be usable.
        internal static void CreateEffectDefs()
        {
            List <GameObject> effects = new List <GameObject>();

            GameObject[] assets = mainAssetBundle.LoadAllAssets <GameObject>();
            foreach (GameObject g in assets)
            {
                if (g.GetComponent <EffectComponent>())
                {
                    effects.Add(g);
                }
            }
            foreach (GameObject g in effects)
            {
                EffectDef def = new EffectDef();
                def.prefab = g;

                effectDefs.Add(def);
            }

            mainContentPack.effectDefs.Add(effectDefs.ToArray());
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Creates an EffectDef from a prefab and adds it to the EffectCatalog.
        /// The prefab must have an the following components: EffectComponent, VFXAttributes
        /// For more control over the EffectDef, use AddEffect( EffectDef )
        /// </summary>
        /// <param name="effect">The prefab of the effect to be added</param>
        /// <returns>True if the effect was added</returns>
        public static bool AddEffect(GameObject effect)
        {
            if (!IsLoaded)
            {
                R2API.Logger.LogError("EffectAPI is not loaded. Please use [R2API.Utils.SubModuleDependency]");
                return(false);
            }
            if (effect == null)
            {
                Debug.LogError("Effect prefab was null");
                return(false);
            }

            EffectComponent effectComp = effect.GetComponent <EffectComponent>();

            if (effectComp == null)
            {
                Debug.LogErrorFormat("Effect prefab: \"{0}\" does not have an EffectComponent.", effect.name);
                return(false);
            }

            VFXAttributes vfxAtrib = effect.GetComponent <VFXAttributes>();

            if (vfxAtrib == null)
            {
                Debug.LogErrorFormat("Effect prefab: \"{0}\" does not have a VFXAttributes component.", effect.name);
                return(false);
            }

            EffectDef def = new EffectDef {
                prefab = effect,
                prefabEffectComponent = effectComp,
                prefabVfxAttributes   = vfxAtrib,
                prefabName            = effect.name,
                spawnSoundEventName   = effectComp.soundName
            };

            return(AddEffect(def));
        }
Ejemplo n.º 22
0
        void UpdateEffectGenerator(EffectEnvelope s, EffectDef d)
        {
            byte f = (byte)AdvanceEffectEnvelope(s, d);

            if ((f & 1) != 0)
            {
                switch (d.type)
                {
                    case 0:
                        _operator2Tl = (byte)(s.startLevel + d.phase);
                        break;
                    case 13:
                        _operator1Tl = (byte)(s.startLevel + d.phase);
                        break;
                    case 30:
                        d.s.modWheelState = (sbyte)d.phase;
                        break;
                    case 31:
                        d.s.modWheelSensitivity = (sbyte)d.phase;
                        break;
                }
            }

            if ((f & 2) != 0)
            {
                if (d.loopRefresh != 0)
                    KeyOn();
            }
        }
Ejemplo n.º 23
0
 public override void Init(int id, EffectDef def, UnitView owner)
 {
     base.Init(id, def, owner);
 }
Ejemplo n.º 24
0
 public int IndexOf(EffectDef effect) => m_effects.IndexOf(effect);
 private void ParseGameEffect_WeaponClassism(TextFieldParser parser, EffectDef def)
 {
     def.actorMethod = CreateMethod_WeaponClassism(parser["Params"], Utils.TryParseFloat(parser, "Duration", null));
 }
Ejemplo n.º 26
0
    /*
     * public void LoadParsers(object[] funStuff)
     * {
     *  methodParsers = Utils.GetMethodParsers();
     *  methodParsers["SpawnRandomZeke"] = new Action<TextFieldParser, EffectDef>(this.ParseGameEffect_SpawnRandomZeke);
     *  methodParsers["SpawnMinionThrow"] = new Action<TextFieldParser, EffectDef>(this.ParseGameEffect_SpawnMinionThrow);
     * }*/

    private void ParseGameEffect_SpawnRandomZeke(TextFieldParser parser, EffectDef def)
    {
        Debug.Log("Hey are you parsing SpawnRandomZeke?");
        def.worldMethod = CreateMethod_SpawnRandomZeke();
    }
Ejemplo n.º 27
0
 private void ParseGameEffect_TriggerDash(TextFieldParser parser, EffectDef def)
 {
     def.actorMethod = CreateMethod_TriggerDash(Utils.TryParseFloat(parser, "Radius", null));
 }
 private void ParseGameEffect_WeaponSizeChange(TextFieldParser parser, EffectDef def)
 {
     def.actorMethod = CreateMethod_WeaponSizeChange(Utils.TryParseFloat(parser, "Radius", null), Utils.TryParseFloat(parser, "Duration", null), Utils.ParseStatMods(parser, "Params", false));
 }
Ejemplo n.º 29
0
        int AdvanceEffectEnvelope(EffectEnvelope s, EffectDef d)
        {
            if (s.duration != 0)
            {
                s.duration -= 17;
                if (s.duration <= 0)
                {
                    s.state = EnvelopeState.Ready;
                    return 0;
                }
            }

            int t = s.currentLevel + s.incrPerStep;

            s.incrCountRem += s.incrPerStepRem;
            if (s.incrCountRem >= s.numSteps)
            {
                s.incrCountRem -= s.numSteps;
                t += s.dir;
            }

            int retFlags = 0;

            if (t != s.currentLevel || (s.modWheelState != s.modWheelLast))
            {
                s.currentLevel = t;
                s.modWheelLast = s.modWheelState;
                t = GetEffectModLevel(t, s.modWheelState);
                if (t != d.phase)
                {
                    d.phase = t;
                    retFlags |= 1;
                }
            }

            if ((--s.stepCounter) != 0)
                return retFlags;

            if (++s.state > EnvelopeState.Releasing)
            {
                if (s.loop == 0)
                {
                    s.state = EnvelopeState.Ready;
                    return retFlags;
                }
                s.state = EnvelopeState.Attacking;
                retFlags |= 2;
            }

            InitNextEnvelopeState(s);

            return retFlags;
        }
 private void ParseGameEffect_ShootGems(TextFieldParser parser, EffectDef def)
 {
     def.worldMethod = CreateMethod_ShootGems(parser["Params"], (int)Utils.TryParseFloat(parser, "Radius", null), (int)Utils.TryParseFloat(parser, "Duration", null));
 }
        public void SerializeEffectDef(EffectDef effectDef, BinaryWriter writer)
        {
            var  type   = effectDef.Type;
            byte typeId = (byte)type;

            writer.WriteUInt8(typeId);
            WriteValuesF(effectDef.Mix);

            switch (effectDef)
            {
            case RetriggerEffectDef r: Debug.Assert(type == EffectType.Retrigger);
                {
                    WriteValuesF(r.Gating);
                    WriteValuesF(r.GateDuration);
                } break;

            case FlangerEffectDef l: Debug.Assert(type == EffectType.Flanger);
                {
                    WriteValuesF(l.Delay);
                    WriteValuesI(l.Offset);
                    WriteValuesI(l.Depth);
                } break;

            case PhaserEffectDef ph: Debug.Assert(type == EffectType.Phaser);
                {
                } break;

            case GateEffectDef g: Debug.Assert(type == EffectType.Gate);
                {
                    WriteValuesF(g.Gating);
                    WriteValuesF(g.GateDuration);
                } break;

            case TapeStopEffectDef ts: Debug.Assert(type == EffectType.TapeStop);
                {
                    WriteValuesF(ts.Duration);
                } break;

            case BitCrusherEffectDef bc: Debug.Assert(type == EffectType.BitCrush);
                {
                    WriteValuesF(bc.Reduction);
                } break;

            case WobbleEffectDef w: Debug.Assert(type == EffectType.Wobble);
                {
                    WriteValuesF(w.Period);
                } break;

            case SideChainEffectDef s: Debug.Assert(type == EffectType.SideChain);
                {
                    WriteValuesF(s.Amount);
                    WriteValuesF(s.Duration);
                } break;

            case BiQuadFilterEffectDef bq:
            {
                WriteValuesF(bq.Q);
                WriteValuesF(bq.Gain);
                WriteValuesF(bq.Freq);
            } break;
            }

            void WriteValuesF(EffectParamF p)
            {
                writer.WriteUInt8((byte)(p.IsRange ? 0xFF : 0));
                writer.WriteSingleBE(p.MinValue);
                if (p.IsRange)
                {
                    writer.WriteSingleBE(p.MaxValue);
                }
            }

            void WriteValuesI(EffectParamI p)
            {
                writer.WriteUInt8((byte)(p.IsRange ? 0xFF : 0));
                writer.WriteInt32BE(p.MinValue);
                if (p.IsRange)
                {
                    writer.WriteInt32BE(p.MaxValue);
                }
            }
        }