LogError() private method

private LogError ( UnityEngine context, object message ) : void
context UnityEngine
message object
return void
Beispiel #1
0
 public void log(string channel, string msg)
 {
     if (!enable)
     {
         return;
     }
     if (blackList.Contains(channel))
     {
         return;
     }
     if (channel == "Debug")
     {
         UberDebug.Log((string.IsNullOrEmpty(name) ? null : (name + ":")) + msg);
     }
     else if (channel == "Warning")
     {
         UberDebug.LogWarning((string.IsNullOrEmpty(name) ? null : (name + ":")) + msg);
     }
     else if (channel == "Error")
     {
         UberDebug.LogError((string.IsNullOrEmpty(name) ? null : (name + ":")) + msg);
     }
     else
     {
         UberDebug.LogChannel(channel, (string.IsNullOrEmpty(name) ? null : (name + ":")) + msg);
     }
 }
Beispiel #2
0
        public override void RunAction()
        {
            if (this.Target.Unit == null || this.Context.MaybeCaster == null)
            {
                UberDebug.LogError((object)"Target unit is missing", (object[])Array.Empty <object>());
            }
            else
            {
                var dc          = !this.use_custom_dc ? this.Context.Params.DC : custom_dc.Calculate(this.Context);
                var skill_check = this.Context.TriggerRule <RuleSkillCheck>(new RuleSkillCheck(on_caster ? this.Context.MaybeCaster : this.Target.Unit, this.Stat, dc)
                {
                    ShowAnyway = true
                });

                if (skill_check.IsPassed)
                {
                    this.Success.Run();
                }
                else if (!skill_check.IsSuccessRoll(skill_check.D20, 9))
                {
                    this.Failure10.Run();
                }
                else if (!skill_check.IsSuccessRoll(skill_check.D20, 4))
                {
                    this.Failure5.Run();
                }
            }
        }
Beispiel #3
0
        // Similar to `metamagic.DefaultCost()`, but returns the result before Bag of Tricks
        // modifies it to 0.
        public static int OriginalCost(this Metamagic metamagic)
        {
            // Inline this so Bag of Tricks can't mutate it.
            switch (metamagic)
            {
            case Metamagic.Empower:
                return(2);

            case Metamagic.Maximize:
                return(3);

            case Metamagic.Quicken:
                return(4);

            case Metamagic.Extend:
                return(1);

            case Metamagic.Heighten:
                return(0);

            case Metamagic.Reach:
                return(1);
            }
            UberDebug.LogError($"Unknown metamagic: {metamagic}");
            return(0);
        }
        public override void RunAction()
        {
            if (this.Target.Unit == null)
            {
                UberDebug.LogError((UnityEngine.Object) this, (object)"Invalid target for effect '{0}'", (object)this.GetType().Name);
            }
            else if (this.Context.MaybeCaster == null)
            {
                UberDebug.LogError((UnityEngine.Object) this, (object)"Caster is missing", (object[])Array.Empty <object>());
            }
            else
            {
                int bonus = this.Value.Calculate(this.Context);
                int hps   = bonus;
                if (multiply_by_hd)
                {
                    hps = bonus * this.Target.Unit.Descriptor.Progression.CharacterLevel;
                }

                this.Context.TriggerRule <RuleHealDamage>(new RuleHealDamage(this.Context.MaybeCaster, this.Target.Unit, DiceFormula.Zero, hps));

                foreach (var s in stats_to_heal)
                {
                    this.Context.TriggerRule <RuleHealStatDamage>(new RuleHealStatDamage(this.Context.MaybeCaster, this.Target.Unit, s, bonus));
                }
            }
        }
Beispiel #5
0
 public override void RunAction()
 {
     if (this.Target.Unit == null || this.Context.MaybeCaster == null)
     {
         UberDebug.LogError((object)"Target unit is missing", (object[])Array.Empty <object>());
     }
     else
     {
         int value = this.Target.Unit.Ensure <UnitPartSeedStorage>().getRandom(1, 100);
         if (this.Target.Unit.IsInCombat && in_combat_bonus != null)
         {
             value += in_combat_bonus.Calculate(this.Context);
         }
         //Main.logger.Log("Rolled: " + value.ToString());
         Common.AddBattleLogMessage(this.Target.Unit.CharacterName + " rolls " + value.ToString() + " on d100 for " + this.Context.Name);
         for (int i = 0; i < actions.Length; i++)
         {
             if (thresholds[i] >= value)
             {
                 if (actions[i] != null)
                 {
                     actions[i].Run();
                 }
                 return;
             }
         }
     }
 }
        public override void RunAction()
        {
            var unit = this.Target?.Unit;

            if (unit == null)
            {
                UberDebug.LogError("Target is missing");
                return;
            }

            int val = amount.Calculate(this.Context);

            var unit_part_focus = unit.Get <UnitPartImplements>();

            if (unit_part_focus != null && !unit_part_focus.isLocked())
            {
                unit_part_focus.investFocus(school, val);
            }


            if (resource != null)
            {
                unit.Descriptor.Resources.Restore(resource, val);
            }
        }
Beispiel #7
0
        public override IEnumerator <AbilityDeliveryTarget> Deliver(AbilityExecutionContext context, TargetWrapper target)
        {
            UnitEntityData caster = context.MaybeCaster;

            if (caster == null)
            {
                UberDebug.LogError("Caster is missing", Array.Empty <object>());
                yield break;
            }

            RulebookEventContext rulebookContext      = context.RulebookContext;
            RuleAttackWithWeapon attackWithWeapon     = (rulebookContext != null) ? rulebookContext.AllEvents.LastOfType <RuleAttackWithWeapon>() : null;
            RuleAttackWithWeapon ruleAttackWithWeapon = attackWithWeapon;
            RuleAttackRoll       attackRoll           = (ruleAttackWithWeapon != null) ? ruleAttackWithWeapon.AttackRoll : null;

            attackRoll = (attackRoll ?? context.TriggerRule <RuleAttackRoll>(new RuleAttackRoll(caster, target.Unit, caster.GetFirstWeapon(), 0)));
            if (attackWithWeapon == null)
            {
                attackRoll.ConsumeMirrorImageIfNecessary();
            }
            yield return(new AbilityDeliveryTarget(target)
            {
                AttackRoll = attackRoll
            });

            yield break;
        }
        public override void RunAction()
        {
            int            available_units = max_units;
            UnitEntityData unit            = this.Target.Unit;

            if (unit == null)
            {
                UberDebug.LogError((object)"Target is missing", (object[])Array.Empty <object>());
            }
            else
            {
                foreach (var u in unit.CombatState.EngagedBy)
                {
                    if (u == this.Context.MaybeCaster)
                    {
                        continue;
                    }
                    Game.Instance.CombatEngagementController.ForceAttackOfOpportunity(u, unit);
                    available_units--;
                    if (available_units <= 0)
                    {
                        return;
                    }
                }
            }
        }
 public override void RunAction()
 {
     if (this.Context.MaybeCaster == null)
     {
         UberDebug.LogError((object)"Caster unit is missing", (object[])Array.Empty <object>());
     }
     else
     {
         int num = bonus.Calculate(this.Context);
         var rule_skill_check = new RuleSkillCheck(this.Context.MaybeCaster, this.Stat, this.UseCustomDC ? this.CustomDC.Calculate(this.Context) : ((this.Target.Unit?.Descriptor?.Progression.CharacterLevel).GetValueOrDefault() + 10));
         rule_skill_check.ShowAnyway = true;
         if (num != 0)
         {
             rule_skill_check.Bonus.AddModifier(num, null, Kingmaker.Enums.ModifierDescriptor.UntypedStackable);
         }
         if (this.Context.TriggerRule <RuleSkillCheck>(rule_skill_check).IsPassed)
         {
             this.Success.Run();
         }
         else
         {
             this.Failure.Run();
         }
     }
 }
        public override string GetUIText()
        {
            StringBuilder stringBuilder = new StringBuilder();

            if ((UnityEngine.Object) this.evolution == (UnityEngine.Object)null)
            {
                UberDebug.LogError((object)("Empty Feature field in prerequisite component: " + this.name), (object[])Array.Empty <object>());
            }
            else
            {
                if (string.IsNullOrEmpty(this.evolution.Name))
                {
                    UberDebug.LogError((object)string.Format("{0} has no Display Name", (object)this.evolution.name), (object[])Array.Empty <object>());
                }
                stringBuilder.Append(this.evolution.Name);
            }
            if (!not)
            {
                return("Has Personal Evolution: " + stringBuilder.ToString());
            }
            else
            {
                return("No Personal Evolution: " + stringBuilder.ToString());
            }
        }
Beispiel #11
0
        private int DealHitPointsDamage(ContextActionDealDamage2.DamageInfo info)
        {
            if (this.Context.MaybeCaster == null)
            {
                UberDebug.LogError(this, (object)"Caster is missing", (object[])Array.Empty <object>());
                return(0);
            }
            BaseDamage damage1 = this.DamageType.GetDamageDescriptor(info.Dices, info.Bonus).CreateDamage();

            damage1.EmpowerBonus = !info.Empower ? damage1.EmpowerBonus : 1.5f;
            damage1.Maximized    = info.Maximize || damage1.Maximized;
            BaseDamage baseDamage = damage1;
            DamageCriticalModifierType?criticalModifier = info.CriticalModifier;
            int?critModifier = criticalModifier.HasValue ? new int?(criticalModifier.GetValueOrDefault().IntValue()) : new int?();

            baseDamage.CriticalModifier = critModifier;
            damage1.Half           = this.Half;
            damage1.AlreadyHalved  = info.PreRolledValue.HasValue && this.Half && this.AlreadyHalved;
            damage1.PreRolledValue = info.PreRolledValue;
            if (this.IsAoE && !info.PreRolledValue.HasValue)
            {
                int?nullable2 = this.Context.AoEDamage.Get <ContextActionDealDamage, int?>(this, new int?());
                if (nullable2.HasValue)
                {
                    damage1.PreRolledValue = nullable2;
                }
            }
            ContextAttackData data    = ElementsContext.GetData <ContextAttackData>();
            DamageBundle      damage2 = (DamageBundle)damage1;

            damage2.Weapon = data?.AttackRoll?.Weapon;
            RuleDealDamage rule = new RuleDealDamage(this.Context.MaybeCaster, this.Target.Unit, damage2)
            {
                Projectile             = data?.Projectile,
                AttackRoll             = data?.AttackRoll,
                HalfBecauseSavingThrow = info.HalfBecauseSavingThrow,
                MinHPAfterDamage       = !this.UseMinHPAfterDamage ? new int?() : new int?(this.MinHPAfterDamage),
                SourceAbility          = this.Context.SourceAbility,
                SourceArea             = this.Context.AssociatedBlueprint as BlueprintAbilityAreaEffect
            };

            if (this.IsShadowEvocation)
            {
                RuleSavingThrow ruleSavingThrow = this.Context.TriggerRule(new RuleSavingThrow(this.Target.Unit, SavingThrowType.Will, this.Context.Params.DC));
                rule.ReducedBecauseOfShadowEvocation = ruleSavingThrow.IsPassed;
            }
            if (this.IsShadowEvocationGreater)
            {
                RuleSavingThrow ruleSavingThrow = this.Context.TriggerRule(new RuleSavingThrow(this.Target.Unit, SavingThrowType.Will, this.Context.Params.DC));
                rule.ReducedBecauseOfShadowEvocationGreater = ruleSavingThrow.IsPassed;
            }
            this.Context.TriggerRule <RuleDealDamage>(rule);
            if (this.IsAoE && !this.Context.AoEDamage.Get <ContextActionDealDamage, int?>(this, new int?()).HasValue)
            {
                this.Context.AoEDamage[this] = new int?(rule.Calculate.CalculatedDamage.FirstItem <DamageValue>().RolledValue);
            }
            return(rule.Damage);
        }
        public override void RunAction()
        {
            MechanicsContext           context     = ElementsContext.GetData <MechanicsContext.Data>()?.Context;
            EnchantPoolDataDescription description = new EnchantPoolDataDescription();

            if (context == null)
            {
                UberDebug.LogError((UnityEngine.Object) this, (object)"Unable to apply buff: no context found", (object[])Array.Empty <object>());
            }
            else
            {
                Rounds         rounds      = this.DurationValue.Calculate(context);
                UnitEntityData maybeCaster = context.MaybeCaster;
                if (maybeCaster == null)
                {
                    UberDebug.LogError((UnityEngine.Object) this, (object)"Can't apply buff: target is null", (object[])Array.Empty <object>());
                }
                else
                {
                    maybeCaster.Ensure <UnitPartEnchantPoolData>().ClearEnchantPool(this.EnchantPool);
                    ItemEntity itemEntity = maybeCaster.Body.PrimaryHand.HasWeapon ? (ItemEntity)maybeCaster.Body.PrimaryHand.MaybeWeapon : (ItemEntity)maybeCaster.Body.EmptyHandWeapon;
                    if (itemEntity == null)
                    {
                        return;
                    }
                    int num1      = 0;
                    int groupSize = maybeCaster.Descriptor.Progression.Features.GetRank(Feature);
                    description.EnchantedItem = itemEntity;
                    description.EnchantPool   = this.EnchantPool;
                    if (itemEntity.Enchantments.Any <ItemEnchantment>())
                    {
                        foreach (WeaponEnhancementBonus enhancementBonus in itemEntity.Enchantments.SelectMany <ItemEnchantment, WeaponEnhancementBonus>((Func <ItemEnchantment, IEnumerable <WeaponEnhancementBonus> >)(e => e.SelectComponents <WeaponEnhancementBonus>())))
                        {
                            num1 += enhancementBonus.EnhancementBonus;
                        }
                    }

                    foreach (AddBondProperty selectFactComponent in maybeCaster.Buffs.SelectFactComponents <AddBondProperty>())
                    {
                        if (selectFactComponent.EnchantPool == this.EnchantPool && !itemEntity.HasEnchantment(selectFactComponent.Enchant))
                        {
                            groupSize -= selectFactComponent.Enchant.EnchantmentCost;
                            description.Enchantments.Add(itemEntity.AddEnchantment(selectFactComponent.Enchant, context, new Rounds?(rounds)));
                        }
                    }

                    int num2 = Math.Min(Math.Max(0, 5 - num1), groupSize);
                    if (num2 > 0)
                    {
                        description.Enchantments.Add(itemEntity.AddEnchantment(this.DefaultEnchantments[num2 - 1], context, new Rounds?(rounds)));
                    }
                    maybeCaster.Ensure <UnitPartEnchantPoolData>().RecordEnchantPool(description);
                }
            }
        }
Beispiel #13
0
        public void mod_FoundSettlement(RegionSettlementLocation settlementLocation, string name = null)
        {
            if (!KingmakerPatchSettings.CurrencyFallback.Enabled)
            {
                this.source_FoundSettlement(settlementLocation, name);
                return;
            }

            if (!this.Blueprint.SettlementBuildArea)
            {
                UberDebug.LogError("Cannot found a settlement in {0}: no building area set up", settlementLocation);
                return;
            }

            if (this.Settlement != null)
            {
                UberDebug.LogError("Cannot found a settlement in {0}: already built", settlementLocation);
                return;
            }

            if (settlementLocation != null && settlementLocation.AssociatedLocation == null)
            {
                UberDebug.LogError("Cannot found a settlement in {0}: no globalmap location associated", settlementLocation);
                return;
            }

            if (settlementLocation == null && this.Blueprint.SettlementGlobalmapLocations.Length == 0)
            {
                UberDebug.LogError("Cannot found a settlement in {0}: no location specified and no default found", this.Blueprint);
                return;
            }

            KingdomCurrencyFallback.SpendPoints(KingdomRoot.Instance.SettlementBPCost);

            var settlementState = new SettlementState(SettlementState.LevelType.Village)
            {
                Region = this
            };

            SettlementState settlementState2 = settlementState;

            settlementState2.HasWaterSlot = settlementLocation?.HasWaterSlot == true;

            settlementState.Name = name ?? this.Blueprint.DefaultSettlementName;

            settlementState.Location = settlementLocation?.AssociatedLocation ?? this.Blueprint.SettlementGlobalmapLocations.FirstOrDefault();

            settlementState.SettlementLocation = settlementLocation;

            this.Settlement = settlementState;

            this.SetSettlementUIMarkers();

            EventBus.RaiseEvent((ISettlementFoundingHandler h) => h.OnSettlementFounded(this.Settlement));
        }
Beispiel #14
0
        public override void RunAction()
        {
            var caster = Context.MaybeCaster;

            if (caster == null)
            {
                UberDebug.LogError("Caster is missing");
                return;
            }
            caster.Descriptor.Resources.Restore(Resource, 1);
        }
Beispiel #15
0
        protected override bool CheckCondition()
        {
            UnitEntityData unit = this.check_caster ? this.Context.MaybeCaster : this.Target.Unit;

            if (unit == null)
            {
                UberDebug.LogError((object)"Target is missing", (object[])Array.Empty <object>());
                return(false);
            }
            return(unit.Stats.GetStat <ModifiableValueSkill>(skill).BaseValue >= value);
        }
        private static void LoadPacks()
        {
            var currentPacks = new List <LocalizationPack>();

            var directoryInfo = new DirectoryInfo(Path.Combine(Application.dataPath, "Mods", "Localization/" + alias_s_CurrentLocale));

            FileInfo[] files;

            try
            {
                files = directoryInfo.GetFiles("*.json", SearchOption.AllDirectories);
            }
            catch (DirectoryNotFoundException ex)
            {
                UberDebug.LogError("Failed to load localization packs in: {0}", directoryInfo.FullName);
                UberDebug.LogException(ex);
                return;
            }

            foreach (FileInfo file in files.Where(file => file.Exists))
            {
                try
                {
                    using (var streamReader = new StreamReader(file.FullName))
                    {
                        currentPacks.Add(JsonConvert.DeserializeObject <LocalizationPack>(streamReader.ReadToEnd()));
                    }
                }
                catch (Exception ex)
                {
                    UberDebug.LogError("Failed to load localization pack: {0}", file.FullName);
                    UberDebug.LogException(ex);
                }
            }

            if (CurrentPack == null)
            {
                return;
            }

            foreach (LocalizationPack currentPack in currentPacks)
            {
                foreach (KeyValuePair <string, string> keyValuePair in currentPack.Strings)
                {
                    if (CurrentPack.Strings.ContainsKey(keyValuePair.Key) == true)
                    {
                        CurrentPack.Strings.Remove(keyValuePair.Key);
                    }

                    CurrentPack.Strings.Add(keyValuePair.Key, keyValuePair.Value);
                }
            }
        }
        public override void RunAction()
        {
            UnitEntityData caster = this.Context.MaybeCaster;

            if (caster == null)
            {
                UberDebug.LogError((UnityEngine.Object) this, (object)"Caster is missing", (object[])Array.Empty <object>());
            }
            var unit = this.Target.Unit;

            if (unit == null || !unit.Descriptor.State.IsDead || unit.Descriptor.State.HasCondition(UnitCondition.Petrified))
            {
                return;
            }

            var            blueprint       = unit.Blueprint;
            Rounds         duration        = this.DurationValue.Calculate(this.Context);
            Vector3        clampedPosition = ObstacleAnalyzer.GetNearestNode(this.Target.Point).clampedPosition;
            UnitEntityView unitEntityView  = blueprint.Prefab.Load(false);

            var target_size = unit.Descriptor.OriginalSize;

            float radius = !((UnityEngine.Object)unitEntityView != (UnityEngine.Object)null) ? 0.5f : unitEntityView.Corpulence;

            FreePlaceSelector.PlaceSpawnPlaces(1, radius, clampedPosition);

            Vector3        relaxedPosition = FreePlaceSelector.GetRelaxedPosition(0, true);
            UnitEntityData animated_unit   = this.Context.TriggerRule <RuleSummonUnit>(new RuleSummonUnit(caster, blueprint, relaxedPosition, duration, 0)
            {
                Context           = this.Context,
                DoNotLinkToCaster = this.do_not_link_to_caster
            }).SummonedUnit;

            if (this.SummonPool != null)
            {
                GameHelper.RegisterUnitInSummonPool(this.SummonPool, animated_unit);
            }

            var level_up_component = animated_unit.Blueprint.GetComponent <AddClassLevels>();

            int current_level = level_up_component.Levels;

            animated_unit.Descriptor.State.AddCondition(UnitCondition.Unlootable, (Kingmaker.UnitLogic.Buffs.Buff)null);

            using (this.Context.GetDataScope(animated_unit))
            {
                this.AfterSpawn.Run();
            }

            unit.Descriptor.AddFact(Common.no_animate_feature);
        }
        public override void RunAction()
        {
            var unit = this.Target?.Unit;

            if (unit == null)
            {
                UberDebug.LogError("Target is missing");
                return;
            }

            int amount = getRemainingGroupSize(unit.Descriptor);

            unit.Descriptor.Resources.Restore(resource, amount);
        }
 public override void RunAction()
 {
     if (this.Target.Unit == null)
     {
         UberDebug.LogError((UnityEngine.Object) this, (object)"Invalid target for effect '{0}'", (object)this.GetType().Name);
     }
     else if (this.Context.MaybeCaster == null)
     {
         UberDebug.LogError((UnityEngine.Object) this, (object)"Caster is missing", (object[])Array.Empty <object>());
     }
     else
     {
         int bonus = this.Value.Calculate(this.Context);
         this.Context.TriggerRule <RuleHealDamage>(new RuleHealDamage(this.Context.MaybeCaster, this.Target.Unit, DiceFormula.Zero, bonus));
     }
 }
Beispiel #20
0
 private int DealAbilityScoreDamage(ContextActionDealDamage2.DamageInfo info)
 {
     if (this.Context.MaybeCaster == null)
     {
         UberDebug.LogError(this, (object)"Caster is missing", (object[])Array.Empty <object>());
         return(0);
     }
     return(this.Context.TriggerRule(new RuleDealStatDamage(this.Context.MaybeCaster, this.Target.Unit, this.AbilityType, info.Dices, info.Bonus)
     {
         Empower = info.Empower,
         Maximize = info.Maximize,
         CriticalModifier = info.CriticalModifier,
         IsDrain = this.Drain,
         HalfBecauseSavingThrow = info.HalfBecauseSavingThrow
     }).Damage);
 }
        public static Buff mod_ApplyBuff(UnitEntityData target, BlueprintBuff buff, Rounds?duration = null)
        {
            if (target == null)
            {
                UberDebug.LogError("target == null, returning null without calling target.Descriptor.AddBuff");
                return(null);
            }

            if (buff == null)
            {
                UberDebug.LogError("buff == null, returning null without calling target.Descriptor.AddBuff");
                return(null);
            }

            return(source_ApplyBuff(target, buff, duration));
        }
Beispiel #22
0
        public override void OnTurnOff()
        {
            Main.logger.Log("AddSacredWordBonus OnTurnOff");
            MechanicsContext           context     = ElementsContext.GetData <MechanicsContext.Data>()?.Context;
            EnchantPoolDataDescription description = new EnchantPoolDataDescription();

            if (context == null)
            {
                UberDebug.LogError((UnityEngine.Object) this, (object)"Unable to apply buff: no context found", (object[])Array.Empty <object>());
            }
            else
            {
                UnitEntityData maybeCaster = context.MaybeCaster;
                maybeCaster.Remove <UnitPartEnchantPoolData>();
            }
        }
        public override void RunAction()
        {
            UnitEntityData maybeCaster = this.Context.MaybeCaster;

            if (maybeCaster == null)
            {
                UberDebug.LogError((UnityEngine.Object) this, (object)"Caster is missing", (object[])Array.Empty <object>());
            }
            else
            {
                Rounds         duration        = this.DurationValue.Calculate(this.Context);
                int            count           = this.CountValue.Calculate(this.Context);
                int            level           = this.LevelValue.Calculate(this.Context);
                Vector3        clampedPosition = ObstacleAnalyzer.GetNearestNode(this.Target.Point).clampedPosition;
                UnitEntityView unitEntityView  = this.Blueprint.Prefab.Load(false);
                float          radius          = (UnityEngine.Object)unitEntityView != (UnityEngine.Object)null ? unitEntityView.Corpulence : 0.5f;
                FreePlaceSelector.PlaceSpawnPlaces(count, radius, clampedPosition);
                for (int index = 0; index < count; ++index)
                {
                    Vector3        relaxedPosition = FreePlaceSelector.GetRelaxedPosition(index, true);
                    UnitEntityData summonedUnit    = this.Context.TriggerRule <RuleSummonUnit>(new RuleSummonUnit(maybeCaster, this.Blueprint, relaxedPosition, duration, level)
                    {
                        Context           = this.Context,
                        DoNotLinkToCaster = this.DoNotLinkToCaster
                    }).SummonedUnit;
                    var weapon = getWeapon();
                    if (weapon != null)
                    {
                        ItemsCollection.DoWithoutEvents((Action)(() => summonedUnit.Body.PrimaryHand.InsertItem(weapon.CreateEntity())));
                    }

                    if (attack_mark_buff != null)
                    {
                        summonedUnit.Ensure <UnitPartSpiritualWeaponTargetMark>().buff = attack_mark_buff;
                    }
                    if ((UnityEngine.Object) this.SummonPool != (UnityEngine.Object)null)
                    {
                        GameHelper.RegisterUnitInSummonPool(this.SummonPool, summonedUnit);
                    }
                    using (this.Context.GetDataScope((TargetWrapper)summonedUnit))
                        this.AfterSpawn.Run();

                    summonedUnit.Descriptor.CustomName = custom_name;
                    EventBus.RaiseEvent <IUnitNameHandler>((Action <IUnitNameHandler>)(h => h.OnUnitNameChanged(summonedUnit)));
                }
            }
        }
Beispiel #24
0
 public override void RunAction()
 {
     if (this.Target.Unit == null)
     {
         UberDebug.LogError((object)"Target unit is missing", (object[])Array.Empty <object>());
     }
     else
     {
         if (tryBreakFree(this.Target.Unit, this.Context.MaybeCaster, this.Context))
         {
             this.Success.Run();
         }
         else
         {
             this.Failure.Run();
         }
     }
 }
        public override void RunAction()
        {
            MechanicsContext context = ElementsContext.GetData <MechanicsContext.Data>()?.Context;

            if (context == null)
            {
                UberDebug.LogError((UnityEngine.Object) this, (object)"Unable to apply buff: no context found", (object[])Array.Empty <object>());
            }
            else
            {
                UnitEntityData caster = context.MaybeCaster;
                UnitEntityData target = this.Target.Unit;

                if (caster != null && target != null)
                {
                    caster.Descriptor.Ensure <UnitPartStudiedTarget>().SetTarget(target.Descriptor);
                }
            }
        }
        public override void RunAction()
        {
            var unit = this.Target?.Unit;

            if (unit == null)
            {
                UberDebug.LogError("Target is missing");
                return;
            }

            var unit_part_focus = unit.Get <UnitPartImplements>();

            if (unit_part_focus == null || !unit_part_focus.isLocked())
            {
                return;
            }

            unit_part_focus.unlockFocus();
        }
        public override void RunAction()
        {
            var unit = this.Target?.Unit;

            if (unit == null)
            {
                UberDebug.LogError("Target is missing");
                return;
            }

            if (!full)
            {
                unit.Descriptor.Resources.Restore(Resource, amount.Calculate(this.Context));
            }
            else
            {
                unit.Descriptor.Resources.Restore(Resource);
            }
        }
        public override void RunAction()
        {
            UnitEntityData maybeCaster = base.Context.MaybeCaster;

            if (maybeCaster == null)
            {
                UberDebug.LogError(this, "Caster is missing", Array.Empty <object>());
                return;
            }
            Vector3 vector = base.Target.Point;

            vector += new Vector3(-3, 0, -2);
            vector  = ObstacleAnalyzer.GetNearestNode(vector).clampedPosition;
            UnitEntityView unitEntityView = this.Blueprint.Prefab.Load(false);
            float          radius         = (unitEntityView != null) ? unitEntityView.Corpulence : 0.5f;

            FreePlaceSelector.PlaceSpawnPlaces(3, radius, vector);
            Game.Instance.EntityCreator.SpawnUnit(this.Blueprint, vector, Quaternion.identity, maybeCaster.HoldingState);
        }
 private void checkDeckValid(int[] deck)
 {
     if (deck == null)
     {
         return;
     }
     if (game.getCardDefine(deck[0]) == null)
     {
         UberDebug.LogError("非法角色ID" + deck[0] + "被替换为灵梦");
         deck[0] = game.getCardDefine <Reimu>().id;
     }
     for (int i = 1; i < deck.Length; i++)
     {
         if (game.getCardDefine(deck[i]) == null)
         {
             UberDebug.LogError("非法随从ID" + deck[i] + "被替换为小野菊");
             deck[i] = game.getCardDefine <RashFairy>().id;
         }
     }
 }
Beispiel #30
0
        private int DrainEnergy(ContextActionDealDamage2.DamageInfo info)
        {
            if (this.Context.MaybeCaster == null)
            {
                UberDebug.LogError(this, (object)"Caster is missing", (object[])Array.Empty <object>());
                return(0);
            }
            RuleDrainEnergy rule = new RuleDrainEnergy(this.Context.MaybeCaster, this.Target.Unit, this.EnergyDrainType, this.EnergyDrainType == EnergyDrainType.Permanent ? new TimeSpan?() : new TimeSpan?(this.Duration.Calculate(this.Context).Seconds), new DiceFormula(this.Value.DiceCountValue.Calculate(this.Context), this.Value.DiceType), this.Value.BonusValue.Calculate(this.Context));

            rule.CriticalModifier = info.CriticalModifier;
            rule.Empower          = info.Empower;
            rule.Maximize         = info.Maximize;
            rule.ParentContext    = this.Context;
            RuleDrainEnergy ruleDrainEnergy = rule;
            SavingThrowType?type            = this.Context.SavingThrow?.Type;
            int             num             = !type.HasValue ? 1 : (int)type.Value;

            ruleDrainEnergy.SavingThrowType = (SavingThrowType)num;
            return(this.Context.TriggerRule <RuleDrainEnergy>(rule).Count);
        }