void OnRPC_ClProject(Message packet) { ProjectileShoot projectileShoot = ProjectileShoot.Deserialize(packet.read); if (projectileShoot.projectiles.Count > ItemOwner.Information.BaseProjectile.ProjectilesPerShot) { ConsoleSystem.Log($"projectiles.Count[{projectileShoot.projectiles.Count}] > ProjectilesPerShot[{ItemOwner.Information.BaseProjectile.ProjectilesPerShot}]"); Release(); return; } if (AmmoCount <= 0) { ConsoleSystem.Log($"AmmoCount[{AmmoCount}] <= 0"); Release(); return; } AmmoCount--; foreach (var projectile in projectileShoot.projectiles) { PlayerOwner.firedProjectiles.Add(projectile.projectileID, ItemOwner.Information); } base.SignalBroadcast(E_Signal.Attack, string.Empty, packet.connection); Release(); void Release() { projectileShoot.Dispose(); Pool.Free(ref projectileShoot); } }
void OnRPC_CLProject(Message packet) { ProjectileShoot projectileShoot = ProjectileShoot.Deserialize(packet.read); foreach (var projectile in projectileShoot.projectiles) { PlayerOwner.firedProjectiles.Add(projectile.projectileID, ItemOwner.Information); } var container = ItemOwner.Container; container.RemoveItemFromContainer(ItemOwner); container.OnItemConainerUpdate(); Release(); void Release() { projectileShoot.Dispose(); Pool.Free(ref projectileShoot); } }
private void CLProject(RPCMessage msg) { BasePlayer player = msg.player; if (!VerifyClientAttack(player)) { SendNetworkUpdate(); } else { if (player == null || player.IsHeadUnderwater()) { return; } if (!canThrowAsProjectile) { AntiHack.Log(player, AntiHackType.ProjectileHack, "Not throwable (" + base.ShortPrefabName + ")"); player.stats.combat.Log(this, "not_throwable"); return; } Item item = GetItem(); if (item == null) { AntiHack.Log(player, AntiHackType.ProjectileHack, "Item not found (" + base.ShortPrefabName + ")"); player.stats.combat.Log(this, "item_missing"); return; } ItemModProjectile component = item.info.GetComponent <ItemModProjectile>(); if (component == null) { AntiHack.Log(player, AntiHackType.ProjectileHack, "Item mod not found (" + base.ShortPrefabName + ")"); player.stats.combat.Log(this, "mod_missing"); return; } ProjectileShoot projectileShoot = ProjectileShoot.Deserialize(msg.read); if (projectileShoot.projectiles.Count != 1) { AntiHack.Log(player, AntiHackType.ProjectileHack, "Projectile count mismatch (" + base.ShortPrefabName + ")"); player.stats.combat.Log(this, "count_mismatch"); return; } player.CleanupExpiredProjectiles(); foreach (ProjectileShoot.Projectile projectile in projectileShoot.projectiles) { if (player.HasFiredProjectile(projectile.projectileID)) { AntiHack.Log(player, AntiHackType.ProjectileHack, "Duplicate ID (" + projectile.projectileID + ")"); player.stats.combat.Log(this, "duplicate_id"); } else if (ValidateEyePos(player, projectile.startPos)) { player.NoteFiredProjectile(projectile.projectileID, projectile.startPos, projectile.startVel, this, item.info, item); Effect effect = new Effect(); effect.Init(Effect.Type.Projectile, projectile.startPos, projectile.startVel, msg.connection); effect.scale = 1f; effect.pooledString = component.projectileObject.resourcePath; effect.number = projectile.seed; EffectNetwork.Send(effect); } } projectileShoot?.Dispose(); item.SetParent(null); Interface.CallHook("OnMeleeThrown", player, item); if (!canAiHearIt) { return; } float num = 0f; if (component.projectileObject != null) { GameObject gameObject = component.projectileObject.Get(); if (gameObject != null) { Projectile component2 = gameObject.GetComponent <Projectile>(); if (component2 != null) { foreach (DamageTypeEntry damageType in component2.damageTypes) { num += damageType.amount; } } } } if (player != null) { Sensation sensation = default(Sensation); sensation.Type = SensationType.ThrownWeapon; sensation.Position = player.transform.position; sensation.Radius = 50f; sensation.DamagePotential = num; sensation.InitiatorPlayer = player; sensation.Initiator = player; Sense.Stimulate(sensation); } } }