示例#1
0
        private void FindRandomVisitPlace(TAI instance, uint citizenId, ref TCitizen citizen, int doNothingProbability, ushort currentBuilding)
        {
            int targetType = touristAI.GetRandomTargetType(instance, doNothingProbability);

            if (targetType == 1)
            {
                Log.Debug(TimeInfo.Now, $"Tourist {GetCitizenDesc(citizenId, ref citizen)} decides to leave the city");
                touristAI.FindVisitPlace(instance, citizenId, currentBuilding, touristAI.GetLeavingReason(instance, citizenId, ref citizen));
                return;
            }

            uint goOutChance = spareTimeBehavior.GetGoOutChance(
                CitizenProxy.GetAge(ref citizen),
                WorkShift.Unemployed,
                CitizenProxy.HasFlags(ref citizen, Citizen.Flags.NeedGoods));

            if (!Random.ShouldOccur(goOutChance) || IsBadWeather())
            {
                FindHotel(instance, citizenId, ref citizen);
                return;
            }

            switch (targetType)
            {
            case 2:
                touristAI.FindVisitPlace(instance, citizenId, currentBuilding, touristAI.GetShoppingReason(instance));
                Log.Debug(TimeInfo.Now, $"Tourist {GetCitizenDesc(citizenId, ref citizen)} stays in the city, goes shopping");
                break;

            case 3:
                Log.Debug(TimeInfo.Now, $"Tourist {GetCitizenDesc(citizenId, ref citizen)} stays in the city, goes relaxing");
                touristAI.FindVisitPlace(instance, citizenId, currentBuilding, touristAI.GetEntertainmentReason(instance));
                break;
            }
        }
示例#2
0
        private void FindRandomVisitPlace(TAI instance, uint citizenId, ref TCitizen citizen, int doNothingProbability, ushort currentBuilding)
        {
            var target = (TouristTarget)touristAI.GetRandomTargetType(instance, doNothingProbability);

            target = AdjustTargetToTimeAndWeather(ref citizen, target);

            switch (target)
            {
            case TouristTarget.LeaveCity:
                Log.Debug(LogCategory.Movement, TimeInfo.Now, $"Tourist {GetCitizenDesc(citizenId, ref citizen)} decides to leave the city");
                touristAI.FindVisitPlace(instance, citizenId, currentBuilding, touristAI.GetLeavingReason(instance, citizenId, ref citizen));
                break;

            case TouristTarget.Shopping:
                touristAI.FindVisitPlace(instance, citizenId, currentBuilding, touristAI.GetShoppingReason(instance));
                Log.Debug(LogCategory.Movement, TimeInfo.Now, $"Tourist {GetCitizenDesc(citizenId, ref citizen)} stays in the city, goes shopping");
                break;

            case TouristTarget.Relaxing:
                Log.Debug(LogCategory.Movement, TimeInfo.Now, $"Tourist {GetCitizenDesc(citizenId, ref citizen)} stays in the city, goes relaxing");
                touristAI.FindVisitPlace(instance, citizenId, currentBuilding, touristAI.GetEntertainmentReason(instance));
                break;

            case TouristTarget.Party:
                ushort leisureBuilding = BuildingMgr.FindActiveBuilding(
                    currentBuilding,
                    LeisureSearchDistance,
                    ItemClass.Service.Commercial,
                    ItemClass.SubService.CommercialLeisure);
                if (leisureBuilding == 0)
                {
                    goto case TouristTarget.Hotel;
                }

                Log.Debug(LogCategory.Movement, TimeInfo.Now, $"Tourist {GetCitizenDesc(citizenId, ref citizen)} want to party in {leisureBuilding}");
                StartMovingToVisitBuilding(instance, citizenId, ref citizen, currentBuilding, leisureBuilding);
                break;

            case TouristTarget.Hotel:
                ushort hotel = FindHotel(currentBuilding);
                if (hotel == 0)
                {
                    goto case TouristTarget.LeaveCity;
                }

                Log.Debug(LogCategory.Movement, TimeInfo.Now, $"Tourist {GetCitizenDesc(citizenId, ref citizen)} want to stay in a hotel {hotel}");
                StartMovingToVisitBuilding(instance, citizenId, ref citizen, currentBuilding, hotel);
                break;
            }
        }
示例#3
0
        private void FindRandomVisitPlace(TAI instance, uint citizenId, ref TCitizen citizen, int doNothingProbability, ushort currentBuilding, bool isVirtual)
        {
            int targetType = touristAI.GetRandomTargetType(instance, doNothingProbability);

            if (targetType == 1)
            {
                Log.Debug(TimeInfo.Now, $"Tourist {GetCitizenDesc(citizenId, ref citizen, isVirtual)} decides to leave the city");
                touristAI.FindVisitPlace(instance, citizenId, currentBuilding, touristAI.GetLeavingReason(instance, citizenId, ref citizen));
                return;
            }

            if (!Random.ShouldOccur(GetGoOutChance(CitizenProxy.GetAge(ref citizen))) || IsBadWeather(citizenId))
            {
                FindHotel(instance, citizenId, ref citizen, isVirtual);
                return;
            }

            if (isVirtual)
            {
                if (Random.ShouldOccur(TouristShoppingChance) && BuildingMgr.GetBuildingService(currentBuilding) == ItemClass.Service.Commercial)
                {
                    BuildingMgr.ModifyMaterialBuffer(currentBuilding, TransferManager.TransferReason.Shopping, -ShoppingGoodsAmount);
                }

                touristAI.AddTouristVisit(instance, citizenId, currentBuilding);

                return;
            }

            switch (targetType)
            {
            case 2:
                touristAI.FindVisitPlace(instance, citizenId, currentBuilding, touristAI.GetShoppingReason(instance));
                Log.Debug(TimeInfo.Now, $"Tourist {GetCitizenDesc(citizenId, ref citizen, isVirtual)} stays in the city, goes shopping");
                break;

            case 3:
                Log.Debug(TimeInfo.Now, $"Tourist {GetCitizenDesc(citizenId, ref citizen, isVirtual)} stays in the city, goes relaxing");
                touristAI.FindVisitPlace(instance, citizenId, currentBuilding, touristAI.GetEntertainmentReason(instance));
                break;
            }
        }
示例#4
0
        private bool FindRandomVisitPlace(TAI instance, uint citizenId, ref TCitizen citizen, int doNothingProbability, ushort visitBuilding)
        {
            int targetType = touristAI.GetRandomTargetType(instance, doNothingProbability);

            if (targetType == 1)
            {
                Log.Debug(TimeInfo.Now, $"Tourist {GetCitizenDesc(citizenId, ref citizen)} decides to leave the city");
                touristAI.FindVisitPlace(instance, citizenId, visitBuilding, touristAI.GetLeavingReason(instance, citizenId, ref citizen));
                return(true);
            }

            if (CitizenProxy.GetInstance(ref citizen) == 0 && !touristAI.DoRandomMove(instance))
            {
                return(false);
            }

            if (!IsChance(GetGoOutChance(CitizenProxy.GetAge(ref citizen))))
            {
                FindHotel(instance, citizenId, ref citizen);
                return(true);
            }

            switch (targetType)
            {
            case 2:
                touristAI.FindVisitPlace(instance, citizenId, visitBuilding, touristAI.GetShoppingReason(instance));
                Log.Debug(TimeInfo.Now, $"Tourist {GetCitizenDesc(citizenId, ref citizen)} stays in the city, goes shopping");
                break;

            case 3:
                Log.Debug(TimeInfo.Now, $"Tourist {GetCitizenDesc(citizenId, ref citizen)} stays in the city, goes relaxing");
                touristAI.FindVisitPlace(instance, citizenId, visitBuilding, touristAI.GetEntertainmentReason(instance));
                break;
            }

            return(true);
        }