Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Although the KnifeItem.prefab says `useCooldown: 0`, the `KnifeItem.HitKnife` has a special logic:
- * (Unrelated parts omitted)
- */
- public class KnifeItem : GrabbableObject
- {
- public int knifeHitForce = 1;
- public override void ItemActivate(bool used, bool buttonDown = true)
- {
- if (base.IsOwner) { HitKnife(); }
- }
- public void HitKnife(bool cancel = false)
- {
- if (!cancel)
- {
- objectsHitByKnife = Physics.SphereCastAll( /* ... */ );
- objectsHitByKnifeList = objectsHitByKnife /* ... */ ;
- for (int i = 0; i < objectsHitByKnifeList.Count; i++)
- {
- if (/* hit on special layers */) { /* ... */ }
- else
- {
- if ( /* hit on walls, floors, etc., */ ) continue;
- try
- {
- if (Time.realtimeSinceStartup - timeAtLastDamageDealt > 0.43f) // <-- [!]
- {
- timeAtLastDamageDealt = Time.realtimeSinceStartup;
- component.Hit(knifeHitForce, forward, previousPlayerHeldBy, playHitSFX: true, 5);
- bloodParticle.Play(withChildren: true);
- }
- }
- catch (Exception arg) Debug.Log("...");
- }
- }
- }
- }
- // other methods ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement