Esempio n. 1
0
 /// <summary>
 /// Invokes the delegates registered to run when this synergy is deactivated, passing the player to them.
 /// </summary>
 /// <param name="id">ID of the synergy.</param>
 /// <param name="p">PlayerController to pass on.</param>
 internal static void InvokeSynergyDeactivated(ID id, PlayerController p)
 {
     Logger.Debug($"Synergy deactivated: '{id}'");
     Registry.SynergyStateChangeAction action = null;
     if (SynergyDeactivatedActions.TryGetValue(id, out action))
     {
         action.Invoke(p);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Registers a new synergy.
        /// </summary>
        /// <returns>Newly registered synergy entry.</returns>
        /// <param name="id">ID (including the mod's namespace) for the new item.</param>
        /// <param name="name_loc_id">ID of the localization key for the name of this synergy (StringTable.Synergies).</param>
        /// <param name="objects_required">How many of the listed items and guns are needed to trigger the synergy.</param>
        /// <param name="optional_gun_ids">A list of gun IDs that will count for the synergy, but aren't required to trigger it. DOES NOT SUPPORT CONTEXT IDS.</param>
        /// <param name="mandatory_gun_ids">A list of gun IDs that are required for the synergy to trigger. DOES NOT SUPPORT CONTEXT IDS.</param>
        /// <param name="optional_item_ids">A list of item IDs that will count for the synergy, but aren't required to trigger it. DOES NOT SUPPORT CONTEXT IDS.</param>
        /// <param name="mandatory_item_ids">A list of item IDs that are required for the synergy to trigger. DOES NOT SUPPORT CONTEXT IDS.</param>
        /// <param name="stat_modifiers">A list of stat modifiers to go into effect when the synergy is active.</param>
        /// <param name="active_when_gun_unequipped">Whether the synergy should be active if conditions are met, but none of the mentioned guns are being held.</param>
        /// <param name="ignore_lich_eye_bullets">Whether Lich's Eye Bullets should not attempt to activate this synergy when one of the listed guns is picked up.</param>
        /// <param name="require_at_least_one_gun_and_one_item">Whether the synergy should require both an item and a gun to be picked up to activate the synergy, regardless of whether <code>objects_required</code> is met.</param>
        /// <param name="suppress_vfx">Whether the synergy should avoid triggering the arrow visual effect.</param>
        /// <param name="on_activated">Delegate executed when the synergy becomes active.</param>
        /// <param name="on_deactivated">Delegate executed when the synergy stops being active.</param>
        public AdvancedSynergyEntry RegisterSynergy(ID id, ID name_loc_id, int objects_required, ID[] optional_gun_ids = null, ID[] mandatory_gun_ids = null, ID[] optional_item_ids = null, ID[] mandatory_item_ids = null, List <StatModifier> stat_modifiers = null, bool active_when_gun_unequipped = false, bool ignore_lich_eye_bullets = false, bool require_at_least_one_gun_and_one_item = false, bool suppress_vfx = false, Registry.SynergyStateChangeAction on_activated = null, Registry.SynergyStateChangeAction on_deactivated = null)
        {
            CheckMode();
            id          = GetFullID(id, true);
            name_loc_id = GetFullID(name_loc_id, false);

            var syn = new Patches.AdvancedSynergyEntry {
                ActivationStatus                = SynergyEntry.SynergyActivation.ACTIVE,
                OptionalGuns                    = optional_gun_ids,
                MandatoryGuns                   = mandatory_gun_ids,
                OptionalItems                   = optional_item_ids,
                MandatoryItems                  = mandatory_item_ids,
                NameKey                         = name_loc_id,
                statModifiers                   = stat_modifiers,
                NumberObjectsRequired           = objects_required,
                ActiveWhenGunUnequipped         = active_when_gun_unequipped,
                IgnoreLichEyeBullets            = ignore_lich_eye_bullets,
                RequiresAtLeastOneGunAndOneItem = require_at_least_one_gun_and_one_item,
                SuppressVFX                     = suppress_vfx,
                bonusSynergies                  = new List <CustomSynergyType>(),
                UniqueID                        = id
            };

            //TODO @performance use a working state on this, like collections
            var synergies = new List <AdvancedSynergyEntry>(GameManager.Instance.SynergyManager.synergies);

            synergies.Add(syn);
            GameManager.Instance.SynergyManager.synergies = synergies.ToArray();

            if (on_activated != null)
            {
                Registry.OnSynergyActivated(id, on_activated);
            }
            if (on_deactivated != null)
            {
                Registry.OnSynergyDeactivated(id, on_activated);
            }

            return(syn);
        }