Example #1
0
        public void ApplyAbilityAttributesPatch(AbilityAttributesPatch abilityAttributesPatch, AbilityAttributesWrapper abilityAttributesWrapper)
        {
            applyPropertyPatch(abilityAttributesPatch.AbilityType, () => abilityAttributesWrapper.AbilityType);
            applyPropertyPatch(abilityAttributesPatch.TargetingType, () => abilityAttributesWrapper.TargetingType);
            applyPropertyPatch(abilityAttributesPatch.TargetAlignment, () => abilityAttributesWrapper.TargetAlignment);
            applyPropertyPatch(abilityAttributesPatch.AbilityMapTargetLayers, () => abilityAttributesWrapper.AbilityMapTargetLayers);
            applyPropertyPatch(abilityAttributesPatch.GroundAutoTargetAlignment, () => abilityAttributesWrapper.GroundAutoTargetAlignment);
            applyPropertyPatch(abilityAttributesPatch.EdgeOfTargetShapeMinDistance, () => abilityAttributesWrapper.EdgeOfTargetShapeMinDistance, x => Fixed64.UnsafeFromDouble(x));
            applyPropertyPatch(abilityAttributesPatch.CasterMovesToTarget, () => abilityAttributesWrapper.CasterMovesToTarget);
            applyPropertyPatch(abilityAttributesPatch.GroupActivationType, () => abilityAttributesWrapper.GroupActivationType);
            applyPropertyPatch(abilityAttributesPatch.StartsRemovedInGameMode, () => abilityAttributesWrapper.StartsRemovedInGameMode);
            applyPropertyPatch(abilityAttributesPatch.CooldownTimeSecs, () => abilityAttributesWrapper.CooldownTimeSecs, x => Fixed64.UnsafeFromDouble(x));
            applyPropertyPatch(abilityAttributesPatch.WarmupTimeSecs, () => abilityAttributesWrapper.WarmupTimeSecs, x => Fixed64.UnsafeFromDouble(x));
            applyPropertyPatch(abilityAttributesPatch.SharedCooldownChannel, () => abilityAttributesWrapper.SharedCooldownChannel);
            applyPropertyPatch(abilityAttributesPatch.SkipCastOnArrivalConditions, () => abilityAttributesWrapper.SkipCastOnArrivalConditions);
            applyPropertyPatch(abilityAttributesPatch.IsToggleable, () => abilityAttributesWrapper.IsToggleable);
            applyPropertyPatch(abilityAttributesPatch.CastOnDeath, () => abilityAttributesWrapper.CastOnDeath);

            var cost = new CostAttributesWrapper(abilityAttributesWrapper.Cost);

            abilityAttributesWrapper.Cost = cost;

            applyPropertyPatch(abilityAttributesPatch.Resource1Cost, () => cost.Resource1Cost);
            applyPropertyPatch(abilityAttributesPatch.Resource2Cost, () => cost.Resource2Cost);
        }
Example #2
0
        protected override void Apply(AttributeLoader loader, object wrapperObj)
        {
            if (!(wrapperObj is AbilityAttributesWrapper w))
            {
                throw new System.InvalidCastException();
            }

            if (Resource1Cost != null || Resource2Cost != null || Resource1CostMult != null || Resource2CostMult != null)
            {
                var w2 = new CostAttributesWrapper(w.Cost);

                loader.ApplyPPatch(Resource1Cost, () => w2.Resource1Cost);
                loader.ApplyPMultPatch(Resource1CostMult, () => w2.Resource1Cost);

                loader.ApplyPPatch(Resource2Cost, () => w2.Resource2Cost);
                loader.ApplyPMultPatch(Resource2CostMult, () => w2.Resource2Cost);

                w.Cost = w2;
            }

            loader.ApplyPPatch(EdgeOfTargetShapeMinDistance, () => w.EdgeOfTargetShapeMinDistance, Fixed64.UnsafeFromDouble);
            loader.ApplyPMultPatch(EdgeOfTargetShapeMinDistanceMult, () => w.EdgeOfTargetShapeMinDistance);

            loader.ApplyPPatch(CooldownTimeSecs, () => w.CooldownTimeSecs, Fixed64.UnsafeFromDouble);
            loader.ApplyPMultPatch(CooldownTimeSecsMult, () => w.CooldownTimeSecs);

            loader.ApplyPPatch(WarmupTimeSecs, () => w.WarmupTimeSecs, Fixed64.UnsafeFromDouble);
            loader.ApplyPMultPatch(WarmupTimeSecsMult, () => w.WarmupTimeSecs);

            loader.ApplyPPatch(SharedCooldownChannel, () => w.SharedCooldownChannel);
            loader.ApplyPMultPatch(SharedCooldownChannelMult, () => w.SharedCooldownChannel);

            loader.ApplyPPatch(AbilityType, () => w.AbilityType);
            loader.ApplyPPatch(TargetingType, () => w.TargetingType);
            loader.ApplyPPatch(TargetAlignment, () => w.TargetAlignment);
            loader.ApplyPPatch(AbilityMapTargetLayers, () => w.AbilityMapTargetLayers);
            loader.ApplyPPatch(GroundAutoTargetAlignment, () => w.GroundAutoTargetAlignment);
            loader.ApplyPPatch(CasterMovesToTarget, () => w.CasterMovesToTarget);
            loader.ApplyPPatch(GroupActivationType, () => w.GroupActivationType);
            loader.ApplyPPatch(StartsRemovedInGameMode, () => w.StartsRemovedInGameMode);
            loader.ApplyPPatch(SkipCastOnArrivalConditions, () => w.SkipCastOnArrivalConditions);
            loader.ApplyPPatch(IsToggleable, () => w.IsToggleable);
            loader.ApplyPPatch(CastOnDeath, () => w.CastOnDeath);

            if (TargetHighlighting != null)
            {
                using (loader.logger.BeginScope($"TargetHighlighting:"))
                {
                    var w2 = new TargetHighlightingAttributesWrapper(w.TargetHighlighting);
                    TargetHighlighting.Apply(loader, w2, null);
                    w.TargetHighlighting = w2;
                }
            }
            if (Charges != null)
            {
                using (loader.logger.BeginScope($"Charges:"))
                {
                    var w2 = new ChargeAttributesWrapper(w.Charges);
                    Charges.Apply(loader, w2, null);
                    w.Charges = w2;
                }
            }
            if (Autocast != null)
            {
                using (loader.logger.BeginScope($"Autocast:"))
                {
                    var w2 = new AutocastAttributesWrapper(w.Autocast);
                    Autocast.Apply(loader, w2, null);
                    w.Autocast = w2;
                }
            }
            if (ProduceUnit != null)
            {
                using (loader.logger.BeginScope($"ProduceUnit:"))
                {
                    var w2 = new ProduceUnitAttributesWrapper(w.ProduceUnit);
                    ProduceUnit.Apply(loader, w2, null);
                    w.ProduceUnit = w2;
                }
            }
            if (UseWeapon != null)
            {
                using (loader.logger.BeginScope($"UseWeapon:"))
                {
                    var w2 = new UseWeaponAttributesWrapper(w.UseWeapon);
                    UseWeapon.Apply(loader, w2, null);
                    w.UseWeapon = w2;
                }
            }
            if (ChangeContext != null)
            {
                var w2 = new ChangeContextAttributesWrapper(w.ChangeContext);
                loader.ApplyPPatch(ChangeContext, () => w2.TargetContext);
                w.ChangeContext = w2;
            }
            if (AirSortie != null)
            {
                using (loader.logger.BeginScope($"AirSortie:"))
                {
                    var w2 = new AirSortieAttributesWrapper(w.AirSortie);
                    AirSortie.Apply(loader, w2, null);
                    w.AirSortie = w2;
                }
            }
            if (Salvage != null)
            {
                using (loader.logger.BeginScope($"Salvage:"))
                {
                    var w2 = new SalvageAttributesWrapper(w.Salvage);
                    Salvage.Apply(loader, w2, null);
                    w.Salvage = w2;
                }
            }
            if (ApplyStatusEffect.Count > 0)
            {
                using (loader.logger.BeginScope($"ApplyStatusEffect:"))
                {
                    var w2 = new ApplyStatusEffectAttributesWrapper(w.ApplyStatusEffect);

                    var statusEffectWrappers = w2.StatusEffectsToApply?.Select(x => new StatusEffectAttributesWrapper(x)).ToList() ?? new List <StatusEffectAttributesWrapper>();
                    loader.ApplyNamedLPatch(ApplyStatusEffect, statusEffectWrappers, (x) => new StatusEffectAttributesWrapper(x), nameof(StatusEffectAttributes));
                    w2.StatusEffectsToApply = statusEffectWrappers.ToArray();

                    w.ApplyStatusEffect = w2;
                }
            }
            if (Repair != null)
            {
                var w2 = new RepairAttributesWrapper(w.Repair);
                loader.ApplyPPatch(Repair, () => w2.WeaponID);
                w.Repair = w2;
            }
            if (SelfDestruct != null)
            {
                using (loader.logger.BeginScope($"SelfDestruct:"))
                {
                    var w2 = new SelfDestructAttributesWrapper(w.SelfDestruct);
                    SelfDestruct.Apply(loader, w2, null);
                    w.SelfDestruct = w2;
                }
            }
            if (ModifyInventory != null)
            {
                using (loader.logger.BeginScope($"ModifyInventory:"))
                {
                    var w2 = new ModifyInventoryAttributesWrapper(w.ModifyInventory);
                    ModifyInventory.Apply(loader, w2, null);
                    w.ModifyInventory = w2;
                }
            }
            if (RequiredResearch != null)
            {
                var w2 = new ResearchDependenciesAttributesWrapper(w.ResearchDependencies);
                loader.ApplyArrayPropertyPatch(RequiredResearch, w2, "RequiredResearch");
                w.ResearchDependencies = w2;
            }
            if (ActivationDependencies != null)
            {
                using (loader.logger.BeginScope($"ActivationDependencies:"))
                {
                    var w2 = new ActivationDependenciesAttributesWrapper(w.ActivationDependencies);
                    ActivationDependencies.Apply(loader, w2, null);
                    w.ActivationDependencies = w2;
                }
            }
            if (AutoToggleOffConditions != null)
            {
                using (loader.logger.BeginScope($"AutoToggleOffConditions:"))
                {
                    var w2 = new AutoToggleOffConditionsAttributesWrapper(w.AutoToggleOffConditions);
                    AutoToggleOffConditions.Apply(loader, w2, null);
                    w.AutoToggleOffConditions = w2;
                }
            }
            if (ChainCasting != null)
            {
                using (loader.logger.BeginScope($"ChainCasting:"))
                {
                    var w2 = new ChainCastingAttributesWrapper(w.ChainCasting);
                    ChainCasting.Apply(loader, w2, null);
                    w.ChainCasting = w2;
                }
            }
        }