コード例 #1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="TargetCitizenInfo"/> class.
            /// </summary>
            /// <param name="citizenId">The citizen identifier.</param>
            /// <param name="citizen">The citizen.</param>
            /// <param name="dispatcherType">Type of the dispatcher.</param>
            public TargetCitizenInfo(uint citizenId, ref Citizen citizen, Dispatcher.DispatcherTypes dispatcherType)
            {
                this.CitizenId = citizenId;
                this.VehicleId = 0;

                this.Update(ref citizen, dispatcherType);
            }
コード例 #2
0
        /// <summary>
        /// Deserializes the specified serialized data to this instance.
        /// </summary>
        /// <param name="serializedData">The serialized data.</param>
        /// <returns>
        /// The deserialization result.
        /// </returns>
        private SerializableSettings.DeserializationResult Deserialize(SerializableSettings.BinaryData serializedData)
        {
            if (serializedData == null || serializedData.Left == 0)
            {
                return(SerializableSettings.DeserializationResult.EndOfData);
            }

            serializedData.ResetLocalCheckSum();

            ulong version = serializedData.GetVersion();

            if (version > 0)
            {
                Log.Warning(this, "Deserialize", "Serialized data version too high!", version, 0);
                return(SerializableSettings.DeserializationResult.Error);
            }

            this.VehicleId                    = serializedData.GetUshort();
            this.targetBuildingId             = serializedData.GetUshort();
            this.dispatcherType               = serializedData.GetDispatcherType();
            this.checkFlags                   = serializedData.GetVehicleFlags();
            this.checkFlagPosition            = serializedData.GetVector3();
            this.checkFlagSinceFrame          = serializedData.GetUint();
            this.checkFlagSinceTime           = serializedData.GetDouble();
            this.confusedDeAssignedSinceFrame = serializedData.GetUint();
            this.confusedSinceFrame           = serializedData.GetUint();
            this.confusedSinceTime            = serializedData.GetDouble();
            this.lostSinceFrame               = serializedData.GetUint();
            this.lostSinceTime                = serializedData.GetDouble();
            this.lostReason                   = serializedData.GetLostReason();

            serializedData.CheckLocalCheckSum();

            return(SerializableSettings.DeserializationResult.Success);
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ServiceBuildingInfo" /> class.
        /// </summary>
        /// <param name="buildingId">The building identifier.</param>
        /// <param name="building">The building.</param>
        /// <param name="dispatcherType">Type of the dispatcher.</param>
        public ServiceBuildingInfo(ushort buildingId, ref Building building, Dispatcher.DispatcherTypes dispatcherType)
        {
            this.BuildingId                      = buildingId;
            this.CurrentTargetDistance           = float.PositiveInfinity;
            this.CurrentTargetInDistrict         = false;
            this.CurrentTargetInRange            = true;
            this.CurrentTargetCapacityOverflow   = 0;
            this.CurrentTargetServiceProblemSize = 0;
            this.Range          = 0;
            this.Vehicles       = new Dictionary <ushort, ServiceVehicleInfo>();
            this.dispatcherType = dispatcherType;

            if (Global.Buildings.SerializedAutoEmptying != null)
            {
                this.IsAutoEmptying = Global.Buildings.SerializedAutoEmptying.Contains(buildingId);

                if (Log.LogALot && this.IsAutoEmptying)
                {
                    Log.Debug(this, "Construct", "SerializedAutoEmptying", buildingId, this.IsAutoEmptying);
                }
            }
            else if (Global.Buildings.EmptyingIsAutoEmptying)
            {
                this.IsAutoEmptying = (building.m_flags & Building.Flags.Downgrading) != Building.Flags.None;
            }
            else
            {
                this.IsAutoEmptying = false;
            }

            this.Initialize();

            this.Update(ref building);
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ServiceVehicleInfo" /> class.
        /// </summary>
        /// <param name="vehicleId">The vehicle identifier.</param>
        /// <param name="vehicle">The vehicle.</param>
        /// <param name="freeToCollect">If set to <c>true</c> the vehicle is free.</param>
        /// <param name="dispatcherType">Type of the dispatcher.</param>
        /// <param name="targetBuildingId">The target building identifier.</param>
        public ServiceVehicleInfo(ushort vehicleId, ref Vehicle vehicle, bool freeToCollect, Dispatcher.DispatcherTypes dispatcherType, ushort targetBuildingId = 0)
        {
            this.VehicleId      = vehicleId;
            this.dispatcherType = dispatcherType;
            this.LastAssigned   = 0;
            this.Target         = targetBuildingId;

            this.Update(ref vehicle, freeToCollect, false, false);
        }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ServiceVehicleInfo" /> class.
 /// </summary>
 /// <param name="vehicleId">The vehicle identifier.</param>
 /// <param name="vehicle">The vehicle.</param>
 /// <param name="dispatcherType">Type of the dispatcher.</param>
 /// <param name="targetBuildingId">The target building identifier.</param>
 public ServiceVehicleInfo(ushort vehicleId, ref Vehicle vehicle, Dispatcher.DispatcherTypes dispatcherType, ushort targetBuildingId)
 {
     this.VehicleId      = vehicleId;
     this.dispatcherType = dispatcherType;
     this.LastAssigned   = 0;
     this.LastSeen       = 0;
     this.FreeToCollect  = false;
     this.Target         = targetBuildingId;
 }
コード例 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TargetBuildingInfo" /> class.
        /// </summary>
        /// <param name="buildingId">The building identifier.</param>
        /// <param name="building">The building.</param>
        /// <param name="dispatcherType">Type of the dispatcher.</param>
        /// <param name="demand">The demand.</param>
        public TargetBuildingInfo(ushort buildingId, ref Building building, Dispatcher.DispatcherTypes dispatcherType, ServiceDemand demand)
        {
            this.BuildingId     = buildingId;
            this.dispatcherType = dispatcherType;

            if (this.dispatcherType == Dispatcher.DispatcherTypes.AmbulanceDispatcher)
            {
                this.citizens = new Dictionary <uint, TargetCitizenInfo>();
            }

            this.Update(ref building, demand);
        }
コード例 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ServiceVehicleInfo" /> class.
        /// </summary>
        /// <param name="vehicleId">The vehicle identifier.</param>
        /// <param name="vehicle">The vehicle.</param>
        /// <param name="freeToCollect">If set to <c>true</c> the vehicle is free.</param>
        /// <param name="dispatcherType">Type of the dispatcher.</param>
        /// <param name="targetBuildingId">The target building identifier.</param>
        public ServiceVehicleInfo(ushort vehicleId, ref Vehicle vehicle, bool freeToCollect, Dispatcher.DispatcherTypes dispatcherType, ushort targetBuildingId = 0)
        {
            this.VehicleId = vehicleId;
            this.dispatcherType = dispatcherType;
            this.LastAssigned = 0;
            this.Target = targetBuildingId;

            this.Update(ref vehicle, freeToCollect, false, false);

            ////if (Log.LogALot)
            ////{
            ////    Log.DevDebug(this, "ServiceVehicleInfo", vehicleId, vehicle.m_targetBuilding, this.Target, targetBuildingId);
            ////}
        }
コード例 #8
0
            /// <summary>
            /// Updates the specified citizen.
            /// </summary>
            /// <param name="citizen">The citizen.</param>
            /// <param name="dispatcherType">Type of the dispatcher.</param>
            public void Update(ref Citizen citizen, Dispatcher.DispatcherTypes dispatcherType)
            {
                if (dispatcherType == Dispatcher.DispatcherTypes.AmbulanceDispatcher)
                {
                    this.ProblemSize = ((int)citizen.m_health) << 8;
                }

                if (citizen.m_vehicle != this.VehicleId)
                {
                    this.VehicleId = 0;
                }

                this.lastUpdateStamp = Global.CurrentFrame;
            }
コード例 #9
0
        /// <summary>
        /// Gets the service settings.
        /// </summary>
        /// <param name="dispatcherType">Type of the dispatcher.</param>
        /// <returns>The service settings.</returns>
        public static StandardServiceSettings GetServiceSettings(Dispatcher.DispatcherTypes dispatcherType)
        {
            switch (dispatcherType)
            {
            case Dispatcher.DispatcherTypes.GarbageTruckDispatcher:
                return(Global.Settings.Garbage);

            case Dispatcher.DispatcherTypes.HearseDispatcher:
                return(Global.Settings.DeathCare);

            case Dispatcher.DispatcherTypes.AmbulanceDispatcher:
                return(Global.Settings.HealthCare);

            case Dispatcher.DispatcherTypes.None:
                throw new ArgumentNullException("Dispathcher type 'None' can not have settings");

            default:
                throw new ArgumentException("No settings for dispatcher type: " + dispatcherType.ToString());
            }
        }
コード例 #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StuckVehicleInfo"/> class.
        /// </summary>
        /// <param name="vehicleId">The vehicle identifier.</param>
        /// <param name="vehicle">The vehicle.</param>
        public StuckVehicleInfo(ushort vehicleId, ref Vehicle vehicle)
        {
            this.VehicleId = vehicleId;

            if (vehicle.m_leadingVehicle == 0)
            {
                this.dispatcherType = Dispatcher.GetDispatcherType(ref vehicle);
            }
            else
            {
                try
                {
                    this.dispatcherType = Dispatcher.GetDispatcherType(ref Singleton <VehicleManager> .instance.m_vehicles.m_buffer[vehicleId]);
                }
                catch
                {
                    this.dispatcherType = Dispatcher.DispatcherTypes.None;
                }
            }

            this.Update(ref vehicle);
        }
コード例 #11
0
 /// <summary>
 /// Adds the specified data.
 /// </summary>
 /// <param name="data">The data.</param>
 public void Add(Dispatcher.DispatcherTypes data)
 {
     this.Add((byte)data);
 }
コード例 #12
0
        /// <summary>
        /// Creates the specified service building.
        /// </summary>
        /// <param name="serviceBuilding">The service building.</param>
        /// <param name="material">The material.</param>
        /// <param name="dispatcherType">Type of the dispatcher.</param>
        /// <param name="targetBuildingId">The target building identifier.</param>
        /// <param name="targetCitizenId">The target citizen identifier.</param>
        /// <returns>
        /// The service vehicle.
        /// </returns>
        public static ServiceVehicleInfo Create(ServiceBuildingInfo serviceBuilding, TransferManager.TransferReason material, Dispatcher.DispatcherTypes dispatcherType, ushort targetBuildingId, uint targetCitizenId)
        {
            ushort      vehicleId = 0;
            VehicleInfo info      = null;

            if (Global.Settings.CreationCompatibilityMode == ServiceDispatcherSettings.ModCompatibilityMode.UseCustomCode)
            {
                info = VehicleHelper.CreateServiceVehicle(serviceBuilding.BuildingId, material, targetBuildingId, targetCitizenId, out vehicleId);
            }
            else
            {
                info = BuildingHelper.StartTransfer(serviceBuilding.BuildingId, material, targetBuildingId, targetCitizenId, out vehicleId);
            }

            if (info == null)
            {
                return(null);
            }

            VehicleManager manager = Singleton <VehicleManager> .instance;

            return(new ServiceVehicleInfo(vehicleId, ref manager.m_vehicles.m_buffer[vehicleId], targetBuildingId == 0, dispatcherType, targetBuildingId));
        }
コード例 #13
0
 /// <summary>
 /// Determines whether this dispatcher type is dispatchers responsibility.
 /// </summary>
 /// <param name="dispatcherType">Type of the dispatcher.</param>
 /// <returns>
 ///   <c>true</c> if dispatchers responsibility; otherwise, <c>false</c>.
 /// </returns>
 public static bool IsDispatchersResponsibility(Dispatcher.DispatcherTypes dispatcherType)
 {
     return((Global.Settings.DeathCare.DispatchVehicles && Global.HearseDispatcher != null && dispatcherType == Dispatcher.DispatcherTypes.HearseDispatcher) ||
            (Global.Settings.Garbage.DispatchVehicles && Global.GarbageTruckDispatcher != null && dispatcherType == Dispatcher.DispatcherTypes.GarbageTruckDispatcher) ||
            (Global.Settings.HealthCare.DispatchVehicles && Global.AmbulanceDispatcher != null && dispatcherType == Dispatcher.DispatcherTypes.AmbulanceDispatcher));
 }
コード例 #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StuckVehicleInfo"/> class.
        /// </summary>
        /// <param name="vehicleId">The vehicle identifier.</param>
        /// <param name="vehicle">The vehicle.</param>
        public StuckVehicleInfo(ushort vehicleId, ref Vehicle vehicle)
        {
            this.vehicleId = vehicleId;
            this.dispatcherType = Dispatcher.GetDispatcherType(ref vehicle);

            this.Update(ref vehicle);
        }