You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.4 KiB
44 lines
1.4 KiB
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);
|
|
}
|
|
}
|
|
}
|