Class: RuneRb::Network::RS377::ContextStateBlock

Inherits:
Message
  • Object
show all
Defined in:
app/network/protocol/rs377/outgoing/state.rb

Overview

Since:

  • 0.9.3

Constant Summary

Constants included from Constants

Constants::BIT_MASK_OUT, Constants::BYTE_MUTATIONS, Constants::BYTE_ORDERS, Constants::BYTE_SIZE, Constants::CONNECTION_TYPES, Constants::LOGIN_RESPONSES, Constants::MESSAGE_SIZES, Constants::PROTOCOL_TEMPLATES, Constants::RW_TYPES, Constants::SIDEBAR_INTERFACES

Instance Attribute Summary

Attributes inherited from Message

#header, #mode

Instance Method Summary collapse

Methods inherited from Message

compile_header, #inspect, #peek, validate

Methods included from System::Log

#class_name, #err, #err!, #log, #log!, #symbolize_file

Constructor Details

#initialize(context) ⇒ ContextStateBlock

Writes the appearance of a Context entity

Parameters:

Since:

  • 0.9.3


8
9
10
11
# File 'app/network/protocol/rs377/outgoing/state.rb', line 8

def initialize(context)
  super('w')
  write_state(context)
end

Instance Method Details

#write_state(context) ⇒ Object

Writes the state of a context to a message

Parameters:

Since:

  • 0.9.3


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/network/protocol/rs377/outgoing/state.rb', line 15

def write_state(context)
  # Make the mask
  mask = 0
  # Attributes:
  # ForcedMove
  mask |= 0x100 if context.flags[:force_move?]
  # Graphics
  mask |= 0x200 if context.flags[:graphic?]
  # Animation
  mask |= 0x8 if context.flags[:animation?]
  # Forced Chat
  mask |= 0x10 if context.flags[:force_chat?]
  # Chat
  mask |= 0x40 if context.flags[:chat?]
  # Face Entity
  mask |= 0x1 if context.flags[:face_mob?]
  # Appearance
  mask |= 0x4 if context.flags[:state?]
  # Face Coordinates
  mask |= 0x2 if context.flags[:turn_to?]
  # Primary Hit
  mask |= 0x80 if context.flags[:primary_hit?]
  # Secondary Hit
  mask |= 0x400 if context.flags[:secondary_hit?]
  # Append the mask
  if mask >= 0x100
    mask |= 0x20
    write_short(mask, :STD, :LITTLE)
  else
    write_byte(mask)
  end

  write_graphic(context.graphic) if context.flags[:graphic?]
  write_animation(context.animation) if context.flags[:animation?]
  write_chat(context.message, context.profile.rights) if context.flags[:chat?]
  write_appearance(context) if context.flags[:state?]
end