|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.cast.CharacterManager
public class CharacterManager
The character manager provides facilities for constructing sprites that are used to represent characters in a scene. It also handles the compositing and caching of composited character animations.
| Nested Class Summary | |
|---|---|
protected static class |
CharacterManager.TranslatedComponent
Combines a component with an optional translation for shadowing or masking. |
| Field Summary | |
|---|---|
protected ActionCache |
_acache
The action animation cache, if we have one. |
protected Map<Tuple<CharacterDescriptor,String>,ActionFrames> |
_actionFrames
A table of composited action sequences (these don't reference the actual image data directly and thus take up little memory). |
protected Map<String,ActionSequence> |
_actions
A table of our action sequences. |
protected static RuntimeAdjust.IntAdjust |
_cacheSize
Register our image cache size with the runtime adjustments framework. |
protected Throttle |
_cacheStatThrottle
Throttle our cache status logging to once every 30 seconds. |
protected Class<? extends CharacterSprite> |
_charClass
The character class to be created. |
protected ComponentRepository |
_crepo
The component repository. |
protected LRUHashMap<CompositedActionFrames.CompositedFramesKey,CompositedMultiFrameImage> |
_frameCache
A cache of composited animation frames. |
protected ImageManager |
_imgr
The image manager with whom we interact. |
protected static int |
_runCacheSize
Cache size to be used in this run. |
| Fields inherited from interface com.threerings.util.DirectionCodes |
|---|
CARDINAL_DIRECTIONS, CCW, CW, DIRECTION_COUNT, DOWN, EAST, EASTNORTHEAST, EASTSOUTHEAST, FINE_DIRECTION_COUNT, HORIZONTAL, LEFT, NONE, NORTH, NORTHEAST, NORTHNORTHEAST, NORTHNORTHWEST, NORTHWEST, RIGHT, SOUTH, SOUTHEAST, SOUTHSOUTHEAST, SOUTHSOUTHWEST, SOUTHWEST, UP, VERTICAL, WEST, WESTNORTHWEST, WESTSOUTHWEST |
| Constructor Summary | |
|---|---|
CharacterManager(ImageManager imgr,
ComponentRepository crepo)
Constructs the character manager. |
|
| Method Summary | ||
|---|---|---|
protected ActionFrames |
compositeMask(String action,
CharacterComponent ccomp,
ActionFrames cframes,
ArrayList<CharacterManager.TranslatedComponent> mcomps)
|
|
protected CompositedActionFrames.ComponentFrames |
compositeShadow(String action,
String sclass,
ArrayList<CharacterManager.TranslatedComponent> scomps)
|
|
protected ActionFrames |
createCompositeFrames(CharacterDescriptor descrip,
String action)
Generates the composited animation frames for the specified action for a character with the specified descriptor. |
|
ActionFrames |
getActionFrames(CharacterDescriptor descrip,
String action)
Obtains the composited animation frames for the specified action for a character with the specified descriptor. |
|
ActionSequence |
getActionSequence(String action)
Returns the action sequence instance with the specified name or null if no such sequence exists. |
|
CharacterSprite |
getCharacter(CharacterDescriptor desc)
Returns a CharacterSprite representing the character
described by the given CharacterDescriptor, or
null if an error occurs. |
|
|
getCharacter(CharacterDescriptor desc,
Class<T> charClass)
Returns a CharacterSprite representing the character
described by the given CharacterDescriptor, or
null if an error occurs. |
|
ComponentRepository |
getComponentRepository()
Returns the component repository being used by this manager. |
|
protected long |
getEstimatedCacheMemoryUsage()
Returns the estimated memory usage in bytes for all images currently cached by the cached action frames. |
|
void |
resolveActionSequence(CharacterDescriptor desc,
String action)
Informs the character manager that the action sequence for the given character descriptor is likely to be needed in the near future and so any efforts that can be made to load it into the action sequence cache in advance should be undertaken. |
|
void |
setActionCache(ActionCache cache)
Instructs the character manager to use the provided cache for composited action animations. |
|
static void |
setCacheSize(int cacheKilobytes)
Sets the size of the cache used for composited animation frames. |
|
void |
setCharacterClass(Class<? extends CharacterSprite> charClass)
Instructs the character manager to construct instances of this derived class of CharacterSprite when creating new sprites. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected ImageManager _imgr
protected ComponentRepository _crepo
protected Map<String,ActionSequence> _actions
protected Map<Tuple<CharacterDescriptor,String>,ActionFrames> _actionFrames
protected LRUHashMap<CompositedActionFrames.CompositedFramesKey,CompositedMultiFrameImage> _frameCache
protected Class<? extends CharacterSprite> _charClass
protected ActionCache _acache
protected Throttle _cacheStatThrottle
protected static RuntimeAdjust.IntAdjust _cacheSize
protected static int _runCacheSize
| Constructor Detail |
|---|
public CharacterManager(ImageManager imgr,
ComponentRepository crepo)
| Method Detail |
|---|
public static void setCacheSize(int cacheKilobytes)
public ComponentRepository getComponentRepository()
public void setCharacterClass(Class<? extends CharacterSprite> charClass)
CharacterSprite when creating new sprites.
IllegalArgumentException - thrown if the supplied class
does not derive from CharacterSprite.public void setActionCache(ActionCache cache)
public CharacterSprite getCharacter(CharacterDescriptor desc)
CharacterSprite representing the character
described by the given CharacterDescriptor, or
null if an error occurs.
desc - the character descriptor.
public <T extends CharacterSprite> T getCharacter(CharacterDescriptor desc,
Class<T> charClass)
CharacterSprite representing the character
described by the given CharacterDescriptor, or
null if an error occurs.
desc - the character descriptor.charClass - the CharacterSprite derived class that
should be instantiated instead of the configured default (which is
set via setCharacterClass(java.lang.Class extends com.threerings.cast.CharacterSprite>)).
public ActionFrames getActionFrames(CharacterDescriptor descrip,
String action)
throws NoSuchComponentException
NoSuchComponentException - thrown if any of the components in
the supplied descriptor do not exist.
IllegalArgumentException - thrown if any of the components
referenced in the descriptor do not support the specified action.
public void resolveActionSequence(CharacterDescriptor desc,
String action)
This will eventually be revamped to spiffily load action sequences in the background.
public ActionSequence getActionSequence(String action)
protected long getEstimatedCacheMemoryUsage()
protected ActionFrames createCompositeFrames(CharacterDescriptor descrip,
String action)
throws NoSuchComponentException
NoSuchComponentException - thrown if any of the components
in the supplied descriptor do not exist.
IllegalArgumentException - thrown if any of the components
referenced in the descriptor do not support the specified action.
protected CompositedActionFrames.ComponentFrames compositeShadow(String action,
String sclass,
ArrayList<CharacterManager.TranslatedComponent> scomps)
protected ActionFrames compositeMask(String action,
CharacterComponent ccomp,
ActionFrames cframes,
ArrayList<CharacterManager.TranslatedComponent> mcomps)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||