public static void SerializeLegacy(ThingType thingType, Net.OutputMessage binaryWriter, int startPhase, int phasesLimit) { binaryWriter.AddU8(1); binaryWriter.AddS32(thingType.HasAttribute(AttributesUniform.AnimateAlways) || thingType.Category == ThingCategory.Item ? 0 : 1); binaryWriter.AddU8(0); int duration; if (thingType.Category == ThingCategory.Effect) { duration = 75; } else { duration = phasesLimit > 0 ? 1000 / phasesLimit : 40; } for (int i = 0; i < phasesLimit; i++) { binaryWriter.AddS32(duration); // force legacy animation binaryWriter.AddS32(duration); } }
public void Serialize(Net.OutputMessage binaryWriter, int startPhase, int phasesLimit) { binaryWriter.AddU8(Async ? (byte)1 : (byte)0); binaryWriter.AddS32(LoopCount); int minPhase = startPhase; int maxPhase = startPhase = phasesLimit; if (StartPhase > 0 && (StartPhase < minPhase || StartPhase > maxPhase)) { binaryWriter.AddS8((sbyte)minPhase); } else { binaryWriter.AddS8(StartPhase); } for (int i = 0; i < phasesLimit; i++) { var frameGroupDuration = FrameGroupDurations[startPhase + i]; binaryWriter.AddS32(frameGroupDuration.Minimum); binaryWriter.AddS32(frameGroupDuration.Maximum); } }