Esempio n. 1
0
    private void DequeueAndProcessServerShot()
    {
        if (queuedShots.Count > 0)
        {
            QueuedShot nextShot = queuedShots.Dequeue();

            // check if we can still shoot
            PlayerMove   shooter       = nextShot.shooter.GetComponent <PlayerMove>();
            PlayerScript shooterScript = nextShot.shooter.GetComponent <PlayerScript>();
            if (!shooter.allowInput || shooterScript.IsGhost)
            {
                Logger.Log("A player tried to shoot when not allowed or when they were a ghost.", Category.Exploits);
                Logger.LogWarning("A shot was attempted when shooter is a ghost or is not allowed to shoot.", Category.Firearms);
                return;
            }


            if (CurrentMagazine == null || CurrentMagazine.ServerAmmoRemains <= 0 || Projectile == null)
            {
                Logger.LogTrace("Player tried to shoot when there was no ammo.", Category.Exploits);
                Logger.LogWarning("A shot was attempted when there is no ammo.", Category.Firearms);
                return;
            }

            if (FireCountDown > 0)
            {
                Logger.LogTrace("Player tried to shoot too fast.", Category.Exploits);
                Logger.LogWarning("Shot was attempted to be dequeued when the fire count down is not yet at 0.", Category.Exploits);
                return;
            }

            //perform the actual server side shooting, creating the bullet that does actual damage
            DisplayShot(nextShot.shooter, nextShot.finalDirection, nextShot.damageZone, nextShot.isSuicide);

            //trigger a hotspot caused by gun firing
            registerTile.Matrix.ReactionManager.ExposeHotspotWorldPosition(nextShot.shooter.TileWorldPosition(), 3200, 0.005f);

            //tell all the clients to display the shot
            ShootMessage.SendToAll(nextShot.finalDirection, nextShot.damageZone, nextShot.shooter, this.gameObject, nextShot.isSuicide);

            //kickback
            shooterScript.pushPull.Pushable.NewtonianMove((-nextShot.finalDirection).NormalizeToInt());

            if (SpawnsCaseing)
            {
                if (casingPrefab == null)
                {
                    casingPrefab = Resources.Load("BulletCasing") as GameObject;
                }

                Spawn.ServerPrefab(casingPrefab, nextShot.shooter.transform.position, nextShot.shooter.transform.parent);
            }
        }
    }
Esempio n. 2
0
    private void DequeueAndProcessServerShot()
    {
        if (queuedShots.Count > 0)
        {
            QueuedShot nextShot = queuedShots.Dequeue();

            // check if we can still shoot
            PlayerMove   shooter       = nextShot.shooter.GetComponent <PlayerMove>();
            PlayerScript shooterScript = nextShot.shooter.GetComponent <PlayerScript>();
            if (!shooter.allowInput || shooterScript.IsGhost)
            {
                Logger.Log("A player tried to shoot when not allowed or when they were a ghost.", Category.Exploits);
                Logger.LogWarning("A shot was attempted when shooter is a ghost or is not allowed to shoot.", Category.Firearms);
                return;
            }


            if (CurrentMagazine == null || CurrentMagazine.ammoRemains <= 0 || Projectile == null)
            {
                Logger.LogTrace("Player tried to shoot when there was no ammo.", Category.Exploits);
                Logger.LogWarning("A shot was attempted when there is no ammo.", Category.Firearms);
                return;
            }

            if (FireCountDown > 0)
            {
                Logger.LogTrace("Player tried to shoot too fast.", Category.Exploits);
                Logger.LogWarning("Shot was attempted to be dequeued when the fire count down is not yet at 0.", Category.Exploits);
                return;
            }

            //perform the actual server side shooting, creating the bullet that does actual damage
            DisplayShot(nextShot.shooter, nextShot.finalDirection, nextShot.damageZone, nextShot.isSuicide);

            //tell all the clients to display the shot
            ShootMessage.SendToAll(nextShot.finalDirection, nextShot.damageZone, nextShot.shooter, this.gameObject, nextShot.isSuicide);

            if (SpawnsCaseing)
            {
                if (casingPrefab == null)
                {
                    casingPrefab = Resources.Load("BulletCasing") as GameObject;
                }

                PoolManager.PoolNetworkInstantiate(casingPrefab, nextShot.shooter.transform.position, nextShot.shooter.transform.parent);
            }
        }
    }