Example #1
0
    public void handleDamage(object titan, object pv, int damage)
    {
        PhotonView playerView = (PhotonView)pv;
        TITAN      t          = (TITAN)titan;

        if (this.healthModEnabled)
        {
            int  health = this.getTitanHealth(t);
            bool dead   = damage >= health;

            if (dead)
            {
                if (customNames)
                {
                    //colorize the titan's HP based on it's value
                    float percentage = ((float)health) / minDamage;
                    int   hp         = 0;
                    percentage = percentage > 1f ? 1f : percentage;
                    //alternate between RED (max health) and green (lowest health)
                    byte r = (byte)((int)255 * percentage);
                    byte g = (byte)((int)255 * (1f - percentage));

                    hp |= ((r << 16) | (g << 8));

                    t.name = Colorizer.colorize(health + "HP ", hp.ToString("X6"), false) + t.name;
                }

                if (headExplode && damage > health + explodeHeadExtraDamage && t.abnormalType != AbnormalType.TYPE_CRAWLER)
                {
                    t.photonView.RPC("dieHeadBlowRPC", PhotonTargets.All, new object[] {
                        playerView.transform.position,
                        1f
                    });
                }
                else
                {
                    t.photonView.RPC("netDie", PhotonTargets.AllBuffered, new object[] {});
                    if (t.grabbedTarget != null)
                    {
                        t.grabbedTarget.GetPhotonView().RPC("netUngrabbed", global::PhotonTargets.All, new object[0]);
                    }
                }

                t.OnTitanDie(t.photonView); //RC

                ModMain.instance.getGameManager().photonView.RPC("titanGetKill", PhotonNetwork.player, playerView.owner, damage, t.name);

                //SpawnControllerHook
                ModMain.instance.getSpawnController().onTitanDown(t);

                if (this.rcExplode)
                {
                    new Thread(() => this.doExplosion(t.transform.position, this.rcExplosionRadius, explosionDelay)).Start();
                }
            }
            else if (this.showDealtDamage)
            {
                ModMain.instance.getGameManager().photonView.RPC("netShowDamage", playerView.owner, new object[] { damage });
            }
        }
        else
        {
            ModMain.instance.getGameManager().photonView.RPC("titanGetKill", PhotonNetwork.player, playerView.owner, damage, t.name);

            t.OnTitanDie(t.photonView); //RC

            t.photonView.RPC("netDie", PhotonTargets.AllBuffered, new object[] {});
            if (t.grabbedTarget != null)
            {
                t.grabbedTarget.GetPhotonView().RPC("netUngrabbed", global::PhotonTargets.All, new object[0]);
            }

            //SpawnControllerHook
            ModMain.instance.getSpawnController().onTitanDown(t);
        }
    }