RuneHive-Game
Loading...
Searching...
No Matches
CombatHit.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.combat.hit;
2
3import java.util.function.Function;
4
5/**
6 * A wrapper for a {@link Hit} object, adding additional variables for hit and
7 * hitsplat delays.
8 *
9 * @author Michael | Chex
10 */
11public final class CombatHit extends Hit {
12
13 /** The hit delay. */
14 private final int hitDelay;
15
16 /** The hitsplat delay. */
17 private final int hitsplatDelay;
18
19 private final boolean multipleHitsAllowed;
20
21 /** Constructs a new {@link CombatHit} object. */
23 super(hit.getDamage(), hit.getHitsplat(), hit.getHitIcon(), hit.isAccurate());
24 this.hitDelay = hitDelay;
25 this.hitsplatDelay = hitsplatDelay;
26 this.multipleHitsAllowed = false;
27 }
28
29 public CombatHit(Hit[] hits, int hitDelay, int hitsplatDelay) {
30 super(hits);
31 this.hitDelay = hitDelay;
32 this.hitsplatDelay = hitsplatDelay;
33 this.multipleHitsAllowed = true;
34 }
35
36 /**
37 * Copies and modifies this combat hit.
38 *
39 * @param modifier the damage modification
40 * @return a copy of this combat hit with the damage modifier applied
41 */
42 public CombatHit copyAndModify(Function<Integer, Integer> modifier) {
43 CombatHit next = new CombatHit(this, hitDelay, hitsplatDelay);
44 next.modifyDamage(modifier);
45 return next;
46 }
47
48 /** @return the hit delay. */
49 public int getHitDelay() {
50 return hitDelay;
51 }
52
53 /** @return the hit delay. */
54 public int getHitsplatDelay() {
55 return hitsplatDelay;
56 }
57
58 public boolean getMultipleHitsAllowed() {
60 }
61}
CombatHit copyAndModify(Function< Integer, Integer > modifier)
Copies and modifies this combat hit.
CombatHit(Hit hit, int hitDelay, int hitsplatDelay)
Constructs a new CombatHit object.
CombatHit(Hit[] hits, int hitDelay, int hitsplatDelay)
Hit(Hit[] multipleHits)
Constructs a new Hit object.
Definition Hit.java:31
void modifyDamage(Function< Integer, Integer > modifier)
Sets the hit damage with a function.
Definition Hit.java:108