void AFlockFish::ManageTimers(float delta) { // Check if the fish is full or not if (isFull) { hungerTimer += delta; if (hungerTimer >= hungerResetTime) { hungerTimer = 0.0f; isFull = false; } } // decide on wether to move target this tick if (turnTimer >= turnFrequency && isLeader == true) { spawnTarget(); GenerateSeekType(); turnTimer = 0.0; } else if (!isLeader) { curSeekType = Cast<AFlockFish>(leader)->curSeekType; } updateTimer += delta; turnTimer += delta; }
AFlockFish::AFlockFish(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { base = ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("FishMesh")); RootComponent = base; // Fish interaction sphere FishInteractionSphere = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("FishInteractionSphere")); FishInteractionSphere->SetSphereRadius(10); FishInteractionSphere->AttachTo(RootComponent); FishInteractionSphere->OnComponentBeginOverlap.AddDynamic(this, &AFlockFish::OnBeginOverlap); FishInteractionSphere->OnComponentEndOverlap.AddDynamic(this, &AFlockFish::OnEndOverlap); if (isLeader == true) { spawnTarget(); } //Defaults followDist = 50.0; speed = 1200.0; maxSpeed = 2400.0; turnSpeed = 3.0; turnFrequency = 1.0; turnFrequency = 1.0; hungerResetTime = 20.0; distBehindSpeedUpRange = 3000.0; SeperationDistanceMultiplier = 0.75; FleeDistanceMultiplier = 5.0; FleeAccelerationMultiplier = 2.0; ChaseAccelerationMultiplier = 2.0; SeekDecelerationMultiplier = 1.0; AvoidForceMultiplier = 1.0; AvoidanceForce = 20000.0; underwaterMin = FVector(-40000, -40000, -9000); underwaterMax = FVector(40000, 40000, -950); CustomZSeekMin = 0.0; CustomZSeekMax = 0.0; NumNeighborsToEvaluate = 5.0; UpdateEveryTick = 0.0; DebugMode = true; fleeDistance = 0.0; neighborSeperation = 300.0; curSpeed = speed; isFleeing = false; isFull = false; underwaterBoxLength = 10000.0; AvoidanceDistance = 5000.0; curVelocity = FVector(0, 0, 0); curRotation = FRotator(0, 0, 0); turnTimer = 0.0; isSetup = false; hungerTimer = 0.0; updateTimer = 0.0; hasFishManager = false; }
void doBroker(int argc, char *argv[]) { sandboxed::Broker::instance()->initialize(); // Create application QApplication::setGraphicsSystem( "raster" ); QApplication app( argc, argv ); MPMEventLoop loop; sandboxed::TargetProcess *process = spawnTarget(); process->client()->waitForConnection(); app.exec(); }
AFlockFish::AFlockFish(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { base = ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("FishMesh")); RootComponent = base; // Fish interaction sphere FishInteractionSphere = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("FishInteractionSphere")); FishInteractionSphere->SetSphereRadius(10); FishInteractionSphere->AttachTo(RootComponent); FishInteractionSphere->OnComponentBeginOverlap.AddDynamic(this, &AFlockFish::OnBeginOverlap); FishInteractionSphere->OnComponentEndOverlap.AddDynamic(this, &AFlockFish::OnEndOverlap); if (isLeader == true) { spawnTarget(); } }