Skip to content

Instantly share code, notes, and snippets.

@BrodyHiggerson
Created September 19, 2014 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrodyHiggerson/da7090aaa886ce72e61f to your computer and use it in GitHub Desktop.
Save BrodyHiggerson/da7090aaa886ce72e61f to your computer and use it in GitHub Desktop.
#include "FlightPrototype.h"
#include "ShipStart.h"
#include "Ship.h"
AShipStart::AShipStart(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
SpawnBoxComponent = PCIP.CreateDefaultSubobject<UBoxComponent>(this, "Spawn Box");
if (SpawnBoxComponent)
{
SpawnBoxComponent->SetWorldScale3D(FVector(200, 200, 200));
SpawnBoxComponent->AttachParent = RootComponent;
}
ArrowComponent->SetWorldScale3D(FVector(100, 100, 100));
bHasSpawnedShip = false;
pMostRecentShipSpawn = nullptr;
TeamNum = -1;
}
bool AShipStart::HasSpawnedShip()
{
return bHasSpawnedShip;
}
void AShipStart::SetHasSpawnedShip(bool HasSpawned)
{
bHasSpawnedShip = HasSpawned;
}
bool AShipStart::IsSpawnBoxClear()
{
TArray<AActor*> OverlappingActors;
GetOverlappingActors(OverlappingActors, AShip::StaticClass());
if (OverlappingActors.Num() > 0)
{
return false;
}
return true;
}
#pragma once
#include "GameFramework/PlayerStart.h"
#include "SpaceTypes.h"
#include "ShipStart.generated.h"
/**
*
*/
UCLASS(Blueprintable, hidecategories = Collision)
class FLIGHTPROTOTYPE_API AShipStart : public APlayerStart
{
GENERATED_UCLASS_BODY()
/* Specifies the owning faction for this ship start. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Game) // Not used / hasn't been a problem
TEnumAsByte<EFactionName::Type> SpawnFaction; // Same as above
/* Specifies the owning team for this ship start. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Game)
int32 TeamNum;
/* Returns whether this ship start has spawned a ship yet. */
bool HasSpawnedShip();
/* Set whether or not this ship has spawned a ship. */
void SetHasSpawnedShip(bool HasSpawned);
/* Checks if the spawn box is clear of ships. */
bool IsSpawnBoxClear();
protected:
/* Whether this ship start has spawned a ship yet. */
bool bHasSpawnedShip;
/* The most recently-spawned ship from this ship start. */
AActor* pMostRecentShipSpawn;
UPROPERTY(BlueprintReadOnly, Category = Components)
TSubobjectPtr<UBoxComponent> SpawnBoxComponent;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment