Exemple #1
0
        protected override void Apply(AttributeLoader loader, object wrapperObj)
        {
            if (!(wrapperObj is UnitMovementAttributesWrapper wrapper))
            {
                throw new System.InvalidCastException();
            }

            loader.ApplyPPatch(DriveType, () => wrapper.DriveType);

            if (Dynamics != null)
            {
                using (loader.logger.BeginScope($"Dynamics:"))
                {
                    var w = new UnitDynamicsAttributesWrapper(wrapper.Dynamics);
                    Dynamics.Apply(loader, w, null);
                    wrapper.Dynamics = w;
                }
            }
            if (RandomDynamicsVariance != null)
            {
                using (loader.logger.BeginScope($"RandomDynamicsVariance:"))
                {
                    var w2 = new UnitDynamicsRandomizationParametersWrapper(wrapper.RandomDynamicsVariance);
                    RandomDynamicsVariance.Apply(loader, w2, null);
                    wrapper.RandomDynamicsVariance = w2;
                }
            }
            if (Maneuvers != null)
            {
                using (loader.logger.BeginScope($"Maneuvers:"))
                {
                    var w2 = new UnitManeuverAttributesWrapper(wrapper.Maneuvers);
                    Maneuvers.Apply(loader, w2, null);
                    wrapper.Maneuvers = w2;
                }
            }
            if (Hover != null)
            {
                using (loader.logger.BeginScope($"Hover:"))
                {
                    var w2 = new HoverDynamicsAttributesWrapper(wrapper.Hover);
                    Hover.Apply(loader, w2, null);
                    wrapper.Hover = w2;
                }
            }
            if (Combat != null)
            {
                using (loader.logger.BeginScope($"Combat:"))
                {
                    var w2 = new UnitCombatBehaviorAttributesWrapper(wrapper.Combat);
                    Combat.Apply(loader, w2, null);
                    wrapper.Combat = w2;
                }
            }
            if (Avoidance != null)
            {
                using (loader.logger.BeginScope($"Avoidance:"))
                {
                    var w2 = new UnitAvoidanceAttributesWrapper(wrapper.Avoidance);
                    Avoidance.Apply(loader, w2, null);
                    wrapper.Avoidance = w2;
                }
            }
            if (ReversePolarity != null)
            {
                using (loader.logger.BeginScope($"ReversePolarity:"))
                {
                    var w2 = new ReversePolarityAttributesWrapper(wrapper.ReversePolarity);
                    ReversePolarity.Apply(loader, w2, null);
                    wrapper.ReversePolarity = w2;
                }
            }
        }