RuneHive-Game
Loading...
Searching...
No Matches
UpdateFlag.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.mob;
2
3import com.runehive.game.world.entity.mob.npc.Npc;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.net.packet.out.SendPlayerUpdate;
6
7/**
8 * Entity update flags.
9 *
10 * @author Michael | Chex
11 * @author Jire
12 */
13public enum UpdateFlag {
14 APPEARANCE(0x10, -1),
15 CHAT(0x80, -1) {
16 @Override
17 public boolean canApply(Player player, Player other, SendPlayerUpdate.UpdateState state) {
18 return state != SendPlayerUpdate.UpdateState.UPDATE_SELF && other.getChatMessage().isPresent();
19 }
20 },
21 GRAPHICS(0x100, 0x80) {
22 @Override
23 public boolean canApply(Player player, Player other, SendPlayerUpdate.UpdateState state) {
24 return other.getGraphic().isPresent();
25 }
26
27 @Override
28 public boolean canApply(Npc npc) {
29 return npc.getGraphic().isPresent();
30 }
31 },
32 ANIMATION(0x8, 0x10) {
33 @Override
34 public boolean canApply(Player player, Player other, SendPlayerUpdate.UpdateState state) {
35 return other.getAnimation().isPresent();
36 }
37
38 @Override
39 public boolean canApply(Npc npc) {
40 return npc.getAnimation().isPresent();
41 }
42 },
43 FORCED_CHAT(0x4, 0x1),
44 INTERACT(0x1, 0x20),
45 FACE_COORDINATE(0x2, 0x4),
46 FIRST_HIT(0x20, 0x40),
47 SECOND_HIT(0x200, 0x8),
48 TRANSFORM(-1, 0x2),
49 FORCE_MOVEMENT(0x400, -1) {
50 @Override
51 public boolean canApply(Player player, Player other, SendPlayerUpdate.UpdateState state) {
52 return other.getForceMovement() != null;
53 }
54 };
55
56 public final int playerMask;
57 public final int npcMask;
58
60 this.playerMask = playerMask;
61 this.npcMask = npcMask;
62 }
63
64 public static final UpdateFlag[] playerOrder = {
65 FORCE_MOVEMENT,
66 GRAPHICS,
67 ANIMATION,
68 FORCED_CHAT,
69 CHAT,
70 INTERACT,
71 APPEARANCE,
72 FACE_COORDINATE,
73 FIRST_HIT,
74 SECOND_HIT
75 };
76
77 public static final UpdateFlag[] npcOrder = {
78 ANIMATION,
79 GRAPHICS,
80 INTERACT,
81 FORCED_CHAT,
82 FIRST_HIT,
83 SECOND_HIT,
84 TRANSFORM,
85 FACE_COORDINATE
86 };
87
88 public static boolean contains(int masks, int mask) {
89 return (masks & mask) != 0;
90 }
91
92 public static boolean containsPlayer(int masks, UpdateFlag flag) {
93 return contains(masks, flag.playerMask);
94 }
95
96 public static boolean containsNpc(int masks, UpdateFlag flag) {
97 return contains(masks, flag.npcMask);
98 }
99
100 public boolean canApply(Player player, Player other, SendPlayerUpdate.UpdateState state) {
101 return true;
102 }
103
104 public boolean canApply(Npc npc) {
105 return true;
106 }
107}
Optional< Graphic > getGraphic()
Definition Mob.java:712
Optional< Animation > getAnimation()
Definition Mob.java:708
Represents a non-player character in the in-game world.
Definition Npc.java:29
This class represents a character controlled by a player.
Definition Player.java:125
boolean canApply(Player player, Player other, SendPlayerUpdate.UpdateState state)
static boolean containsNpc(int masks, UpdateFlag flag)
UpdateFlag(int playerMask, int npcMask)
static boolean containsPlayer(int masks, UpdateFlag flag)
static boolean contains(int masks, int mask)