Class Perception
- Sync perceptions
these are used to synchronize clients with the server world representation. This is the only valid way of knowing world's status. - Delta perception
this is used to send only the changes to the world since the last perception.
How Perceptions and Actions work Actions are sent from the client to the server in order to make the character perform an action. In order for the client to know the result of the action the Server needs to send a reply to the client. How will this be done?
In a first attempt, we send clients back an action that was the result of their action. However, this made the code really hard because we had to update two different things, perceptions and actions. Instead the solution appears intuitively: Why not join action reply and perceptions.
So the action reply is stored inside each object (that executed the action ) with a set of attributes that determine the action return status and the attributes. This way of doing replys makes it a bit harder on RPManager but it simplifys the creation of new clients alot.
See RPAction reply in the RPObject documentation to know exactly what is returned. However, keep in mind that the return result depends of each particular game.
- Author:
- miguel
-
Field Summary
Modifier and TypeFieldDescriptionThe added objectsThe deleted objectsstatic byte
A Delta perception sends only changesThe modified added objectsThe modified deleted objectsstatic byte
A sync perception sends the whole worldbyte
The type of the perception: Delta or SyncThe zone.id to which this perception belong -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This method adds an added object to the perceptionvoid
clear()
Clear the perceptionvoid
This method adds an modified object of the worldvoid
This method adds a removed object of the worldint
size()
Returns the number of elements of the perceptiontoString()
-
Field Details
-
DELTA
public static final byte DELTAA Delta perception sends only changes- See Also:
- Constant Field Values
-
SYNC
public static final byte SYNCA sync perception sends the whole world- See Also:
- Constant Field Values
-
type
public byte typeThe type of the perception: Delta or Sync -
zoneid
The zone.id to which this perception belong -
addedList
The added objects -
modifiedAddedList
The modified added objects -
modifiedDeletedList
The modified deleted objects -
deletedList
The deleted objects
-
-
Constructor Details
-
Perception
Constructor- Parameters:
type
- the type of perception, either Delta or Sync perception.zoneid
- the zone we are building the perception for.
-
-
Method Details
-
added
This method adds an added object to the perception- Parameters:
object
- the object added.
-
modified
This method adds an modified object of the world- Parameters:
modified
- the modified object- Throws:
Exception
- if there is any problem computing the differences.
-
removed
This method adds a removed object of the world- Parameters:
object
- the removed object
-
size
public int size()Returns the number of elements of the perception- Returns:
- the amount of objects
-
clear
public void clear()Clear the perception -
toString
-