protected virtual void DoRead(StateBinaryReader reader, VehicleSchedule schedule)
        {
            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                int      taskIndex = reader.ReadInt();
                RootTask task      = schedule.GetTasks()[taskIndex];
                _data.Add(task, DurationDataSet.Read(reader));
            }
        }
示例#2
0
        internal void Read(StateBinaryReader reader)
        {
            _connectedBuildings.Clear();
            _additionalDemands.Clear();
            _connectedStations.Clear();

            if (ScheduleStopwatch.GetSchemaVersion(typeof(StationDemandManager)) >= 3)
            {
                int count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    VehicleStation station = reader.ReadBuilding <VehicleStation>();
                    UniqueList <IStorageNetworkNode> demandList = null;
                    int countList = reader.ReadInt();
                    if (countList > 0 && station != null)
                    {
                        demandList = GetOrCreateDemandsList(station);
                    }

                    for (int j = 0; j < countList; j++)
                    {
                        IStorageNetworkNode node = reader.ReadBuilding <Building>() as IStorageNetworkNode;
                        if (demandList != null && node != null)
                        {
                            demandList.Add(node);
                            _connectedBuildings.Add(node.Building);
                        }
                    }
                }

                count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    VehicleStation station = reader.ReadBuilding <VehicleStation>();
                    UniqueList <VehicleStation> stationList = null;
                    int countList = reader.ReadInt();
                    if (countList > 0 && station != null)
                    {
                        stationList = GetOrCreateConnectedStationsList(station);
                    }

                    for (int j = 0; j < countList; j++)
                    {
                        VehicleStation connStation = reader.ReadBuilding <VehicleStation>();
                        if (stationList != null && connStation != null)
                        {
                            stationList.Add(connStation);
                            _connectedBuildings.Add(connStation);
                        }
                    }
                }
            }
        }
        internal void Read(StateBinaryReader reader)
        {
            _vehiclesData.Clear();
            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                int     vehicleId = reader.ReadInt();
                Vehicle vehicle   = LazyManager <VehicleManager> .Current.FindById(vehicleId);

                _vehiclesData.Add(vehicle, VehicleScheduleData.Read(reader, vehicle));
            }
        }
示例#4
0
        internal static DurationDataSet Read(StateBinaryReader reader)
        {
            DurationDataSet result = new DurationDataSet();
            int             count  = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                TimeSpan span = new TimeSpan(reader.ReadLong());
                result._durationData.Put(span);
                result._runningSum += span;
            }

            result._totalCount = reader.ReadInt();
            result._totalSum   = new TimeSpan(reader.ReadLong());

            return(result);
        }
            internal static Measurement Read(StateBinaryReader reader, VehicleSchedule schedule, VehicleScheduleData data)
            {
                RootTask    task   = schedule.GetTasks()[reader.ReadInt()];
                Measurement result = MeasurementSurrogate.Read(reader, data, task);

                result.DoRead(reader, schedule, data);
                return(result);
            }
示例#6
0
        protected override void DoRead(StateBinaryReader reader, VehicleSchedule schedule)
        {
            base.DoRead(reader, schedule);
            if (ScheduleStopwatch.GetSchemaVersion(typeof(TaskDurationDataSet)) >= 2)
            {
                int count = reader.ReadInt();

                for (int i = 0; i < count; i++)
                {
                    int   taskIndex = reader.ReadInt();
                    float value     = reader.ReadFloat();
                    if (taskIndex > -1)
                    {
                        _distanceData.Add(schedule.GetTasks()[taskIndex], value);
                    }
                    else
                    {
                        ScheduleStopwatch.logger.Log(UnityEngine.LogType.Warning, "RootTask index = -1");
                    }
                }
            }
        }