Decreased Recurring NPCs
This commit is contained in:
parent
ebafc668b4
commit
9a18446c83
BIN
EndlessVendetta/Content/StarterContent/Blueprints/Blueprint_CeilingLight.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/StarterContent/Blueprints/Blueprint_CeilingLight.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset
(Stored with Git LFS)
Binary file not shown.
@ -37,30 +37,19 @@ void ANPC_Manager::BeginPlay()
|
||||
}
|
||||
|
||||
if (NPC_StationClasses.IsEmpty()) return;
|
||||
|
||||
FRotator DefaultRot = FRotator(0, 0, 0);
|
||||
int StationSlots = (StationPoints.Num() / NPC_StationClasses.Num()) + 1;
|
||||
TArray<int> NumOfUniqueStations;
|
||||
for (auto UniqueStation : NPC_StationClasses)
|
||||
{
|
||||
NumOfUniqueStations.Add(StationSlots);
|
||||
}
|
||||
int StationClassIndex = 0;
|
||||
for (FVector StationPoint : StationPoints)
|
||||
{
|
||||
bool FoundRandomFairInt = false;
|
||||
int RandInt = 0;
|
||||
while (!FoundRandomFairInt)
|
||||
{
|
||||
RandInt = FMath::RandRange(0, NPC_StationClasses.Num() - 1);
|
||||
if (NumOfUniqueStations[RandInt] > 0)
|
||||
{
|
||||
NumOfUniqueStations[RandInt]--;
|
||||
FoundRandomFairInt = true;
|
||||
}
|
||||
}
|
||||
|
||||
FVector StationPointWorldLocation = StationPoint + GetActorLocation();
|
||||
ANPC_Station* NPC_Station = GetWorld()->SpawnActor<ANPC_Station>(NPC_StationClasses[RandInt], StationPointWorldLocation, DefaultRot);
|
||||
ANPC_Station* NPC_Station = GetWorld()->SpawnActor<ANPC_Station>(NPC_StationClasses[StationClassIndex], StationPointWorldLocation, DefaultRot);
|
||||
if (IsValid(NPC_Station)) NPC_Stations.Add(NPC_Station);
|
||||
StationClassIndex++;
|
||||
if (StationClassIndex >= NPC_StationClasses.Num())
|
||||
{
|
||||
StationClassIndex = 0;
|
||||
}
|
||||
}
|
||||
SetActorTickInterval(1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user