示例#1
0
        internal static bool ProcessLocationalEffectData(ref EffectData effect, MechComponent mechComponent)
        {
            if (effect.effectType == EffectType.StatisticEffect &&
                LocationNaming.IsLocational(effect.Description.Id) &&
                LocationNaming.Create(mechComponent, out var naming))
            {
                var data = effect.ToJSON();
                effect = new EffectData();
                effect.FromJSON(data);

                Control.mod.Logger.LogDebug($"Replacing location in {effect.Description.Id} with {naming.LocationId}");

                effect.statisticData.statName = naming.InterpolateStatisticName(effect.statisticData.statName);

                effect.Description = new BaseDescriptionDef(
                    naming.InterpolateEffectId(effect.Description.Id),
                    naming.InterpolateText(effect.Description.Name),
                    naming.InterpolateText(effect.Description.Details),
                    naming.InterpolateText(effect.Description.Icon)
                    );

                return(true);
            }

            return(false);
        }
示例#2
0
        internal static bool Create(MechComponent mechComponent, out LocationNaming naming)
        {
            if (mechComponent.parent is Mech)
            {
                naming = new MechLocationNaming(mechComponent.mechComponentRef.MountedLocation);
                return(true);
            }

            if (mechComponent.parent is Vehicle)
            {
                naming = new VehicleLocationNaming(mechComponent.vehicleComponentRef.MountedLocation);
                return(true);
            }

            naming = null;
            return(false);
        }