示例#1
0
        public static void LaunchProjectileClientside(BasePlayer ownerPlayer, BaseProjectile baseProjectile, ItemDefinition ammo, int projectileCount, float projSpreadaimCone)
        {
            ItemModProjectile component = ammo.GetComponent <ItemModProjectile>();

            if (component == null)
            {
                Debug.Log("Ammo doesn't have a Projectile module!");
                return;
            }
            createdProjectiles.Clear();
            float num  = ProjectileWeaponMod.Average(baseProjectile, (ProjectileWeaponMod x) => x.projectileVelocity, (ProjectileWeaponMod.Modifier y) => y.scalar, 1f);
            float num2 = ProjectileWeaponMod.Sum(baseProjectile, (ProjectileWeaponMod x) => x.projectileVelocity, (ProjectileWeaponMod.Modifier y) => y.offset, 0f);

            using (ProjectileShoot projectileShoot = Facepunch.Pool.Get <ProjectileShoot>())
            {
                projectileShoot.projectiles = new List <ProjectileShoot.Projectile>();
                projectileShoot.ammoType    = ammo.itemid;
                for (int i = 0; i < projectileCount; i++)
                {
                    Vector3 position = ownerPlayer.eyes.position;
                    Vector3 vector   = ownerPlayer.eyes.BodyForward();
                    if (projSpreadaimCone > 0f || component.projectileSpread > 0f)
                    {
                        Quaternion rotation = ownerPlayer.eyes.rotation;
                        float      num3     = baseProjectile.aimconeCurve.Evaluate(UnityEngine.Random.Range(0f, 1f));
                        float      num4     = (projectileCount <= 1) ? component.GetSpreadScalar() : component.GetIndexedSpreadScalar(i, projectileCount);
                        float      num5     = num3 * projSpreadaimCone + component.projectileSpread * num4;
                        vector = AimConeUtil.GetModifiedAimConeDirection(num5, rotation * Vector3.forward, projectileCount <= 1);
                        if (ConVar.Global.developer > 0)
                        {
                            UnityEngine.DDraw.Arrow(position, position + vector * 3f, 0.1f, Color.white, 20f);
                        }
                    }
                    Vector3    vector2      = vector * (component.GetRandomVelocity() * baseProjectile.projectileVelocityScale * num + num2);
                    int        seed         = ownerPlayer.NewProjectileSeed();
                    int        projectileID = ownerPlayer.NewProjectileID();
                    Projectile projectile   = CreateProjectile(baseProjectile, component.projectileObject.resourcePath, position, vector, vector2);
                    if (projectile != null)
                    {
                        projectile.mod   = component;
                        projectile.seed  = seed;
                        projectile.owner = ownerPlayer;
                        projectile.sourceWeaponPrefab     = GameManager.client.FindPrefab(baseProjectile).GetComponent <AttackEntity>();
                        projectile.sourceProjectilePrefab = component.projectileObject.Get().GetComponent <Projectile>();
                        projectile.projectileID           = projectileID;
                        projectile.invisible = baseProjectile.IsSilenced();
                        createdProjectiles.Add(projectile);
                        aimbotProjectiles.Add(projectile);
                    }
                    ProjectileShoot.Projectile projectile2 = new ProjectileShoot.Projectile();
                    projectile2.projectileID = projectileID;
                    projectile2.startPos     = position;
                    projectile2.startVel     = vector2;
                    projectile2.seed         = seed;
                    projectileShoot.projectiles.Add(projectile2);
                }
                baseProjectile.ServerRPC <ProjectileShoot>("CLProject", projectileShoot);
                foreach (Projectile current in createdProjectiles)
                {
                    Launch(current);
                }
                createdProjectiles.Clear();
            }
        }