Пример #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
                shooterRegisterTile.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 (SpawnsCasing)
                {
                    if (casingPrefabOverride == null)
                    {
                        //no casing override set, use normal casing prefab
                        casingPrefabOverride = Resources.Load("BulletCasing") as GameObject;
                    }

                    Spawn.ServerPrefab(casingPrefabOverride, nextShot.shooter.transform.position, nextShot.shooter.transform.parent);
                }
            }
        }
Пример #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.ServerAmmoRemains <= 0 || CurrentMagazine.containedBullets[0] == 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;
                }

                GameObject toShoot  = CurrentMagazine.containedBullets[0];
                int        quantity = CurrentMagazine.containedProjectilesFired[0];

                if (toShoot == null)
                {
                    Logger.LogError("Shot was attempted but no projectile or quantity was found to use", Category.Firearms);
                    return;
                }

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

                //trigger a hotspot caused by gun firing
                shooterRegisterTile.Matrix.ReactionManager.ExposeHotspotWorldPosition(nextShot.shooter.TileWorldPosition());

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

                if (isSuppressed == false && nextShot.isSuicide == false)
                {
                    Chat.AddActionMsgToChat(serverHolder,
                                            $"You fire your {gameObject.ExpensiveName()}",
                                            $"{serverHolder.ExpensiveName()} fires their {gameObject.ExpensiveName()}");
                }

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

                if (SpawnsCasing)
                {
                    if (casingPrefabOverride == null)
                    {
                        //no casing override set, use normal casing prefab
                        casingPrefabOverride = CustomNetworkManager.Instance.GetSpawnablePrefabFromName("BulletCasing");
                    }
                    Spawn.ServerPrefab(casingPrefabOverride, nextShot.shooter.transform.position, nextShot.shooter.transform.parent);
                }
            }
        }