Exemple #1
0
        public static bool IsHeartInRoom(Action <CaterpillarDevourHeartBehavior> orig, CaterpillarDevourHeartBehavior self)
        {
            AIActor          m_aiActor      = (AIActor)typeof(CaterpillarDevourHeartBehavior).GetField("m_aiActor", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(self);
            PlayerController companionOwner = m_aiActor.CompanionOwner;

            if (!companionOwner || companionOwner.CurrentRoom == null)
            {
                return(false);
            }
            List <HealthPickup> componentsAbsoluteInRoom = companionOwner.CurrentRoom.GetComponentsAbsoluteInRoom <HealthPickup>();

            for (int i = 0; i < componentsAbsoluteInRoom.Count; i++)
            {
                HealthPickup healthPickup = componentsAbsoluteInRoom[i];
                if (healthPickup)
                {
                    if (healthPickup.armorAmount != 0)
                    {
                        componentsAbsoluteInRoom.RemoveAt(i);
                        i--;
                    }
                }
            }
            HealthPickup closestToPosition = BraveUtility.GetClosestToPosition <HealthPickup>(componentsAbsoluteInRoom, m_aiActor.CenterPosition, new HealthPickup[0]);

            if (closestToPosition != null)
            {
                typeof(CaterpillarDevourHeartBehavior).GetField("m_targetHeart", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(self, closestToPosition);
                return(true);
            }
            return(false);
        }
Exemple #2
0
    void Start()
    {
        pickupSpawnPoints = GameObject.FindGameObjectsWithTag("PickupSpawnPoint").Select(o => o.transform.position).ToList();
        numSpawnPoints    = pickupSpawnPoints.Count();

        healthPickup = ((GameObject)Instantiate(healthPickupPrefab)).GetComponent <HealthPickup>();

        if (useRapidFirePickup)
        {
            rapidFirePickup = ((GameObject)Instantiate(rapidFirePickupPrefab)).GetComponent <RapidFirePickupScript>();
            numberToSpawn++;
        }

        if (useLaserPickup)
        {
            laserPickup = ((GameObject)Instantiate(laserFirePickupPrefab)).GetComponent <LaserPickup>();
            numberToSpawn++;
        }

        if (useExplosivePickup)
        {
            explosiveFirePickup = ((GameObject)Instantiate(explosiveFirePickupPrefab)).GetComponent <ExplosiveFirePickupScript>();
            numberToSpawn++;
        }
    }
Exemple #3
0
    void OnTriggerEnter(Collider other)
    {
        InteractionPrompt.Invoke(this.Interactables.Count > 0);

        switch (other.tag)
        {
        case "Enemy Weapon":
            if (isVulnerable)
            {
                this.SetState(new TakeDamageState(this));
                PlayerDamaged.Invoke();
            }
            break;

        case "Health":
            if (health < maxHealth)
            {
                health += 2;

                if (health > 10)
                {
                    health = 10;
                }

                HealthPickup.Invoke();
                Audio.PlayOneShot(healthPick);

                other.gameObject.SetActive(false);
            }
            break;
        }
    }
Exemple #4
0
        public HealthDropper(Vector2 pos, string textureName, int frameWidth, int frameHeight, DrawOrder layer, float healthDropChance = 0.5f, bool dropBigHealth = false)
            : base(pos, textureName, frameWidth, frameHeight, layer)
        {
            _health = new HealthPickup(pos, dropBigHealth);

            _healthDropChance = healthDropChance;
        }
Exemple #5
0
        public void Execute(TriggerEvent triggerEvent)
        {
            Entity entityA = triggerEvent.Entities.EntityA;
            Entity entityB = triggerEvent.Entities.EntityB;
            bool   entityAIsHealthPickup    = healthPickupGroup.Exists(entityA);
            bool   entityBIsPlayerCharacter = playerCharacterGroup.Exists(entityB);

            if (entityAIsHealthPickup && entityBIsPlayerCharacter)
            {
                HealthPickup healthPickUp = healthPickupGroup[entityA];
                Health       health       = healthGroup[entityB];

                health.Value        += healthPickUp.restoredAmount;
                healthGroup[entityB] = health;

                entityCommandBuffer.DestroyEntity(entityA);
            }
            else
            {
                bool entityAIsPlayerCharacter = playerCharacterGroup.Exists(entityA);
                bool entityBIsHealthPickUp    = healthPickupGroup.Exists(entityB);
                if (entityAIsPlayerCharacter && entityBIsHealthPickUp)
                {
                    HealthPickup healthPickUp = healthPickupGroup[entityB];
                    Health       health       = healthGroup[entityA];

                    health.Value         = math.clamp(health.Value + healthPickUp.restoredAmount, 0, health.MaxValue);
                    healthGroup[entityA] = health;

                    entityCommandBuffer.DestroyEntity(entityB);
                }
            }
        }
Exemple #6
0
        public void GetInteractableFromKaartItem()
        {
            var kaartItem = new KaartItem();

            kaartItem.Beschrijving = "TestBoodschap";
            var interactable = new HealthPickup();

            kaartItem.interacties.Add(interactable);
            Assert.AreEqual(interactable, kaartItem.GetInteractable());
        }
Exemple #7
0
        public void CheckHealthVerhogingNaPickup()
        {
            var speler       = new Speler();
            var spelerOud    = speler;
            var healthPickup = new HealthPickup();

            healthPickup.Interact(speler);

            Assert.AreEqual(spelerOud.Health, speler.Health);
        }
Exemple #8
0
 public static void Healing(Action <HealthPickup, PlayerController> acshon, HealthPickup key, PlayerController player)
 {
     acshon(key, player);
     foreach (PassiveItem passives in player.passiveItems)
     {
         if (passives is CodexUmbra && BoxOTools.BasicRandom(.5f))
         {
             GiveRandomItem(player);
         }
     }
 }
Exemple #9
0
    // END OF STATE MACHINE METHODS

    // Manages collision with other rigidbodys.
    // Player manages its own collisions with objects so enemies may collide with them on its own way.
    void OnCollisionEnter(Collision other)
    {
        if (other.gameObject.GetComponent <Obstacle>() != null) //Check if the collision was triggered by an obstacle
        {
            Obstacle obstacle = other.gameObject.GetComponent <Obstacle>();
            ObstacleCollide(obstacle);
        }
        if (other.gameObject.GetComponent <AIBehaviour>() != null) //Check if the collision was triggered by an obstacle
        {
            AIBehaviour enemy = other.gameObject.GetComponent <AIBehaviour>();
            enemy.Hitting(this);
        }
        if (other.gameObject.GetComponent <Pickup>() != null) //Check if the collision was triggered by an obstacle
        {
            Pickup objectToPick = other.gameObject.GetComponent <Pickup>();
            objectToPick.Disable();
            if (other.gameObject.GetComponent <Gun>() != null) //Check if the collision was triggered by an obstacle
            {
                int   currentNumGuns = _gunController.getGunNum();
                Gun[] newGuns        = new Gun[currentNumGuns + 1];
                if (currentNumGuns > 0)
                {
                    Gun[] currentGuns = _gunController.getGuns();
                    for (int i = 0; i < currentGuns.Length; i++)
                    {
                        newGuns[i] = currentGuns[i];
                    }
                }
                newGuns[newGuns.Length - 1] = other.gameObject.GetComponent <Gun>();
                _gunController.changeGuns(newGuns);
            }
            else if (other.gameObject.GetComponent <HealthPickup>() != null) //Check if the collision was triggered by a healthpack
            {
                HealthPickup healthPack = other.gameObject.GetComponent <HealthPickup>();
                if (_hp + healthPack.getHeal() > startingHp)
                {
                    _hp = startingHp;
                }
                else
                {
                    _hp += healthPack.getHeal();
                }
                Debug.Log("Player healed for " + healthPack.getHeal());
                Destroy(other.gameObject);
            }
            else
            {
                Destroy(other.gameObject);
            }
        }
    }
Exemple #10
0
    public void Shoot()
    {
        FindObjectOfType <AudioManager>().Play("cannon");
        RaycastHit[] hits;
        hits = Physics.SphereCastAll(transform.position, radius, transform.forward, range, shootableMask);

        if (hits.Length > 0)
        {
            for (int i = 0; i < hits.Length; i++)
            {
                //Debug.Log(hits[i].collider.name); to check what i am hitting
                shootHit = hits[i];
                if (gyroScript = shootHit.collider.gameObject.GetComponent <GyroBot>())
                {
                    //gyroScript.modeHacked = false;
                    gyroScript.hackedTimer = 0;
                    gyroScript.ActivateSeekPlayer();
                }
                if (swarmBot = shootHit.collider.gameObject.GetComponent <SwarmBot>())
                {
                    swarmBot.SeekPlayer();
                }
                if (healthPickup = shootHit.collider.gameObject.GetComponent <HealthPickup>())
                {
                    if (playerStats.curHealth != 100)
                    {
                        healthPickup.SeekPlayer();
                    }
                }
                if (darkDexPickup = shootHit.collider.gameObject.GetComponent <DarkDexPickup>())
                {
                    darkDexPickup.SeekPlayer();
                }
                if (energyPickup = shootHit.collider.gameObject.GetComponent <EnergyPickup>())
                {
                    if (playerStats.curEnergy != 100)
                    {
                        energyPickup.SeekPlayer();
                    }
                }
                if (partsPickup = shootHit.collider.gameObject.GetComponent <Parts>())
                {
                    partsPickup.SeekPlayer();
                }
                if (memeBot = shootHit.collider.gameObject.GetComponent <MemeBot>())
                {
                    memeBot.SeekPlayer();
                }
            }
        }
    }
Exemple #11
0
    private void OnTriggerEnter2D(Collider2D collision) //Handles collisions between player and non-physical GameObjects
    {
        GameObject other = collision.gameObject;

        if (other.tag == "Pickup") //Player touches a health pickup
        {
            HealthPickup healthScript = other.GetComponent <HealthPickup>();
            if (healthScript) //Restores health and removes pickup
            {
                ChangeHealth(healthScript.Health);
                Destroy(other);
            }
        }
    }
Exemple #12
0
    void Die()
    {
        AudioManagerSFX.PlaySound("lampBreak");

        //this is the only breakable object currently, so small healthpickup drop chance
        var r = Random.Range(0, 10);

        if (r > 9)
        {
            drop = Instantiate <HealthPickup>(hp, transform.position + transform.up * -1, transform.rotation);
        }

        this.enabled = false;

        Destroy(gameObject, 2f);
    }
Exemple #13
0
    //KS - Attempt to set agents target to the closest active health if health is needed, returns false if this is not currently possible or they already have full health.
    public bool SetTargetToClosestActiveHealth()
    {
        if (IsFullHealth())
        {
            return(false);
        }

        //KS - Agent already has an health target.
        if (targetObject != null)
        {
            HealthPickup targetHealth = targetObject.GetComponent <HealthPickup>();
            if (targetHealth && targetHealth.IsPickupActive())
            {
                return(true);
            }
        }

        //KS - Find closest health target
        GameObject target = null;

        if (World.healthTiles.Count > 0)
        {
            float closestDistance = -1;
            for (int i = 0; i < World.healthTiles.Count; i++)
            {
                //KS - If not active skip.
                if (!World.healthTiles[i].pickupComponent.IsPickupActive())
                {
                    continue;
                }

                float distance = Vector3.Distance(transform.position, World.healthTiles[i].mTileObject.transform.position);
                if (distance < closestDistance || closestDistance < 0.0f)
                {
                    closestDistance = distance;
                    target          = World.healthTiles[i].mTileObject;
                }
            }
        }

        if (target)
        {
            SetTarget(target);
        }

        return(target != null);
    }
Exemple #14
0
        public void DropPickup()
        {
            bool coinDrop       = Random.Range(0f, 100f) <= config.coinDropChance;
            int  coinDropAmount = Random.Range(config.coinMinDropAmount, config.coinMaxDropAmount + 1);

            if (coinDrop)
            {
                Coin coinObject = Instantiate(coin, coinDropLocation.position, Quaternion.identity);
                coinObject.SetCoinAmount(coinDropAmount);
            }
            bool healthDrop       = Random.Range(0f, 100f) <= config.healthDropChance;
            int  healthDropAmount = Random.Range(config.healthMinDropAmount, config.healthMaxDropAmount + 1);

            if (healthDrop)
            {
                HealthPickup healthObject = Instantiate(health, healthDropLocation.position, Quaternion.identity);
                healthObject.SetHealthAmount(healthDropAmount);
            }
        }
Exemple #15
0
    void Die()
    {
        dead = true;
        theCanvas.SetActive(false);
        AudioManagerSFX.PlaySound("enemyDied");
        anim.SetBool("isWalking", false);

        anim.SetBool("isDead", true);
        // enemy gameobj is not destroyed, body is left behind for 2 seconds
        this.enabled = false;

        var r = Random.Range(0, 100);

        if (r > 90)
        {
            drop = Instantiate <HealthPickup>(hp, transform.position + transform.right * 1, transform.rotation);
        }

        Destroy(gameObject, 2f);
    }
    //TODO: Implement grace period. Righ now, using OnTriggerEnter, boss can park on top of a cornered player, and using OnTriggerStay, boss insta-kills him
    void OnTriggerStay2D(Collider2D col)
    {
        if (col.tag == "Shot")
        {
            ShotAttributes shot = col.GetComponent <ShotAttributes> ();
            if (shot.getTeamID() != teamID)
            {
                if (!onGracePeriod())
                {
                    takeDamage(shot.damage);
                    timeLastDamage = Time.time;
                }
                Destroy(col.gameObject);
            }
        }

        if (col.tag == "Pickup")
        {
            HealthPickup healthPickup = col.GetComponent <HealthPickup> ();
            currentHealth += healthPickup.healthRecovered;
            if (currentHealth > maxHealth)
            {
                currentHealth = maxHealth;
            }
            healthTracker.setHealth(currentHealth);
            Destroy(col.gameObject);
        }

        if (col.tag == "Boss" && !onGracePeriod())
        {
            takeDamage(1);
            isStunned       = true;
            timeRecoverStun = Time.time + timeStunned;

            Vector3 offset    = transform.position - col.transform.position;
            Vector3 direction = offset.normalized;
            rb.velocity = direction * speedStunned;

            timeLastDamage = Time.time;
        }
    }
Exemple #17
0
    private void Update()
    {
        if (IsSquareOpen(new Vector2(0f, -1f), RaycastPoint.position, 1f) && !IsAnimating)
        {
            IsFalling = true;
        }
        else
        {
            if (IsFalling && !IsOnLadder(Vector2.zero, RaycastPoint.position, 1f))
            {
                AudioSource.PlayOneShot(LandAudioClip);
                LandingParticle.Play();
            }
            IsFalling = false;
        }

        RaycastHit2D raycast = Physics2D.Raycast(RaycastPoint.position, Vector2.zero, 1f, LayerMask.GetMask("bomb bag", "health pickup"));

        if (raycast.transform != null)
        {
            BombBag bombBag = raycast.transform.GetComponent <BombBag>();
            if (bombBag != null)
            {
                AudioSource.PlayOneShot(PickupClip);
                BombCount       += bombBag.CollectBombBag();
                BombCountUI.text = BombCount.ToString();
            }
            HealthPickup healthPickup = raycast.transform.GetComponent <HealthPickup>();
            if (healthPickup != null)
            {
                AudioSource.PlayOneShot(PickupClip);
                Health            += healthPickup.CollectHealth();
                HealthValueUI.text = Health.ToString();
            }
        }

        if (Health <= 0)
        {
            StartCoroutine(DeathAnimation());
        }
    }
Exemple #18
0
    private void OnTriggerEnter2D(Collider2D col)
    {
        switch (col.tag)
        {
        case "HealthPickup":
            HealthPickup healthPickup = col.GetComponent <HealthPickup>();

            ModifyHealth(healthPickup.healthBoost);
            ModifyShield(healthPickup.shieldBoost);

            Destroy(col.gameObject);
            break;

        case "EnemyProjectile":
            AIProjectile aiProjectile = col.GetComponent <AIProjectile>();
            ModifyShield(-aiProjectile.projectileData.damage);

            Destroy(aiProjectile.gameObject);
            break;
        }
    }
    private void EndDialog()
    {
        Animator.SetBool("IsOpen", false);
        _isStarted = false;
        // if event exists, invoke
        if (Type == "START")
        {
            StartBattle?.Invoke();
        }
        else if (Type == "END")
        {
            EndBattle?.Invoke();
        }
        else if (Type == "STARTCUTSCENE")
        {
            EndStartingCutscene?.Invoke();
        }
        else if (Type == "PLAYERSTARTCUTSCENE")
        {
            PlayerEndStartingCutscene?.Invoke();
        }
        else if (Type == "HEALTHPICKUP")
        {
            HealthPickup?.Invoke();
        }
        else if (Type == "ENDING")
        {
            FinalScene?.Invoke();
        }

        AudioSource source = FindObjectOfType <GameStateManager>().gameObject.GetComponent <AudioSource>();

        if (source)
        {
            source.mute = false;
        }
    }
Exemple #20
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.tag == "Shot")
        {
            ShotAttributes shot = col.GetComponent <ShotAttributes> ();
            if (shot.getTeamID() != teamID)
            {
                takeDamage(shot.damage);
                Destroy(col.gameObject);
            }
        }

        if (col.tag == "Pickup")
        {
            HealthPickup healthPickup = col.GetComponent <HealthPickup> ();
            currentHealth += healthPickup.healthRecovered;
            if (currentHealth > maxHealth)
            {
                currentHealth = maxHealth;
            }
            healthTracker.setHealth(currentHealth);
            Destroy(col.gameObject);
        }
    }
    //public AudioClip HealSound;
    //AudioSource audio;

    void Start()
    {
        Instance = this;
        //audio = GetComponent<AudioSource>();
    }
Exemple #22
0
 public static void heartPickupHookMethod(Action <HealthPickup, PlayerController> orig, HealthPickup self, PlayerController player)
 {
     orig(self, player);
     if (player.HasPickupID(CakeIDs.Glitchedheart))
     {
         int bighead = UnityEngine.Random.Range(1, 3);
         if (bighead == 1)
         {
             player.healthHaver.Armor = player.healthHaver.Armor + 1;
         }
         if (bighead == 2)
         {
             player.ownerlessStatModifiers.Add(Toolbox.SetupStatModifier(PlayerStats.StatType.Damage, 0.1f, StatModifier.ModifyMethod.ADDITIVE, false));
             player.stats.RecalculateStats(player, false, false);
         }
     }
 }
Exemple #23
0
 public void UseHealthPickup(HealthPickup h)
 {
     h.UseObject(this);
 }
 public static void heartPickupHookMethod(Action <HealthPickup, PlayerController> orig, HealthPickup self, PlayerController player)
 {
     orig(self, player);
     if (heartRegulator)
     {
         if (self.armorAmount > 0)
         {
             giveCash(player, 8);
         }
         else
         {
             giveCash(player, (int)(self.healAmount * 4f));
         }
         heartRegulator = false;
     }
     else
     {
         heartRegulator = true;
     }
 }
 public void OnPickupEnter(HealthPickup health)
 {
     Health += 20;
 }
    float curFollowSpeed;                       //Increases the longer the player stays in the trigger zone

    // Use this for initialization
    void Start()
    {
        thisHealthPickup = transform.parent.GetComponentInChildren <HealthPickup>();
        curFollowSpeed   = defaultFollowSpeed;
    }
    void Start()
    {
        _playersounds = GetComponent<PlayerSounds>();
        _bullSound = GetComponent<BullSound>();
        if (this.tag == Tags.PLAYER)
        {
            _movement       = GetComponent<PlayerMovement>();
            _inputToggle    = GetComponent<ToggleEnableInput>();
        }

        if(this.tag == Tags.BULL || this.tag == Tags.PLAYER)
        {
            _adjustHealth   = GetComponent<AdjustHealth>();
        }
        if (this.tag == Tags.PICKUP)
        {
            _pickUp         = GetComponent<HealthPickup>();

        }
    }
Exemple #28
0
 public void OnPickupEnter(HealthPickup pickup)
 {
     health += pickup.health;
 }
Exemple #29
0
 public static void CallHealthPickup(float value)
 {
     HealthPickup?.Invoke(value);
 }
Exemple #30
0
    void FixedUpdate()
    {
        //set up external script references
        Ironsights         IronsightsComponent     = GetComponent <Ironsights>();
        FPSRigidBodyWalker FPSWalkerComponent      = GetComponent <FPSRigidBodyWalker>();
        PlayerWeapons      PlayerWeaponsComponent  = weaponObj.GetComponent <PlayerWeapons>();
        WeaponBehavior     WeaponBehaviorComponent = PlayerWeaponsComponent.weaponOrder[PlayerWeaponsComponent.currentWeapon].GetComponent <WeaponBehavior>();

        //Exit application if escape is pressed
        if (Input.GetKey(exitGame))
        {
            if (Application.isEditor || Application.isWebPlayer)
            {
                //Application.Quit();//not used
            }
            else
            {
                //use this quit method because Application.Quit(); can cause crashes on exit in Unity 4
                //if this issue is resolved in a newer Unity version, use Application.Quit here instead
                System.Diagnostics.Process.GetCurrentProcess().Kill();
            }
        }

        //Restart level if v is pressed
        if (Input.GetKey(restartScene))
        {
            Time.timeScale = 1.0f;                                        //set timescale to 1.0f so fadeout wont take longer if bullet time is active
            GameObject llf = Instantiate(levelLoadFadeObj) as GameObject; //Create instance of levelLoadFadeObj
            //call FadeAndLoadLevel function with fadein argument set to false
            //in levelLoadFadeObj to restart level and fade screen out from black on level load
            llf.GetComponent <LevelLoadFade>().FadeAndLoadLevel(Color.black, 2.0f, false);
            //set restarting var to true to be accessed by FPSRigidBodyWalker script to stop rigidbody movement
            restarting = true;
            // Disable all scripts to deactivate player control upon player death
            foreach (var c in children)
            {
                Component[] coms = c.GetComponentsInChildren <MonoBehaviour>();
                foreach (var b in coms)
                {
                    MonoBehaviour p = b as MonoBehaviour;
                    if (p)
                    {
                        p.enabled = false;
                    }
                }
            }
        }

        //toggle or hold zooming state by determining if zoom button is pressed or held
        if (Input.GetKey(zoom) && WeaponBehaviorComponent.canZoom && !(FPSWalkerComponent.climbing && FPSWalkerComponent.lowerGunForClimb))
        {
            if (!zoomStartState)
            {
                zoomStart      = Time.time;                           //track time that zoom button was pressed
                zoomStartState = true;                                //perform these actions only once
                zoomEndState   = false;
                if (zoomEnd - zoomStart < zoomDelay * Time.timeScale) //if button is tapped, toggle zoom state
                {
                    if (!zoomed)
                    {
                        zoomed = true;
                    }
                    else
                    {
                        zoomed = false;
                    }
                }
            }
        }
        else
        {
            if (!zoomEndState)
            {
                zoomEnd        = Time.time;         //track time that zoom button was released
                zoomEndState   = true;
                zoomStartState = false;
                if (zoomEnd - zoomStart > zoomDelay * Time.timeScale)                //if releasing zoom button after holding it down, stop zooming
                {
                    zoomed = false;
                }
            }
        }

        //track when player stopped zooming to allow for delay of reticle becoming visible again
        if (zoomed)
        {
            zoomBtnState = false;            //only perform this action once per button press
        }
        else
        {
            if (!zoomBtnState)
            {
                zoomStopTime = Time.time;
                zoomBtnState = true;
            }
        }

        //enable and disable crosshair based on various states like reloading and zooming
        if (IronsightsComponent.reloading || zoomed)
        {
            //don't disable reticle if player is using a melee weapon or if player is unarmed
            if (WeaponBehaviorComponent.meleeSwingDelay == 0 && !WeaponBehaviorComponent.unarmed)
            {
                if (crosshairVisibleState)
                {
                    //disable the GUITexture element of the instantiated crosshair object
                    //and set state so this action will only happen once.
                    CrosshairGuiObjInstance.GetComponent <GUITexture>().enabled = false;
                    crosshairVisibleState = false;
                }
            }
        }
        else
        {
            //Because of the method that is used for non magazine reloads, an additional check is needed here
            //to make the reticle appear after the last bullet reload time has elapsed. Proceed with no check
            //for magazine reloads.
            if ((WeaponBehaviorComponent.bulletsPerClip != WeaponBehaviorComponent.bulletsToReload &&
                 WeaponBehaviorComponent.reloadLastStartTime + WeaponBehaviorComponent.reloadLastTime < Time.time) ||
                WeaponBehaviorComponent.bulletsPerClip == WeaponBehaviorComponent.bulletsToReload)
            {
                //allow a delay before enabling crosshair again to let the gun return to neutral position
                //by checking the zoomStopTime value
                if (!crosshairVisibleState && (zoomStopTime + 0.2f < Time.time))
                {
                    CrosshairGuiObjInstance.GetComponent <GUITexture>().enabled = true;
                    crosshairVisibleState = true;
                }
            }
        }

        if (WeaponBehaviorComponent.showAimingCrosshair)
        {
            reticleColor.a = 0.25f;
            CrosshairGuiObjInstance.GetComponent <GUITexture>().color = reticleColor;
        }
        else
        {
            //make alpha of aiming reticle zero/transparent
            reticleColor.a = 0.0f;
            //set alpha of aiming reticle at start to prevent it from showing, but allow item pickup hand reticle
            CrosshairGuiObjInstance.GetComponent <GUITexture>().color = reticleColor;
        }

        //Pick up items
        RaycastHit hit;

        if (!IronsightsComponent.reloading &&    //no item pickup when reloading
            !WeaponBehaviorComponent.lastReload &&    //no item pickup when when reloading last round in non magazine reload
            !PlayerWeaponsComponent.switching &&    //no item pickup when switching weapons
            (!FPSWalkerComponent.canRun || FPSWalkerComponent.inputY == 0)       //no item pickup when sprinting
            //there is a small delay between the end of canRun and the start of sprintSwitching (in PlayerWeapons script),
            //so track actual time that sprinting stopped to avoid the small time gap where the pickup hand shows briefly
            && ((FPSWalkerComponent.sprintStopTime + 0.4f) < Time.time))
        {
            //raycast a line from the main camera's origin using a point extended forward from camera position/origin as a target to get the direction of the raycast
            //and scale the distance of the raycast based on the playerHeightMod value in the FPSRigidbodyWalker script
            if (Physics.Raycast(mainCamTransform.position, ((mainCamTransform.position + mainCamTransform.forward * (5.0f + (FPSWalkerComponent.playerHeightMod * 0.25f))) - mainCamTransform.position).normalized, out hit, 2.0f + FPSWalkerComponent.playerHeightMod, rayMask))
            {
                if (hit.collider.gameObject.tag == "Usable")                //if the object hit by the raycast is a pickup item and has the "Usable" tag

                {
                    if (pickUpBtnState && Input.GetKey(use))
                    {
                        //run the PickUpItem function in the pickup object's script
                        hit.collider.SendMessageUpwards("PickUpItem", SendMessageOptions.DontRequireReceiver);
                        //run the ActivateObject function of this object's script if it has the "Usable" tag
                        hit.collider.SendMessageUpwards("ActivateObject", SendMessageOptions.DontRequireReceiver);
                        pickUpBtnState = false;
                        FPSWalkerComponent.cancelSprint = true;
                    }

                    //determine if pickup item is using a custom pickup reticle and if so set pickupTex to custom reticle
                    if (pickUpBtnState)                    //check pickUpBtnState to prevent reticle from briefly showing custom/general pickup icon briefly when picking up last weapon before maxWeapons are obtained

                    //determine if item under reticle is a weapon pickup
                    {
                        if (hit.collider.gameObject.GetComponent <WeaponPickup>())
                        {
                            //set up external script references
                            WeaponBehavior PickupWeaponBehaviorComponent = PlayerWeaponsComponent.weaponOrder[hit.collider.gameObject.GetComponent <WeaponPickup>().weaponNumber].GetComponent <WeaponBehavior>();
                            WeaponPickup   WeaponPickupComponent         = hit.collider.gameObject.GetComponent <WeaponPickup>();

                            if (PlayerWeaponsComponent.totalWeapons == PlayerWeaponsComponent.maxWeapons &&                        //player has maximum weapons
                                PickupWeaponBehaviorComponent.addsToTotalWeaps)                            //weapon adds to total inventory

                            //player does not have weapon under reticle
                            {
                                if (!PickupWeaponBehaviorComponent.haveWeapon
                                    //and weapon under reticle hasn't been picked up from an item with removeOnUse set to false
                                    && !PickupWeaponBehaviorComponent.dropWillDupe)
                                {
                                    if (!useSwapReticle)                                    //if useSwapReticle is true, display swap reticle when item under reticle will replace current weapon
                                    {
                                        if (WeaponPickupComponent.weaponPickupReticle)
                                        {
                                            //display custom weapon pickup reticle if the weapon item has one defined
                                            pickupTex = WeaponPickupComponent.weaponPickupReticle;
                                        }
                                        else
                                        {
                                            //weapon has no custom pickup reticle, just show general pickup reticle
                                            pickupTex = pickupReticle;
                                        }
                                    }
                                    else
                                    {
                                        //display weapon swap reticle if player has max weapons and can swap held weapon for pickup under reticle
                                        pickupTex = swapReticle;
                                    }
                                }
                                else
                                {
                                    //weapon under reticle is not removed on use and is in player's inventory, so show cantPickup reticle
                                    if (!WeaponPickupComponent.removeOnUse)
                                    {
                                        pickupTex = noPickupReticle;
                                    }
                                    else                                      //weapon is removed on use, so show standard or custom pickup reticle

                                    {
                                        if (WeaponPickupComponent.weaponPickupReticle)
                                        {
                                            //display custom weapon pickup reticle if the weapon item has one defined
                                            pickupTex = WeaponPickupComponent.weaponPickupReticle;
                                        }
                                        else
                                        {
                                            //weapon has no custom pickup reticle, just show general pickup reticle
                                            pickupTex = pickupReticle;
                                        }
                                    }
                                }
                            }
                            else                              //total weapons not at maximum and weapon under reticle does not add to inventory

                            {
                                if (!PickupWeaponBehaviorComponent.haveWeapon &&
                                    !PickupWeaponBehaviorComponent.dropWillDupe ||
                                    WeaponPickupComponent.removeOnUse)
                                {
                                    if (WeaponPickupComponent.weaponPickupReticle)
                                    {
                                        //display custom weapon pickup reticle if the weapon item has one defined
                                        pickupTex = WeaponPickupComponent.weaponPickupReticle;
                                    }
                                    else
                                    {
                                        //weapon has no custom pickup reticle, just show general pickup reticle
                                        pickupTex = pickupReticle;
                                    }
                                }
                                else
                                {
                                    pickupTex = noPickupReticle;
                                }
                            }
                            //determine if item under reticle is a health pickup
                        }
                        else if (hit.collider.gameObject.GetComponent <HealthPickup>())
                        {
                            //set up external script references
                            HealthPickup HealthPickupComponent = hit.collider.gameObject.GetComponent <HealthPickup>();

                            if (HealthPickupComponent.healthPickupReticle)
                            {
                                pickupTex = HealthPickupComponent.healthPickupReticle;
                            }
                            else
                            {
                                pickupTex = pickupReticle;
                            }
                            //determine if item under reticle is an ammo pickup
                        }
                        else if (hit.collider.gameObject.GetComponent <AmmoPickup>())
                        {
                            //set up external script references
                            AmmoPickup AmmoPickupComponent = hit.collider.gameObject.GetComponent <AmmoPickup>();

                            if (AmmoPickupComponent.ammoPickupReticle)
                            {
                                pickupTex = AmmoPickupComponent.ammoPickupReticle;
                            }
                            else
                            {
                                pickupTex = pickupReticle;
                            }
                        }
                        else
                        {
                            pickupTex = pickupReticle;
                        }
                    }

                    UpdateReticle(false);                    //show pickupReticle if raycast hits a pickup item
                }
                else
                {
                    if (crosshairTextureState)
                    {
                        UpdateReticle(true);                        //show aiming reticle crosshair if item is not a pickup item
                    }
                }
            }
            else
            {
                if (crosshairTextureState)
                {
                    UpdateReticle(true);                    //show aiming reticle crosshair if raycast hits nothing
                }
            }
        }
        else
        {
            if (crosshairTextureState)
            {
                UpdateReticle(true);                //show aiming reticle crosshair if reloading, switching weapons, or sprinting
            }
        }

        //only register one press of E key to make player have to press button again to pickup items instead of holding E
        if (Input.GetKey(use))
        {
            pickUpBtnState = false;
        }
        else
        {
            pickUpBtnState = true;
        }
    }
        public static void PrePickuphookLogic(Action <HealthPickup, SpeculativeRigidbody, SpeculativeRigidbody> orig, HealthPickup self, SpeculativeRigidbody player, SpeculativeRigidbody selfBody)
        {
            if (self && player.gameActor && player.gameActor is PlayerController)
            {
                PlayerController playerCont = player.gameActor as PlayerController;
                if (playerCont.ModdedCharacterIdentity() == ModdedCharacterID.Shade && self.armorAmount <= 0)
                {
                    if (playerCont.HasPickupID(BloodshotEye.BloodshotEyeID))
                    {
                        float percentPerArmour = 0.02f;
                        float amt1             = self.healAmount / 0.5f;
                        int   amt2             = Mathf.CeilToInt(amt1);

                        StatModifier statModifier = new StatModifier();
                        statModifier.amount      = (percentPerArmour * amt2) + 1;
                        statModifier.modifyType  = StatModifier.ModifyMethod.MULTIPLICATIVE;
                        statModifier.statToBoost = PlayerStats.StatType.Damage;
                        playerCont.ownerlessStatModifiers.Add(statModifier);
                        playerCont.stats.RecalculateStats(playerCont, false, false);
                    }
                    FieldInfo field = typeof(HealthPickup).GetField("m_pickedUp", BindingFlags.Instance | BindingFlags.NonPublic);
                    field.SetValue(self, true);
                    AkSoundEngine.PostEvent("Play_OBJ_coin_medium_01", self.gameObject);
                    int amountToDrop = (self.healAmount >= 1f) ? UnityEngine.Random.Range(5, 12) : UnityEngine.Random.Range(3, 7);
                    LootEngine.SpawnCurrency((!self.sprite) ? self.specRigidbody.UnitCenter : self.sprite.WorldCenter, amountToDrop, false);

                    var type = typeof(HealthPickup);
                    var func = type.GetMethod("GetRidOfMinimapIcon", BindingFlags.Instance | BindingFlags.NonPublic);
                    var ret  = func.Invoke(self, null);

                    self.ToggleLabel(false);
                    UnityEngine.Object.Destroy(self.gameObject);
                }
                else
                {
                    orig(self, player, selfBody);
                }
            }
        }