using System; namespace GAS.Runtime { [Serializable] public class BeBeatenBackGEComponent : GameplayEffectComponent { public float distance; public float time; public float rate; public override void OnGameplayEffectActive(GameplayEffectComponentSpec partSelf, GameplayEffectSpec GESpec) { var random = RandomSrv.Range(0f, 1f); if (random > rate) { return; } var geSpecOwner = GESpec.Owner; var srcEnt = GESpec.Source.owner; var dstEnt = geSpecOwner.owner; if (!srcEnt.hasBullet) return; var tbBullet = BulletDescMgr.Instance.GetConfig(srcEnt.bullet.bulletCfgId); var notNormalizedDir = tbBullet.shootType == ShootType.Curve ? dstEnt.transformProxy.position - srcEnt.transformProxy.position : srcEnt.transformProxy.direction; var offset = notNormalizedDir.normalized * distance; var gameAbilityParam = new GameplayAbilityParams { param2 = offset.x, param3 = offset.y, param4 = time }; var success = geSpecOwner.TryActivateAbilities_WithTagAndParams(GTagLib.State_ForceMove_BeBeatenBack, gameAbilityParam); } } }