/// <summary> /// Initializes a new <see cref="InstantiatorBase"/> and sets the DisplayName and DefaultEnabled properties to the specified values /// <para/> /// Note that the DisplayName and DefaultEnabled properties are infact <see cref="ConfigurableValue{T}"/>s, /// <para/> /// only if either of the values is not stored in the configuration will it's value be set to the default value specified in this constructor /// </summary> /// <param name="name"></param> /// <param name="defEnabled"></param> protected InstantiatorBase(string name, bool defEnabled) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } this.name = Config.GetValue <string>(string.Format("{0}Name", name), new StringConverter(), name); this.isEnabled = Config.GetValue <bool>(string.Format("{0}DefaultEnabled", name), new BooleanConverter(), defEnabled); }
internal static IIsolationSemaphore GetFallbackSemaphore(GroupKey key) { if (key == null) { throw new ArgumentNullException("key"); } return(Instance._fallbackSemaphores.GetOrAddSafe(key, k => { // For now, the default here is 5x the default pool threadCount, with the presumption that // several commands may using the same pool, and we should therefore try to allow for a bit // more concurrent fallback execution. var maxConcurrent = new ConfigurableValue <int>("mjolnir.fallback." + key + ".maxConcurrent", 50); return new SemaphoreSlimIsolationSemaphore(key, maxConcurrent, Stats); })); }
public static void Explode(GameObject attacker, Vector3 position, float damage, float radius, bool crit) { if (NetworkServer.active) { EffectManager.SpawnEffect(explosionPrefab, new EffectData { origin = position, scale = radius, rotation = Random.rotation }, true); BlastAttack blastAttack = new BlastAttack { position = position, baseDamage = damage, baseForce = 0f, radius = radius, attacker = attacker, inflictor = null, teamIndex = TeamComponent.GetObjectTeam(attacker), crit = crit, procChainMask = default,
internal static IIsolationSemaphore GetFallbackSemaphore(GroupKey key) { if (key == null) { throw new ArgumentNullException("key"); } return Instance._fallbackSemaphores.GetOrAddSafe(key, k => { // For now, the default here is 5x the default pool threadCount, with the presumption that // several commands may using the same pool, and we should therefore try to allow for a bit // more concurrent fallback execution. var maxConcurrent = new ConfigurableValue<int>("mjolnir.fallback." + key + ".maxConcurrent", DefaultFallbackMaxConcurrent); return new SemaphoreSlimIsolationSemaphore(key, maxConcurrent, Stats); }); }
public override bool OnUse(EquipmentSlot equipmentSlot) { CharacterMaster master = equipmentSlot.characterBody.master; if (master) { ArchaicMaskSummonLimit summonLimit = master.GetComponent <ArchaicMaskSummonLimit>(); if (!summonLimit) { summonLimit = master.gameObject.AddComponent <ArchaicMaskSummonLimit>(); } MysticsRisky2UtilsEquipmentTarget targetInfo = equipmentSlot.GetComponent <MysticsRisky2UtilsEquipmentTarget>(); if (targetInfo && targetInfo.obj) { HurtBox targetHB = targetInfo.obj.GetComponent <CharacterBody>().mainHurtBox; if (targetHB) { DirectorSpawnRequest directorSpawnRequest = new DirectorSpawnRequest((SpawnCard)LegacyResourcesAPI.Load <CharacterSpawnCard>("SpawnCards/CharacterSpawnCards/cscArchWisp"), new DirectorPlacementRule { placementMode = DirectorPlacementRule.PlacementMode.NearestNode, spawnOnTarget = targetHB.transform }, RoR2Application.rng) { summonerBodyObject = equipmentSlot.characterBody.gameObject }; directorSpawnRequest.onSpawnedServer += (spawnResult) => { GameObject wispMasterObject = spawnResult.spawnedInstance; CharacterMaster wispMaster = wispMasterObject.GetComponent <CharacterMaster>(); wispMaster.inventory.GiveItem(RoR2Content.Items.HealthDecay, (int)duration.Value); wispMaster.inventory.GiveItem(RoR2Content.Items.BoostDamage, (int)(wispDamage.Value - 100f) / 10); wispMaster.inventory.GiveItem(RoR2Content.Items.BoostHp, (int)(wispHealth.Value - 100f) / 10); wispMaster.inventory.GiveItem(RoR2Content.Items.AlienHead, (int)(wispCDR.Value - 100f) / 10); wispMaster.inventory.GiveItem(RoR2Content.Items.BoostAttackSpeed, (int)(wispAttackSpeed.Value - 100f) / 10); wispMaster.GetComponent <RoR2.CharacterAI.BaseAI>().currentEnemy.gameObject = targetHB.healthComponent.gameObject; wispMaster.GetComponent <RoR2.CharacterAI.BaseAI>().currentEnemy.bestHurtBox = targetHB; summonLimit.Add(wispMasterObject); }; DirectorCore.instance.TrySpawnObject(directorSpawnRequest); targetInfo.Invalidate(); return(true); } } { DirectorSpawnRequest directorSpawnRequest = new DirectorSpawnRequest((SpawnCard)LegacyResourcesAPI.Load <CharacterSpawnCard>("SpawnCards/CharacterSpawnCards/cscArchWisp"), new DirectorPlacementRule { placementMode = DirectorPlacementRule.PlacementMode.NearestNode, position = equipmentSlot.GetAimRay().origin }, RoR2Application.rng) { summonerBodyObject = equipmentSlot.characterBody.gameObject }; directorSpawnRequest.onSpawnedServer += (spawnResult) => { GameObject wispMasterObject = spawnResult.spawnedInstance; CharacterMaster wispMaster = wispMasterObject.GetComponent <CharacterMaster>(); wispMaster.inventory.GiveItem(RoR2Content.Items.HealthDecay, (int)duration.Value); wispMaster.inventory.GiveItem(RoR2Content.Items.BoostDamage, (int)(wispDamage.Value - 100f) / 10); wispMaster.inventory.GiveItem(RoR2Content.Items.BoostHp, (int)(wispHealth.Value - 100f) / 10); wispMaster.inventory.GiveItem(RoR2Content.Items.AlienHead, (int)(wispCDR.Value - 100f) / 10); wispMaster.inventory.GiveItem(RoR2Content.Items.BoostAttackSpeed, (int)(wispAttackSpeed.Value - 100f) / 10); summonLimit.Add(wispMasterObject); }; DirectorCore.instance.TrySpawnObject(directorSpawnRequest); return(true); } } return(false); }