public LinearGradientPaletteEntry(FieldList source) : base(PaletteEntryType.LinearGradient) { PairedList <ByteField, Int32Field> searchResults = source.GetPairedItems <ByteField, Int32Field>(DefAgentFieldID.GradientKeyPosition, DefAgentFieldID.GradientKeyColour); foreach (Pair <ByteField, Int32Field> res in searchResults) { Colours.Add(new Pair <byte, Color>(res.First.Data, DataHelper.IntToColour(res.Second.Data))); } IsHorizontal = ((UIFlowDirection)(source[DefAgentFieldID.FlowDirection].AsByte() ?? (byte)UIFlowDirection.Right) == UIFlowDirection.Right); }
public ColourSequencePaletteEntry(FieldList source) : base(PaletteEntryType.ColourSequence) { PairedList <ByteField, Int32Field> searchResults = source.GetPairedItems <ByteField, Int32Field>(DefAgentFieldID.GradientKeyPosition, DefAgentFieldID.GradientKeyColour); foreach (Pair <ByteField, Int32Field> res in searchResults) { Colours.Add(new Pair <byte, Color>(res.First.Data, DataHelper.IntToColour(res.Second.Data))); } Period = source[DefAgentFieldID.TimePeriod].AsShort() ?? 0; IsLoop = source[DefAgentFieldID.Loop].AsBoolean() ?? false; }
public PairedList <T, U> GetPairedItemsOrNull <T, U>(short firstID, short secondID) where T : class, IFieldBase where U : class, IFieldBase { PairedList <T, U> res = new PairedList <T, U>(); for (int i = 0; i < fields.Count; i++) { if ((fields[i].FieldID == firstID) && (fields[i] is T)) { if (((i + 1) < fields.Count) && ((fields[i + 1].FieldID == secondID) && (fields[i + 1] is U))) { res.Add(new Pair <T, U>((T)fields[i], (U)fields[i + 1])); i++; } else { res.Add(new Pair <T, U>((T)fields[i], null)); } } } return(res); }