public override void OnReloadPressedSafe(PlayerController player, Gun gun, bool manualReload) { if ((gun.ClipCapacity == gun.ClipShotsRemaining) || (gun.CurrentAmmo == gun.ClipShotsRemaining)) { if (gun.CurrentAmmo >= 5) { if (this.m_extantReticleQuad) //If the cursor is there, then do the teleport { gun.CurrentAmmo -= 5; Vector2 worldCenter = this.m_extantReticleQuad.WorldCenter; UnityEngine.Object.Destroy(this.m_extantReticleQuad.gameObject); worldCenter += new Vector2(1.5f, 1.5f); //worldCenter = new Vector2(Mathf.FloorToInt(worldCenter.x), Mathf.FloorToInt(worldCenter.y)); // UnityEngine.Object.Instantiate<GameObject>((PickupObjectDatabase.GetById(Pencil.pencilID) as Gun).DefaultModule.projectiles[0].gameObject, new Vector3(worldCenter.x, worldCenter.y), Quaternion.identity); TeleportPlayerToCursorPosition.StartTeleport(player, worldCenter); } else //If the cursor is not there, make it { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.reticleQuad); this.m_extantReticleQuad = gameObject.GetComponent <tk2dBaseSprite>(); this.m_currentAngle = BraveMathCollege.Atan2Degrees(player.unadjustedAimPoint.XY() - player.CenterPosition); this.m_currentDistance = 5f; this.UpdateReticlePosition(); } } } }
protected override void DoActiveEffect(PlayerController user) { tk2dBaseSprite cursor = OMITBReflectionHelpers.ReflectGetField <tk2dBaseSprite>(typeof(TargetedAttackPlayerItem), "m_extantReticleQuad", this); Vector2 overridePos = cursor.WorldCenter; TeleportPlayerToCursorPosition.StartTeleport(user, overridePos); base.DoActiveEffect(user); }