Exemplo n.º 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.Logger.Error.Log($"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(
                ExtendedDetails.GetOrCreate(Def),
                descriptions.Select(x => x.Full),
                OverrideDescriptionsFeature.settings.BonusDescriptionsElementTemplate,
                OverrideDescriptionsFeature.settings.BonusDescriptionsDescriptionTemplate,
                OverrideDescriptionsFeature.settings.DescriptionIdentifier
                );
        }
Exemplo n.º 2
0
        internal static void AddTemplatedExtendedDetail(
            ExtendedDetails extended,
            IEnumerable <string> elements,
            string elementTemplate,
            string descriptionTemplate,
            string identifier,
            UnitType unityType = UnitType.UNDEFINED)
        {
            var elementsText = string.Join("", elements.Where(x => x != null).Select(x => elementTemplate.Replace("{{element}}", x)).ToArray());
            var text         = descriptionTemplate.Replace("{{elements}}", elementsText);
            var detail       = new ExtendedDetail
            {
                UnitType   = unityType,
                Index      = -1,
                Text       = text,
                Identifier = identifier
            };

            extended.AddDetail(detail);
        }
Exemplo n.º 3
0
        public void OnLoaded(Dictionary <string, object> values)
        {
            var text = Description;

            if (text == null)
            {
                return;
            }

            var extended = ExtendedDetails.GetOrCreate(Def);
            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;
        }
Exemplo n.º 4
0
        private void SetFanArtImage(ExtendedDetails details, Title title)
        {
            if (details.FanArtImages != null)
                return;

            if (title.FanArtPaths == null || title.FanArtPaths.Count == 0)
                return;

            details.FanArtImages = new List<Image>();

            foreach (string path in title.FanArtPaths)
            {
                details.FanArtImages.Add(new Image("file://" + path));
            }

            // set the first image
            details.FanArt = details.FanArtImages[0];
        }
Exemplo n.º 5
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 (LinkedStatisticName != null)
            {
                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(
                ExtendedDetails.GetOrCreate(Def),
                descriptions,
                CriticalEffectsFeature.settings.ElementTemplate,
                descriptionTemplate,
                CriticalEffectsFeature.settings.DescriptionIdentifier,
                GetUnitType()
                );
        }