public override BehaviorResult Update() { SpeculativeRigidbody targetRigidbody = this.m_aiActor.TargetRigidbody; if (!(targetRigidbody != null)) { return(BehaviorResult.Continue); } float desiredCombatDistance = this.m_aiActor.DesiredCombatDistance; if (this.StopWhenInRange && this.m_aiActor.DistanceToTarget <= desiredCombatDistance) { this.m_aiActor.ClearPath(); return(BehaviorResult.Continue); } if (this.m_repathTimer <= 0f) { Vector2 targetPosition; if (!this.m_otherBro) { m_otherBro = ExpandWesternBroController.GetOtherWesternBros(this.m_aiActor).FirstOrDefault(); } if (!this.m_otherBro) { targetPosition = targetRigidbody.UnitCenter; } else { Vector2 unitCenter = this.m_aiActor.TargetRigidbody.specRigidbody.GetUnitCenter(ColliderType.HitBox); Vector2 unitCenter2 = this.m_aiActor.specRigidbody.UnitCenter; Vector2 unitCenter3 = this.m_otherBro.specRigidbody.UnitCenter; float num = (unitCenter2 - unitCenter).ToAngle(); float num2 = (unitCenter3 - unitCenter).ToAngle(); float num3 = (num + num2) / 2f; float angle; if (BraveMathCollege.ClampAngle180(num - num3) > 0f) { angle = num3 + 90f; } else { angle = num3 - 90f; } targetPosition = unitCenter + BraveMathCollege.DegreesToVector(angle, 1f) * this.DesiredCombatDistance; } this.m_aiActor.PathfindToPosition(targetPosition, null, true, null, null, null, false); this.m_repathTimer = this.PathInterval; } return(BehaviorResult.SkipRemainingClassBehaviors); }
private void Update() { if (this.m_reloadRemaining > 0) { } else { if (this.m_cooldownRemaining > 0) { } else { if (this.m_clipShotsRemaining > 0) { if (this.GetNearestEnemy() != null) { if (this.ProjectilesToShoot != null) { for (int i = 0; i < this.ProjectilesToShoot.Count; i++) { Projectile projectile = this.ProjectilesToShoot[i]; float angleVariance = this.AngleVariances[i]; if (projectile != null) { GameObject obj = SpawnManager.SpawnProjectile(projectile.gameObject, this.sprite.WorldCenter, Quaternion.Euler(0, 0, BraveMathCollege.Atan2Degrees(this.GetNearestEnemy().sprite.WorldCenter - this.sprite.WorldCenter) + UnityEngine.Random.Range(-angleVariance, angleVariance))); Projectile proj = obj.GetComponent <Projectile>(); if (proj != null) { if (this.Owner != null) { proj.Owner = this.Owner; proj.Shooter = this.Owner.specRigidbody; } } } } } AkSoundEngine.PostEvent("Play_WPN_gun_shot_01", base.gameObject); this.spriteAnimator.Play(this.shootAnimation); base.StartCoroutine(this.HandleCooldown()); this.m_clipShotsRemaining -= 1; } } else { AkSoundEngine.PostEvent("Play_WPN_gun_reload_01", base.gameObject); this.spriteAnimator.Play(this.reloadAnimation); base.StartCoroutine(this.HandleReload()); } } } if (this.GetNearestEnemy() != null) { this.transform.rotation = Quaternion.Euler(0, 0, BraveMathCollege.ClampAngle180(BraveMathCollege.Atan2Degrees(this.GetNearestEnemy().sprite.WorldCenter - this.sprite.WorldCenter))); //ETGModConsole.Log(.ToString()); float num = 75f; float num2 = 105f; float gunAngle = BraveMathCollege.ClampAngle180(BraveMathCollege.Atan2Degrees(this.GetNearestEnemy().sprite.WorldCenter - this.sprite.WorldCenter)); if (gunAngle <= 155f && gunAngle >= 25f) { num = 75f; num2 = 105f; } if (Mathf.Abs(gunAngle) > num2) { this.sprite.FlipY = true; } else if (Mathf.Abs(gunAngle) < num) { base.sprite.FlipY = false; } this.CurrentAngle = gunAngle; } }
public override ContinuousBehaviorResult ContinuousUpdate() { switch (State) { case FireState.Priming: if (!m_aiActor.TargetRigidbody) { return(ContinuousBehaviorResult.Finished); } if (m_timer > 0f) { float facingDirection = m_aiAnimator.FacingDirection; float num = (m_aiActor.TargetRigidbody.specRigidbody.GetUnitCenter(ColliderType.HitBox) - m_aiActor.specRigidbody.UnitCenter).ToAngle(); float b = BraveMathCollege.ClampAngle180(num - facingDirection); float facingDirection2 = facingDirection + Mathf.Lerp(0f, b, m_deltaTime / (m_timer + m_deltaTime)); m_aiAnimator.FacingDirection = facingDirection2; } if (!stopDuringPrime) { float magnitude = m_aiActor.BehaviorVelocity.magnitude; float magnitude2 = Mathf.Lerp(magnitude, 0f, m_deltaTime / (m_timer + m_deltaTime)); m_aiActor.BehaviorVelocity = BraveMathCollege.DegreesToVector(m_aiAnimator.FacingDirection, magnitude2); } if ((primeTime <= 0f) ? (!m_aiAnimator.IsPlaying(primeAnim)) : (m_timer <= 0f)) { State = FireState.Charging; } break; case FireState.Charging: if (chargeAcceleration > 0f) { m_currentSpeed = Mathf.Min(chargeSpeed, m_currentSpeed + chargeAcceleration * m_deltaTime); m_aiActor.BehaviorVelocity = BraveMathCollege.DegreesToVector(m_chargeDirection, m_currentSpeed); } if (endWhenChargeAnimFinishes && !m_aiAnimator.IsPlaying(chargeAnim)) { return(ContinuousBehaviorResult.Finished); } if (maxChargeDistance > 0f) { m_chargeTime += m_deltaTime; if (m_chargeTime * chargeSpeed > maxChargeDistance) { return(ContinuousBehaviorResult.Finished); } } break; case FireState.Bouncing: if (!m_aiAnimator.IsPlaying(hitAnim)) { return(ContinuousBehaviorResult.Finished); } break; case FireState.Idle: return(ContinuousBehaviorResult.Finished); } return(ContinuousBehaviorResult.Continue); }
private void LateUpdate() { if (this.m_reloadRemaining > 0) { } else { if (this.m_cooldownRemaining > 0) { } else { if (this.OwnerAvailable()) { BraveInput input2 = BraveInput.GetInstanceForPlayer(this.Owner.PlayerIDX); if (input2 != null && input2.ActiveActions.GetActionFromType(GungeonActions.GungeonActionType.Shoot).IsPressed) { GameObject obj = SpawnManager.SpawnProjectile(this.ProjectileToShoot.gameObject, this.sprite.WorldCenter, Quaternion.Euler(0, 0, BraveMathCollege.Atan2Degrees(this.GetAimPoint(this.Owner)) + UnityEngine.Random.Range(-this.AngleVariance, this.AngleVariance))); Projectile proj = obj.GetComponent <Projectile>(); if (proj != null) { if (this.Owner != null) { proj.Owner = this.Owner; proj.Shooter = this.Owner.specRigidbody; } } AkSoundEngine.PostEvent("Play_WPN_gun_shot_01", base.gameObject); this.spriteAnimator.Play(this.shootAnimation); base.StartCoroutine(this.HandleCooldown()); } } } } BraveInput input = BraveInput.GetInstanceForPlayer(this.Owner.PlayerIDX); if (this.m_cooldownRemaining <= 0 && (!this.OwnerAvailable() || input == null || !input.ActiveActions.GetActionFromType(GungeonActions.GungeonActionType.Shoot).IsPressed)) { this.spriteAnimator.Stop(); this.sprite.SetSprite(this.collection, this.spriteId); } if (this.OwnerAvailable()) { this.transform.rotation = Quaternion.Euler(0, 0, BraveMathCollege.ClampAngle180(BraveMathCollege.Atan2Degrees(this.GetAimPoint(this.Owner)))); bool flag2 = this.transform.rotation.eulerAngles.z > 90f && this.transform.rotation.eulerAngles.z < 270f; if (flag2 && !base.sprite.FlipY) { base.sprite.FlipY = true; } else if (!flag2 && base.sprite.FlipY) { base.sprite.FlipY = false; } this.Owner.IsGunLocked = true; } else { this.Owner.IsGunLocked = false; } if (this.playerCanCarryMe && this.Owner != null) { this.transform.position = this.Owner.sprite.WorldTopCenter + Vector2.down; } this.sprite.HeightOffGround = 0.075f; this.sprite.UpdateZDepth(); }