Пример #1
0
        void Start()
        {
            // Create a dictionary of classic spells
            RebuildClassicSpellsDict();

            // Enumerate classes implementing an effect and create an instance to use as factory
            magicEffectTemplates.Clear();
            IEnumerable <BaseEntityEffect> effectTemplates = ReflectiveEnumerator.GetEnumerableOfType <BaseEntityEffect>();

            foreach (BaseEntityEffect effect in effectTemplates)
            {
                // Effect must present a key and be discoverable via reflective enumeration
                if (string.IsNullOrEmpty(effect.Key) || effect.Properties.DisableReflectiveEnumeration)
                {
                    continue;
                }

                // Register template
                RegisterEffectTemplate(effect);
            }

            // Below is an example of how to register a fully custom effect and spell bundle
            // This call should remain commented out except for testing and example purposes
            // Mods would do this kind of work after capturing OnRegisterCustomEffects event
            RegisterCustomEffectDemo();

            // Raise event for custom effects to register
            RaiseOnRegisterCustomEffectsEvent();
        }
Пример #2
0
        void Start()
        {
            // Enumerate classes implementing an effect and create an instance to use as factory
            // TODO: Provide an external method for mods to register custom effects without reflections
            magicEffectTemplates.Clear();
            IEnumerable <BaseEntityEffect> effectTemplates = ReflectiveEnumerator.GetEnumerableOfType <BaseEntityEffect>();

            foreach (BaseEntityEffect effect in effectTemplates)
            {
                magicEffectTemplates.Add(effect.Key, effect);

                // Link effect to potion recipe lookup if supported
                PotionRecipe recipe = GetEffectPotionRecipe(effect);
                if (recipe != null)
                {
                    // Add potion effect or log error if collision
                    int recipeKey = recipe.GetHashCode();
                    if (!potionEffectTemplates.ContainsKey(recipeKey))
                    {
                        potionEffectTemplates.Add(recipeKey, effect);

                        // TEMP: Output something just to show potion recipe was registered
                        Debug.LogFormat("EnityEffectBroker: Registered effect '{0}' with recipe key '{1}'. Potion ingredients are: {2}", effect.Key, recipeKey, recipe.ToString());
                    }
                    else
                    {
                        Debug.LogErrorFormat("EnityEffectBroker: Already contains potion recipe key {0} for ingredients: {1}", recipeKey, recipe.ToString());
                    }
                }
            }
        }
Пример #3
0
        void Start()
        {
            // Create a dictionary of classic spells
            RebuildClassicSpellsDict();

            // Enumerate classes implementing an effect and create an instance to use as factory
            // TODO: Provide an external method for mods to register custom effects without reflections
            magicEffectTemplates.Clear();
            IEnumerable <BaseEntityEffect> effectTemplates = ReflectiveEnumerator.GetEnumerableOfType <BaseEntityEffect>();

            foreach (BaseEntityEffect effect in effectTemplates)
            {
                // Effect must present a key
                if (string.IsNullOrEmpty(effect.Key))
                {
                    continue;
                }

                // Store template
                // TODO: Allow effect overwrite for modded effects
                if (effect.VariantCount > 1)
                {
                    // Store one template per variant for multi-effects
                    for (int i = 0; i < effect.VariantCount; i++)
                    {
                        BaseEntityEffect variantEffect = CloneEffect(effect) as BaseEntityEffect;
                        variantEffect.CurrentVariant = i;
                        magicEffectTemplates.Add(variantEffect.Key, variantEffect);
                        IndexEffectRecipes(variantEffect);
                    }
                }
                else
                {
                    // Just store singleton effect
                    magicEffectTemplates.Add(effect.Key, effect);
                    IndexEffectRecipes(effect);
                }

                // Map classic key when defined - output error in case of classic key conflict
                // NOTE: Mods should also be able to replace classic effect - will need to handle substitutions later
                // NOTE: Not mapping effect keys for non spell effects at this time
                byte groupIndex, subGroupIndex;
                BaseEntityEffect.ClassicEffectFamily family;
                BaseEntityEffect.ReverseClasicKey(effect.Properties.ClassicKey, out groupIndex, out subGroupIndex, out family);
                if (effect.Properties.ClassicKey != 0 && family == BaseEntityEffect.ClassicEffectFamily.Spells)
                {
                    if (classicEffectMapping.ContainsKey(effect.Properties.ClassicKey))
                    {
                        Debug.LogErrorFormat("EntityEffectBroker: Detected duplicate classic effect key for {0} ({1}, {2})", effect.Key, groupIndex, subGroupIndex);
                    }
                    else
                    {
                        classicEffectMapping.Add(effect.Properties.ClassicKey, effect.Key);
                    }
                }
            }
        }
Пример #4
0
        void Start()
        {
            // Enumerate classes implementing an effect and create an instance to use as factory
            // TODO: Provide an external method for mods to register custom effects without reflections
            magicEffectTemplates.Clear();
            IEnumerable <BaseEntityEffect> effectTemplates = ReflectiveEnumerator.GetEnumerableOfType <BaseEntityEffect>();

            foreach (BaseEntityEffect effect in effectTemplates)
            {
                magicEffectTemplates.Add(effect.Key, effect);
            }
        }
        void Start()
        {
            // Create a dictionary of classic spells
            RebuildClassicSpellsDict();

            // Enumerate classes implementing an effect and create an instance to use as factory
            magicEffectTemplates.Clear();
            IEnumerable <BaseEntityEffect> effectTemplates = ReflectiveEnumerator.GetEnumerableOfType <BaseEntityEffect>();

            foreach (BaseEntityEffect effect in effectTemplates)
            {
                // Effect must present a key
                if (string.IsNullOrEmpty(effect.Key))
                {
                    continue;
                }

                // Register template
                RegisterEffectTemplate(effect);
            }

            // Raise event for custom effects to register
            RaiseOnRegisterCustomEffectsEvent();
        }
 void Start()
 {
     // Test
     IEnumerable <IEntityEffect> magicEffects = ReflectiveEnumerator.GetEnumerableOfType <IEntityEffect>();
 }