public void RemoteDetachWeapon(DetachWeaponEvent e, RemoteTankNode tank, [JoinByTank] UnblockedWeaponNode weapon) { Rigidbody rigidbody = this.DetachWeapon(tank, weapon); rigidbody.SetVelocitySafe(e.Velocity); rigidbody.SetAngularVelocitySafe(e.AngularVelocity); }
public void PrepareBestDirection(ShotPrepareEvent evt, UnblockedWeaponNode weaponNode, [JoinByTank] SingleNode <TankSyncComponent> tankNode) { TargetingData targetingData = BattleCache.targetingData.GetInstance().Init(); base.ScheduleEvent(new TargetingEvent(targetingData), weaponNode); base.ScheduleEvent(new SendShotToServerEvent(targetingData), weaponNode); }
public void PrepareTargetsByUnblockedWeapon(ShotPrepareEvent evt, UnblockedWeaponNode weaponNode) { TargetingData targetingData = BattleCache.targetingData.GetInstance().Init(); base.ScheduleEvent(new TargetingEvent(targetingData), weaponNode); base.ScheduleEvent(new SendShotToServerEvent(targetingData), weaponNode); base.ScheduleEvent(new SendHitToServerIfNeedEvent(targetingData), weaponNode); }
public void SelfDetachWeapon(DetachWeaponIfPossibleEvent e, TankNode tank, [JoinByTank] UnblockedWeaponNode weapon) { Rigidbody rigidbody = this.DetachWeapon(tank, weapon); rigidbody.SetVelocitySafe(rigidbody.velocity + new Vector3(Random.Range((float)-1.5f, (float)1.5f), Random.Range((float)2f, (float)3f), Random.Range((float)-1.5f, (float)1.5f))); rigidbody.SetAngularVelocitySafe(rigidbody.angularVelocity + Vector3.Scale(Random.onUnitSphere, new Vector3(Random.Range((float)2f, (float)4f), Random.Range((float)0.5f, (float)1f), Random.Range((float)2f, (float)4f)))); base.ScheduleEvent(new DetachWeaponEvent(rigidbody.velocity, rigidbody.angularVelocity), tank); }
public void SendHitToServer(SendHitToServerEvent e, UnblockedWeaponNode weapon) { SelfHitEvent eventInstance = new SelfHitEvent(e.Targets, e.StaticHit) { ShotId = weapon.shotId.ShotId }; base.ScheduleEvent(eventInstance, weapon); }
public void PrepareHitByUnblockedWeapon(SendHitToServerIfNeedEvent evt, UnblockedWeaponNode weapon) { DirectionData bestDirection = evt.TargetingData.BestDirection; if (bestDirection.HasAnyHit()) { SplashHitData splashHit = SplashHitData.CreateSplashHitData(HitTargetAdapter.Adapt(bestDirection.Targets), bestDirection.StaticHit, weapon.Entity); base.ScheduleEvent(new CollectSplashTargetsEvent(splashHit), weapon); } }
public void SendShot(SendShotToServerEvent evt, UnblockedWeaponNode weaponNode) { SelfShotEvent eventInstance = new SelfShotEvent(); if (evt.TargetingData.BestDirection != null) { eventInstance.ShotDirection = evt.TargetingData.BestDirection.Dir; } else { eventInstance.ShotDirection = new MuzzleLogicAccessor(weaponNode.muzzlePoint, weaponNode.weaponInstance).GetFireDirectionWorld(); } base.ScheduleEvent(eventInstance, weaponNode); }
public void SendHit(SendHitToServerIfNeedEvent evt, UnblockedWeaponNode weapon) { WeaponHitComponent weaponHit = weapon.weaponHit; StaticHit staticHit = null; List <HitTarget> targets = new List <HitTarget>(4); if (evt.TargetingData.HasTargetHit()) { if (!weaponHit.RemoveDuplicateTargets) { targets = HitTargetAdapter.Adapt(evt.TargetingData.BestDirection.Targets); } else { HashSet <Entity> set = new HashSet <Entity>(); int num = 0; while (num < evt.TargetingData.Directions.Count) { DirectionData data = evt.TargetingData.Directions[num]; int num2 = 0; while (true) { if (num2 >= data.Targets.Count) { num++; break; } TargetData targetData = data.Targets[num2]; if (set.Add(targetData.TargetEntity)) { targets.Add(HitTargetAdapter.Adapt(targetData)); } num2++; } } } } if (weaponHit.SendStaticHit && evt.TargetingData.HasStaticHit()) { staticHit = evt.TargetingData.BestDirection.StaticHit; } if ((staticHit == null) && (targets.Count == 0)) { base.ScheduleEvent <SelfHitSkipEvent>(weapon); } else { base.ScheduleEvent(new SendHitToServerEvent(evt.TargetingData, targets, staticHit), weapon); } }
private Rigidbody DetachWeapon(TankNode tank, UnblockedWeaponNode weapon) { Rigidbody rigidbody = tank.rigidbody.Rigidbody; WeaponVisualRootComponent weaponVisualRoot = weapon.weaponVisualRoot; WeaponDetachColliderComponent weaponDetachCollider = weapon.weaponDetachCollider; GameObject gameObject = weapon.weaponVisualRoot.gameObject; if (weapon.Entity.HasComponent <DetachedWeaponComponent>()) { return(rigidbody); } gameObject.transform.parent = tank.assembledTank.AssemblyRoot.transform; gameObject.layer = Layers.TANK_AND_STATIC; weaponVisualRoot.VisualTriggerMarker.VisualTriggerMeshCollider.enabled = false; MeshCollider collider = weaponDetachCollider.Collider; collider.enabled = true; Rigidbody rigidbody2 = weaponDetachCollider.Rigidbody; Bounds bounds = collider.sharedMesh.bounds; Vector3 center = bounds.center; center.z = 0f; this.SetInertiaTensor(rigidbody2, bounds.size, center); rigidbody2.mass = rigidbody.mass / 10f; rigidbody2.maxAngularVelocity = rigidbody.maxAngularVelocity; rigidbody2.maxDepenetrationVelocity = 0f; rigidbody2.angularDrag = 2f; rigidbody2.drag = 0f; rigidbody2.SetVelocitySafe(rigidbody.velocity); rigidbody2.SetAngularVelocitySafe(rigidbody.angularVelocity); rigidbody2.interpolation = RigidbodyInterpolation.Interpolate; rigidbody2.isKinematic = false; rigidbody2.detectCollisions = true; weapon.Entity.AddComponent <DetachedWeaponComponent>(); return(rigidbody2); }
public void SendHitEvent(TargetingEvent e, SingleNode <BulletComponent> bulletNode, [JoinByTank] UnblockedWeaponNode weaponNode, [JoinByTank] SingleNode <TankSyncComponent> tankNode) { if (!e.TargetingData.HasBaseStaticHit()) { foreach (DirectionData data in e.TargetingData.Directions) { if (data.HasTargetHit()) { TargetData targetData = data.Targets.First <TargetData>(); if (targetData.TargetEntity.HasComponent <TankActiveStateComponent>()) { this.PrepareTargetData(targetData, bulletNode.component); SelfHitEvent event3 = new SelfHitEvent(); List <HitTarget> list = new List <HitTarget> { HitTargetAdapter.Adapt(targetData) }; event3.Targets = list; event3.ShotId = bulletNode.component.ShotId; SelfHitEvent eventInstance = event3; base.ScheduleEvent(eventInstance, weaponNode.Entity); break; } } } } }
public void RequestBulletBuild(SendShotToServerEvent evt, UnblockedWeaponNode weaponNode) { base.ScheduleEvent(new BulletBuildEvent(evt.TargetingData.BestDirection.Dir), weaponNode); }
public void RequestBulletBuild(RemoteShotEvent evt, UnblockedWeaponNode weaponNode) { base.ScheduleEvent(new BulletBuildEvent(evt.ShotDirection), weaponNode); }