Beispiel #1
0
        /// <summary>
        /// Creates a record of the current state, taking the latest record (if
        /// any) into account. If a latest state is given, this function will
        /// return null if there is no change between the current and latest.
        /// </summary>
        internal static RailStateRecord CreateRecord(
            Tick tick,
            RailState current,
            RailStateRecord latestRecord = null)
        {
            if (latestRecord != null)
            {
                RailState latest       = latestRecord.State;
                bool      shouldReturn =
                    (current.CompareMutableData(latest) > 0) ||
                    (current.IsControllerDataEqual(latest) == false);
                if (shouldReturn == false)
                {
                    return(null);
                }
            }

            RailStateRecord record = RailResource.Instance.CreateRecord();

            record.Overwrite(tick, current);
            return(record);
        }