Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static const DEFAULT:uint = 0;
- public static const IDLE:uint = 0;
- public static const WALKING:uint = 1;
- /**
- * Read sprites for versions 10.57.
- */
- public static function readSprites(thing:ThingType, input:IDataInput):Boolean
- {
- var isOutfit:Boolean = (thing.category == ThingCategory.OUTFIT);
- var groupCount:uint = isOutfit ? input.readUnsignedByte() : 1;
- for (var k:uint = 0; k < groupCount; k++)
- {
- var groupType:uint = isOutfit ? input.readUnsignedByte() : DEFAULT;
- var frameGroup:FrameGroup = new FrameGroup();
- frameGroup.width = input.readUnsignedByte();
- frameGroup.height = input.readUnsignedByte();
- if (frameGroup.width > 1 || frameGroup.height > 1)
- frameGroup.exactSize = input.readUnsignedByte();
- else
- frameGroup.exactSize = Sprite.DEFAULT_SIZE;
- frameGroup.layers = input.readUnsignedByte();
- frameGroup.patternX = input.readUnsignedByte();
- frameGroup.patternY = input.readUnsignedByte();
- frameGroup.patternZ = input.readUnsignedByte();
- frameGroup.frames = input.readUnsignedByte();
- var i:uint = 0;
- if (frameGroup.frames > 1)
- {
- frameGroup.isAnimation = true;
- var animationMode:uint = input.readUnsignedByte();
- var frameStrategy:int = input.readInt();
- var startFrame:int = input.readByte();
- var frameDurations:Vector.<FrameDuration> = new Vector.<FrameDuration>(frameGroup.frames, true);
- for (i = 0; i < frameGroup.frames; i++)
- {
- var minimum:uint = input.readUnsignedInt();
- var maximum:uint = input.readUnsignedInt();
- frameDurations[i] = new FrameDuration(minimum, maximum);
- }
- frameGroup.animator = Animator.create(frameGroup.frames,
- startFrame,
- frameStrategy,
- animationMode,
- frameDurations);
- }
- var totalSprites:uint = frameGroup.getTotalSprites(); // width * height * layers * patternX * patternY * patternZ * frames
- if (totalSprites > 4096)
- throw new Error("A thing type has more than 4096 sprites.");
- frameGroup.spriteIndex = new Vector.<uint>(totalSprites, true);
- for (i = 0; i < totalSprites; i++)
- frameGroup.spriteIndex[i] = input.readUnsignedInt();
- var hasIdle:Boolean = (thing.frameGroups[IDLE] !== undefined);
- if (groupType == WALKING && (!hasIdle || hasIdle && thing.frameGroups[IDLE].frames == 0))
- {
- thing.frameGroups[IDLE] = frameGroup;
- }
- thing.frameGroups[groupType] = frameGroup;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement