コード例 #1
0
        public void OnLoaded(Dictionary <string, object> values)
        {
            if (Bonuses.Length < 1)
            {
                return;
            }

            foreach (var bonus in Bonuses)
            {
                var split    = bonus.Split(new[] { ':' }, 2);
                var bonusKey = split[0].Trim();

                if (!OverrideDescriptionsFeature.Resources.TryGetValue(bonusKey, out var settings))
                {
                    Control.mod.Logger.LogError($"Could not find bonus description \"{bonusKey}\" used by {Def.Description.Id}");
                    continue;
                }

                var args = split.Length >= 2 ? split[1].Split(',').Select(c => c.Trim()).ToArray() : new string[0];

                var description = new BonusDescription(settings, args);
                descriptions.Add(description);
            }

            {
                var adapter = new MechComponentDefAdapter(Def);
                var count   = 0;
                foreach (var description in descriptions.Select(x => x.Short).Where(x => x != null).Take(2))
                {
                    if (count == 0)
                    {
                        adapter.BonusValueA = description;
                        count++;
                    }
                    else if (count == 1)
                    {
                        adapter.BonusValueB = description;
                    }
                }
            }

            AddTemplatedExtendedDetail(
                Def.GetOrCreate(() => new ExtendedDetails(Def.Description)),
                descriptions.Select(x => x.Full),
                OverrideDescriptionsFeature.settings.BonusDescriptionsElementTemplate,
                OverrideDescriptionsFeature.settings.BonusDescriptionsDescriptionTemplate,
                OverrideDescriptionsFeature.settings.DescriptionIdentifier
                );
        }
コード例 #2
0
        public void OnLoaded(Dictionary <string, object> values)
        {
            var text = Description;

            if (text == null)
            {
                return;
            }

            var extended = Def.GetOrCreate(() => new ExtendedDetails(Def.Description));
            var detail   = new ExtendedDetail
            {
                Index      = -1,
                Text       = Description,
                Identifier = ArmActuatorFeature.Shared.Settings.DescriptionIdentifier
            };

            extended.AddDetail(detail);

            // sync YangsThoughts
            Traverse.Create(Def)
            .Property <string>(nameof(Def.YangsThoughts))
            .Value = Def.Description.Details;
        }
コード例 #3
0
        public void OnLoaded(Dictionary <string, object> values)
        {
            var descriptions = new List <string>();

            string GetEffectDescription(string effectId)
            {
                var effectData = CriticalEffectsFeature.GetEffectData(effectId);

                if (effectData == null || effectData.targetingData.showInStatusPanel == false)
                {
                    return(null);
                }
                return(CriticalEffectsFeature.settings.DescriptionUseName ? effectData.Description.Name : effectData.Description.Details);
            }

            var i = 0;

            foreach (var effectIDs in PenalizedEffectIDs)
            {
                i++;
                foreach (var id in effectIDs)
                {
                    var effectDesc = GetEffectDescription(id);
                    if (effectDesc == null)
                    {
                        continue;
                    }
                    descriptions.Add(new Text(CriticalEffectsFeature.settings.CritHitText, i, effectDesc).ToString());
                }
            }

            foreach (var id in OnDestroyedEffectIDs)
            {
                var effectDesc = GetEffectDescription(id);
                if (effectDesc == null)
                {
                    continue;
                }
                descriptions.Add(new Text(CriticalEffectsFeature.settings.CritDestroyedText, effectDesc).ToString());
            }

            if (DeathMethod != DeathMethod.NOT_SET)
            {
                descriptions.Add(new Text(CriticalEffectsFeature.settings.CritDestroyedDeathText, DeathMethod).ToString());
            }

            if (HasLinked)
            {
                descriptions.Add(new Text(CriticalEffectsFeature.settings.CritLinkedText, LinkedStatisticName).ToString());
            }

            var descriptionTemplate = CriticalEffectsFeature.settings.DescriptionTemplate;

            {
                var actorType = GetUnitType();
                if (actorType != UnitType.UNDEFINED)
                {
                    var actorDescription = actorType.ToString();
                    descriptionTemplate = $"{actorDescription} {descriptionTemplate}";
                }
            }

            BonusDescriptions.AddTemplatedExtendedDetail(
                Def.GetOrCreate(() => new ExtendedDetails(Def.Description)),
                descriptions,
                CriticalEffectsFeature.settings.ElementTemplate,
                descriptionTemplate,
                CriticalEffectsFeature.settings.DescriptionIdentifier,
                GetUnitType()
                );
        }