private static void AddTruckIntoWorld(IceCreamTruckManager ths, Lot lot)
        {
            IceCreamTruck car = GlobalFunctions.CreateObjectOutOfWorld("carTruckIceCream", ProductVersion.EP5, "Sims3.Gameplay.Objects.Vehicles.IceCreamTruck", null) as IceCreamTruck;
            if (car != null)
            {
                Vector3[] vectorArray;
                Quaternion[] quaternionArray;

                /*
                Lot lot = null;
                foreach (Lot lot2 in LotManager.AllLots)
                {
                    if (!lot2.IsWorldLot)
                    {
                        lot = lot2;
                        break;
                    }
                }
                */

                Matrix44 mat = new Matrix44();
                car.StreetParkingBeingUsed = lot.StreetParking;
                car.StreetParkingBeingUsed.GetParkingSpotForCar(car, ref mat);
                if (World.FindPlaceOnRoadOffScreen(car.Proxy, mat.pos.V3, FindPlaceOnRoadOption.Road, 150f, out vectorArray, out quaternionArray))
                {
                    car.PlaceAt(vectorArray[0x0], mat.at.V3, null);
                    car.BeginRoute(lot);
                    car.AddMapTags();
                    ths.mIceCreamTrucks.Add(car);
                }
                else
                {
                    car.Destroy();
                }
            }
        }
            public override void Import(BinaryReader Reader)
            {
                base.Import(Reader);
                
                PropHash = Reader.ReadUInt32();
                ObjectHash = Reader.ReadUInt32();
                SlotHash = Reader.ReadUInt32();
                Unknown = Reader.ReadUInt32();

                Matrix = new Matrix44(Reader);
            }
Example #3
0
 public static Quaternion MakeFromMatrix44(Matrix44 xf)
 {
     float x = 0f;
     float y = 0f;
     float z = 0f;
     float num = 0f;
     float num2 = xf.right.x + xf.up.y + xf.at.z;
     if (num2 >= 0f)
     {
         float num3 = (float)Math.Sqrt((double)(num2 + 1f));
         num = 0.5f * num3;
         num3 = 0.5f / num3;
         x = (xf.up.z - xf.at.y) * num3;
         y = (xf.at.x - xf.right.z) * num3;
         z = (xf.right.y - xf.up.x) * num3;
     }
     else
     {
         int num4 = 0;
         if (xf.up.y > xf.right.x)
         {
             num4 = 1;
             if (xf.at.z > xf.up.y)
             {
                 num4 = 2;
             }
         }
         else
         {
             if (xf.at.z > xf.right.x)
             {
                 num4 = 2;
             }
         }
         switch (num4)
         {
             case 0:
                 {
                     float num3 = (float)Math.Sqrt((double)(xf.right.x - (xf.up.y + xf.at.z) + 1f));
                     x = 0.5f * num3;
                     num3 = 0.5f / num3;
                     y = (xf.up.x + xf.right.y) * num3;
                     z = (xf.right.z + xf.at.x) * num3;
                     num = (xf.up.z - xf.at.y) * num3;
                     break;
                 }
             case 1:
                 {
                     float num3 = (float)Math.Sqrt((double)(xf.up.y - (xf.at.z + xf.right.x) + 1f));
                     y = 0.5f * num3;
                     num3 = 0.5f / num3;
                     z = (xf.at.y + xf.up.z) * num3;
                     x = (xf.up.x + xf.right.y) * num3;
                     num = (xf.at.x - xf.right.z) * num3;
                     break;
                 }
             case 2:
                 {
                     float num3 = (float)Math.Sqrt((double)(xf.at.z - (xf.right.x + xf.up.y) + 1f));
                     z = 0.5f * num3;
                     num3 = 0.5f / num3;
                     x = (xf.right.z + xf.at.x) * num3;
                     y = (xf.at.y + xf.up.z) * num3;
                     num = (xf.right.y - xf.up.x) * num3;
                     break;
                 }
         }
     }
     return new Quaternion(x, y, z, num);
 }
Example #4
0
        protected void OneShotRouteToLot()
        {
            mTruck.RoutingComponent.ClearQueuedActions();

            bool flag = false;
            if (mTruck.mDestinationLot == null)
            {
                flag = true;
                List<Lot> randomList = new List<Lot>();
                Lot lotHome = null;
                Household activeHousehold = Household.ActiveHousehold;
                if (activeHousehold != null)
                {
                    lotHome = activeHousehold.LotHome;
                }

                Lot activeLot = LotManager.ActiveLot;
                foreach (Lot lot3 in LotManager.AllLots)
                {
                    if (((lot3.LotId != ulong.MaxValue) && (lot3 != activeLot)) && (lot3 != lotHome))
                    {
                        randomList.Add(lot3);
                    }
                }

                if (randomList.Count > 0x0)
                {
                    mTruck.mDestinationLot = RandomUtil.GetRandomObjectFromList<Lot>(randomList);
                }

                if (mTruck.mDestinationLot == null)
                {
                    mTruck.FadeOut(false, true);
                    mTruck.mRouteToLot = null;
                    return;
                }
            }

            ParkingSpace parent = mTruck.Parent as ParkingSpace;
            if (parent != null)
            {
                Matrix44 matrix = new Matrix44();
                mTruck.LotCurrent.StreetParking.GetParkingSpotForCar(mTruck, ref matrix);
                mTruck.PlaceAt(matrix.pos.V3, matrix.at.V3, null);
                mTruck.TruckOnRoad();
                parent.LotCurrent.StreetParking.FreeParkingSpotForCar(mTruck);
            }

            Matrix44 mat = new Matrix44();
            mTruck.mDestinationLot.StreetParking.GetParkingSpotForCar(mTruck, ref mat);
            Vector3 position = mTruck.Position;
            Route r = mTruck.CarRoutingComponent.CreateRoute();
            r.PlanToMatrixFromPoint(ref position, ref mat);
            if (!mTruck.DoRoute(r))
            {
                if (parent != null)
                {
                    parent.ParkVehicle(mTruck);
                }
                else
                {
                    flag = true;
                }
            }
            else if (parent != null)
            {
                parent.UnReserveSpot(mTruck);
            }

            mTruck.mDestinationLot.StreetParking.FreeParkingSpotForCar(mTruck);
            if (!flag)
            {
                ParkingSpace closestUnreservedParkingSpace = Vehicle.GetClosestUnreservedParkingSpace(mTruck.mDestinationLot.GetObjects<WideParkingSpace>(), mTruck);
                if (closestUnreservedParkingSpace != null)
                {
                    closestUnreservedParkingSpace.ParkVehicle(mTruck);
                    mTruck.TruckParked();
                }
                else if (Traffic.Settings.mRequireFoodParkingSpace)
                {
                    mTruck.FadeOut(false, true);
                }
                else
                {
                    mTruck.TruckParked();
                    mTruck.SetGeometryState("openWithLights");
                }
            }
            else if (Traffic.Settings.mRequireFoodParkingSpace)
            {
                mTruck.FadeOut(false, true);
            }
            else
            {
                mTruck.TruckParked();
                mTruck.SetGeometryState("openWithLights");                
            }

            AddMapTags(mTruck);

            mTruck.mDestinationLot = null;
            mTruck.mRouteToLot = null;
        }
Example #5
0
        protected override bool OnPerform()
        {
            string msg = "OnPerform" + Common.NewLine;

            try
            {
                if ((TrafficManager.Singleton == null) || (LotManager.sLots == null))
                {
                    return true;
                }

                Simulator.DestroyObject(TrafficManager.Singleton.mUpdateTrafficTask);
                TrafficManager.Singleton.mUpdateTrafficTask = ObjectGuid.InvalidObjectGuid;

                while (!TrafficManager.Enabled)
                {
                    FoodTruckManagerEx.Update();
                    SpeedTrap.Sleep((uint)SimClock.ConvertToTicks(RandomUtil.GetFloat(TrafficManager.kTrafficCheckTime[0x0], TrafficManager.kTrafficCheckTime[0x1]), TimeUnit.Hours));
                }

                msg += "A";

                List<Lot> list = new List<Lot>();
                foreach (Lot lot in LotManager.AllLots)
                {
                    if (lot.StreetParking == null) continue;

                    if (lot.IsWorldLot) continue;

                    list.Add(lot);
                }

                if (TrafficManager.GeneratedTrafficTuning.sLotTuning == null) return true;

                msg += "B";

                PairedListDictionary<Type, int> dictionary = new PairedListDictionary<Type, int>();
                foreach (Type type in TrafficManager.GeneratedTrafficTuning.sLotTuning.Keys)
                {
                    if (!TrafficManager.Enabled)
                    {
                        break;
                    }

                    int[] carRange = TrafficManager.GeneratedTrafficTuning.GetCarRange(type);
                    if (carRange == null) continue;

                    if (Math.Max(carRange[0x0], carRange[0x1]) > 0x0)
                    {
                        msg += "C";

                        int numTaxis = RandomUtil.GetInt(carRange[0x0], carRange[0x1]);
                        foreach (Lot lot in list)
                        {
                            if (!TrafficManager.Enabled)
                            {
                                break;
                            }

                            int num2 = (int)Sims3.SimIFace.Queries.CountObjects(type, lot.LotId);
                            if (num2 > 0x0)
                            {
                                msg += "D";

                                PairedListDictionary<Type, int> dictionary2;
                                Type type2;
                                int num3 = 0x0;
                                if (TrafficManager.sGeneratedCarCount != null)
                                {
                                    TrafficManager.sGeneratedCarCount.TryGetValue(type.ToString(), out num3);
                                }

                                msg += "E";

                                if (!dictionary.ContainsKey(type))
                                {
                                    dictionary.Add(type, 0x0);
                                }

                                msg += "F";

                                (dictionary2 = dictionary)[type2 = type] = dictionary2[type2] + num2;
                                if (num3 < (numTaxis * dictionary[type]))
                                {
                                    msg += "G";

                                    CarNpcWithNoDriver car = GlobalFunctions.CreateObjectOutOfWorld("CarTaxiLightweight", ProductVersion.EP3) as CarNpcWithNoDriver;
                                    if (car != null)
                                    {
                                        Matrix44 mat = new Matrix44();
                                        if (lot.StreetParking.GetParkingSpotForCar(car, ref mat))
                                        {
                                            msg += "H";

                                            Vector3[] vectorArray;
                                            Quaternion[] quaternionArray;
                                            if (World.FindPlaceOnRoadOffScreen(car.Proxy, mat.pos.V3, FindPlaceOnRoadOption.Road, 100f, out vectorArray, out quaternionArray))
                                            {
                                                msg += "I";

                                                car.GeneratingClassName = type.ToString();
                                                car.PlaceAt(vectorArray[0x0], mat.at.V3, null);
                                                car.DriveAroundFor(RandomUtil.GetFloat(TrafficManager.kCarDriveAroundTimeRange[0x0], TrafficManager.kCarDriveAroundTimeRange[0x1]), TimeUnit.Hours);
                                            }
                                            else
                                            {
                                                car.Destroy();
                                            }

                                            msg += "J";

                                            lot.StreetParking.FreeParkingSpotForCar(car);
                                            SpeedTrap.Sleep((uint)RandomUtil.GetInt(TrafficManager.kAfterSpawnWaitTime[0x0], TrafficManager.kAfterSpawnWaitTime[0x1]));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                msg += "K";

                // Custom
                FoodTruckManagerEx.Update();

                msg += "L";

                uint tickCount = (uint)SimClock.ConvertToTicks(RandomUtil.GetFloat(TrafficManager.kTrafficCheckTime[0x0], TrafficManager.kTrafficCheckTime[0x1]), TimeUnit.Hours);
                SpeedTrap.Sleep(tickCount);
            }
            catch (Exception e)
            {
                Common.Exception(msg, e);
            }

            return true;
        }