RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
UpdateFlag.java
1package com.osroyale.game.world.entity.mob;
2
3import com.osroyale.game.world.entity.mob.npc.Npc;
4import com.osroyale.game.world.entity.mob.player.Player;
5import com.osroyale.net.packet.out.SendPlayerUpdate;
6
35
36public enum UpdateFlag {
37 APPEARANCE(0x10, -1),
38 CHAT(0x80, -1) {
39 @Override
40 public boolean canApply(Player player, Player other, SendPlayerUpdate.UpdateState state) {
41 return state != SendPlayerUpdate.UpdateState.UPDATE_SELF && other.getChatMessage().isPresent();
42 }
43 },
44 GRAPHICS(0x100, 0x80) {
45 @Override
46 public boolean canApply(Player player, Player other, SendPlayerUpdate.UpdateState state) {
47 return other.getGraphic().isPresent();
48 }
49
50 @Override
51 public boolean canApply(Npc npc) {
52 return npc.getGraphic().isPresent();
53 }
54 },
55 ANIMATION(0x8, 0x10) {
56 @Override
57 public boolean canApply(Player player, Player other, SendPlayerUpdate.UpdateState state) {
58 return other.getAnimation().isPresent();
59 }
60
61 @Override
62 public boolean canApply(Npc npc) {
63 return npc.getAnimation().isPresent();
64 }
65 },
66 FORCED_CHAT(0x4, 0x1),
67 INTERACT(0x1, 0x20),
68 FACE_COORDINATE(0x2, 0x4),
69 FIRST_HIT(0x20, 0x40),
70 SECOND_HIT(0x200, 0x8),
71 TRANSFORM(-1, 0x2),
72 FORCE_MOVEMENT(0x400, -1) {
73 @Override
74 public boolean canApply(Player player, Player other, SendPlayerUpdate.UpdateState state) {
75 return other.getForceMovement() != null;
76 }
77 };
78
79 public final int playerMask;
80 public final int npcMask;
81
82 UpdateFlag(int playerMask, int npcMask) {
83 this.playerMask = playerMask;
84 this.npcMask = npcMask;
85 }
86
87 public static final UpdateFlag[] playerOrder = {
88 FORCE_MOVEMENT,
89 GRAPHICS,
90 ANIMATION,
91 FORCED_CHAT,
92 CHAT,
93 INTERACT,
94 APPEARANCE,
95 FACE_COORDINATE,
96 FIRST_HIT,
97 SECOND_HIT
98 };
99
100 public static final UpdateFlag[] npcOrder = {
101 ANIMATION,
102 GRAPHICS,
103 INTERACT,
104 FORCED_CHAT,
105 FIRST_HIT,
106 SECOND_HIT,
107 TRANSFORM,
108 FACE_COORDINATE
109 };
110
111 public static boolean contains(int masks, int mask) {
112 return (masks & mask) != 0;
113 }
114
115 public static boolean containsPlayer(int masks, UpdateFlag flag) {
116 return contains(masks, flag.playerMask);
117 }
118
119 public static boolean containsNpc(int masks, UpdateFlag flag) {
120 return contains(masks, flag.npcMask);
121 }
122
123 public boolean canApply(Player player, Player other, SendPlayerUpdate.UpdateState state) {
124 return true;
125 }
126
127 public boolean canApply(Npc npc) {
128 return true;
129 }
130}