public static FrameGroup Serialize(ThingCategory category, ref Net.InputMessage binaryReader) { FrameGroup frameGroup = new FrameGroup(); frameGroup.Width = binaryReader.GetU8(); frameGroup.Height = binaryReader.GetU8(); if (frameGroup.Width > 1 || frameGroup.Height > 1) { frameGroup.ExactSize = binaryReader.GetU8(); } else { frameGroup.ExactSize = 32; } frameGroup.Layers = binaryReader.GetU8(); frameGroup.PatternWidth = binaryReader.GetU8(); frameGroup.PatternHeight = binaryReader.GetU8(); frameGroup.PatternDepth = binaryReader.GetU8(); frameGroup.Phases = binaryReader.GetU8(); if (frameGroup.Phases > 1) { frameGroup.Animator = FrameGroupAnimator.Serialize(frameGroup.Phases, ref binaryReader); } int totalSprites = frameGroup.Width * frameGroup.Height * frameGroup.Layers * frameGroup.PatternWidth * frameGroup.PatternHeight * frameGroup.PatternDepth * frameGroup.Phases; for (int j = 0; j < totalSprites; j++) { frameGroup.Sprites.Add(binaryReader.GetU32()); } return(frameGroup); }
public void Unserialize(Net.InputMessage binaryReader, int clientVersion) { Width = binaryReader.GetU8(); Height = binaryReader.GetU8(); if (Width > 1 || Height > 1) { ExactSize = binaryReader.GetU8(); } else { ExactSize = 32; } Layers = binaryReader.GetU8(); PatternWidth = binaryReader.GetU8(); PatternHeight = binaryReader.GetU8(); PatternDepth = clientVersion >= 755 ? binaryReader.GetU8() : (byte)1; Phases = binaryReader.GetU8(); if (Phases > 1 && clientVersion >= 1050) { Animator = new FrameGroupAnimator(); Animator.Unserialize(Phases, binaryReader); } int totalSprites = Width * Height * Layers * PatternWidth * PatternHeight * PatternDepth * Phases; for (int j = 0; j < totalSprites; j++) { Sprites.Add(clientVersion >= 960 ? binaryReader.GetU32() : binaryReader.GetU16()); } }
public void Unserialize(byte animationPhases, Net.InputMessage binaryReader) { AnimationPhases = animationPhases; Async = binaryReader.GetU8() == 0; LoopCount = binaryReader.GetS32(); StartPhase = binaryReader.GetS8(); for (int i = 0; i < animationPhases; i++) { var duration = new FrameGroupDuration(); duration.Minimum = binaryReader.GetS32(); duration.Maximum = binaryReader.GetS32(); FrameGroupDurations.Add(duration); } }
public static FrameGroupAnimator Serialize(byte animationPhases, ref Net.InputMessage binaryReader) { FrameGroupAnimator frameGroupAnimator = new FrameGroupAnimator(); frameGroupAnimator.AnimationPhases = animationPhases; frameGroupAnimator.Async = binaryReader.GetU8() == 0; frameGroupAnimator.LoopCount = binaryReader.GetS32(); frameGroupAnimator.StartPhase = binaryReader.GetS8(); for (int i = 0; i < animationPhases; i++) { FrameGroupDuration duration = new FrameGroupDuration(); duration.Minimum = (int)binaryReader.GetU32(); duration.Maximum = (int)binaryReader.GetU32(); frameGroupAnimator.FrameGroupDurations.Add(duration); } return(frameGroupAnimator); }
public ContentSprites(byte[] buffer) { m_BinaryReader = new Net.InputMessage(buffer); }
public static ThingType Serialize(ushort id, ThingCategory category, ref Net.InputMessage binaryReader) { ThingType type = new ThingType() { ID = id, Category = category }; int count = 0, attr = -1; bool done = false; for (int i = 0; i < DatAttributes.LastAttr; ++i) { count++; attr = binaryReader.GetU8(); if (attr == DatAttributes.LastAttr) { done = true; break; } switch (attr) { case DatAttributes.Ground: case DatAttributes.Writable: case DatAttributes.WritableOnce: case DatAttributes.MinimapColor: case DatAttributes.LensHelp: case DatAttributes.Cloth: case DatAttributes.DefaultAction: type.Attributes[(byte)attr] = binaryReader.GetU16(); break; case DatAttributes.GroundBorder: case DatAttributes.OnBottom: case DatAttributes.OnTop: case DatAttributes.Container: case DatAttributes.Stackable: case DatAttributes.ForceUse: case DatAttributes.MultiUse: case DatAttributes.FluidContainer: case DatAttributes.Splash: case DatAttributes.NotWalkable: case DatAttributes.NotMoveable: case DatAttributes.BlockProjectile: case DatAttributes.NotPathable: case DatAttributes.NoMoveAnimation: case DatAttributes.Pickupable: case DatAttributes.Hangable: case DatAttributes.HookSouth: case DatAttributes.HookEast: case DatAttributes.Rotateable: case DatAttributes.DontHide: case DatAttributes.Translucent: case DatAttributes.LyingCorpse: case DatAttributes.AnimateAlways: case DatAttributes.FullGround: case DatAttributes.Look: case DatAttributes.Wrapable: case DatAttributes.Unwrapable: case DatAttributes.TopEffect: case DatAttributes.Usable: type.Attributes[(byte)attr] = true; break; case DatAttributes.Light: type.Attributes[(byte)attr] = new LightInfo() { intensity = binaryReader.GetU16(), color = binaryReader.GetU16() }; break; case DatAttributes.Displacement: type.Attributes[(byte)attr] = new Vector2Int { x = binaryReader.GetU16(), y = binaryReader.GetU16() }; break; case DatAttributes.Elevation: type.Elevation = binaryReader.GetU16(); type.Attributes[(byte)attr] = type.Elevation; break; case DatAttributes.Market: type.Attributes[(byte)attr] = new MarketData() { category = binaryReader.GetU16(), tradeAs = binaryReader.GetU16(), showAs = binaryReader.GetU16(), name = binaryReader.GetString(), restrictVocation = binaryReader.GetU16(), requiredLevel = binaryReader.GetU16(), }; break; default: throw new System.Exception("Unhandled DatAttribute [" + attr + "]."); } } if (!done) { throw new System.Exception("Couldn't parse thing [category: " + category + ", ID: " + id + "]."); } byte groupCount = (category == ThingCategory.Creature) ? binaryReader.GetU8() : (byte)1U; for (int i = 0; i < groupCount; i++) { FrameGroupType groupType = FrameGroupType.Default; if (category == ThingCategory.Creature) { groupType = (FrameGroupType)binaryReader.GetU8(); } type.FrameGroups[groupType] = FrameGroup.Serialize(category, ref binaryReader); } return(type); }
public ContentData(byte[] buffer, int clientVersion) { m_BinaryReader = new Net.InputMessage(buffer); m_ClientVersion = clientVersion; }
public ContentSprites(byte[] buffer, int clientVersion, bool alpha = false) { m_BinaryReader = new Net.InputMessage(buffer); m_ClientVersion = clientVersion; m_UseAlpha = alpha; }