public void PrepareTargeting(TargetingEvent evt, BulletTargetingNode barelTargetingNode) { TargetingData targetingData = evt.TargetingData; BulletTargetingComponent bulletTargeting = barelTargetingNode.bulletTargeting; CollectDirection(targetingData.Origin, targetingData.Dir, 0f, targetingData); Vector3 normalized = Vector3.Cross(targetingData.Dir, Vector3.up).normalized; float num = 360f / bulletTargeting.RadialRaysCount; for (int i = 0; i < bulletTargeting.RadialRaysCount; i++) { Vector3 vector3 = (Vector3)(Quaternion.AngleAxis(num * i, targetingData.Dir) * normalized); Vector3 origin = targetingData.Origin + (vector3 * bulletTargeting.Radius); CollectDirection(origin, targetingData.Dir, 0f, targetingData); } base.ScheduleEvent(BattleCache.collectTargetsEvent.GetInstance().Init(targetingData), barelTargetingNode); base.ScheduleEvent(BattleCache.targetEvaluateEvent.GetInstance().Init(targetingData), barelTargetingNode); }
public void Build(BulletBuildEvent e, WeaponNode weaponNode, [JoinByTank] TankNode tankNode) { Entity entity = base.CreateEntity<RicochetBulletTemplate>("battle/weapon/ricochet/bullet"); BulletComponent bullet = new BulletComponent(); WeaponBulletShotComponent weaponBulletShot = weaponNode.weaponBulletShot; float bulletRadius = weaponBulletShot.BulletRadius; bullet.Radius = bulletRadius; bullet.Speed = weaponBulletShot.BulletSpeed; MuzzleVisualAccessor accessor = new MuzzleVisualAccessor(weaponNode.muzzlePoint); BulletTargetingComponent component4 = entity.AddComponentAndGetInstance<BulletTargetingComponent>(); component4.RadialRaysCount = entity.AddComponentAndGetInstance<BulletConfigComponent>().RadialRaysCount; component4.Radius = bulletRadius; Rigidbody tankRigidbody = tankNode.rigidbody.Rigidbody; bullet.ShotId = weaponNode.shotId.ShotId; base.InitBullet(bullet, accessor.GetWorldPosition(), e.Direction, bullet.Radius, tankRigidbody); entity.AddComponent(bullet); entity.AddComponent(new TankGroupComponent(weaponNode.tankGroup.Key)); entity.AddComponent<RicochetBulletComponent>(); entity.AddComponent(new TargetCollectorComponent(new TargetCollector(tankNode.Entity), new TargetValidator(tankNode.Entity))); entity.AddComponent<ReadyBulletComponent>(); }