Space Plunder
Loading...
Searching...
No Matches
AShipPawn Class Reference

#include <ShipPawn.h>

Inheritance diagram for AShipPawn:
AInteractablePawn ICharacterInterface IBaseInterface ISaveLoad

Public Member Functions

 AShipPawn ()
 
virtual ETeamAttitude::Type GetTeamAttitudeTowards (const AActor &Other) const override
 
virtual void SetGenericTeamId (const FGenericTeamId &NewTeamID) override
 
virtual FGenericTeamId GetGenericTeamId () const override
 
bool GetIsPiloted () const
 
int32 GetPassengers () const
 
- Public Member Functions inherited from AInteractablePawn
 AInteractablePawn ()
 
virtual void ReceiveStartFocus (AActor *Caller)
 
virtual void ReceiveEndFocus (AActor *Caller)
 
virtual void ReceiveOnInteract (AActor *Caller, const EInteractionType InteractionType)
 
virtual void ReceiveOnEndInteract (AActor *Caller)
 
virtual void ReceiveOnOverlap (AActor *Caller)
 
virtual void ReceiveOnEndOverlap (AActor *Caller)
 
virtual void ReceiveToggleSwitch (AActor *Caller, const bool bOn)
 
virtual void InteractionDataUpdated ()
 
virtual void SetupPlayerInputComponent (class UInputComponent *PlayerInputComponent) override
 
- Public Member Functions inherited from ICharacterInterface
virtual USkeletalMeshComponent * GetCharacterSecondaryMesh () const
 
virtual void StartThreatIndication (AActor *PawnThreat)
 
virtual void UpdateThreatIndication (const FVector &Location, const float DetectionAmount)
 
virtual void StopThreatIndication ()
 

Protected Member Functions

virtual void BeginPlay () override
 
virtual void PossessedBy (AController *NewController) override
 
virtual void OnInteract (AActor *Caller, const int32 SelectedInteraction) override
 
virtual void PilotShip (AActor *Caller)
 
virtual void EnterShip (AActor *Caller)
 
virtual void SetCallerInShip (AActor *Caller, AAIController *AIController)
 
void OnPilotEntered (AActor *NewPilot)
 
void OnPilotExited (AActor *NewPilot)
 
virtual void PilotExitShip ()
 
virtual void PilotEnterShip ()
 
void OnPassengerEntered (AActor *NewPassenger)
 
void OnPassengerExited (AActor *NewPassenger)
 
virtual void PassengerEnterShip (const int32 NewPassenger)
 
virtual void PassengerExitShip (const int32 ExitPassenger)
 
void OpenDoor ()
 
void CloseDoor ()
 
void OnOpenDoor ()
 
void OnCloseDoor ()
 
int32 GetTeamID () const
 
virtual ECharacterType GetCharacterType () const override
 
virtual EFactionType GetCharacterFaction () const override
 
virtual bool GetIsDead () const override
 
virtual void SetCharacterVehicleMode (const EVehicleMode Mode) override
 
virtual void PointDamageTaken (AActor *DamagedActor, float Damage, class AController *InstigatedBy, FVector HitLocation, class UPrimitiveComponent *HitComponent, FName BoneName, FVector ShotFromDirection, const class UDamageType *DamageType, AActor *DamageCauser)
 
virtual void OnDeath (AActor *OwningActor, EDeathType DeathType, AActor *DeathCauser, AController *DeathInstigator)
 
- Protected Member Functions inherited from AInteractablePawn
virtual bool SaveGame () override
 
virtual bool LoadGame () override
 
FVector GetCustomInteractionLocation () const
 
void LogDebugError (const FString &Message) const
 
void LogDebugError (const FString &Message, const int32 Value) const
 
void LogDebugError (const FString &Message, const float Value) const
 
void LogDebugWarning (const FString &Message) const
 
void LogDebugWarning (const FString &Message, const int32 Value) const
 
void LogDebugWarning (const FString &Message, const float Value) const
 
void LogDebugMessage (const FString &Message, const bool bWarning=false, const bool bError=false) const
 
void LogDebugMessage (const FString &Message, const int32 Value, const bool bWarning=false, const bool bError=false) const
 
void LogDebugMessage (const FString &Message, const float Value, const bool bWarning=false, const bool bError=false) const
 
void LogDebugMessage (const FString &Message, const bool bValue, const bool bWarning, const bool bError) const
 
void LogOnScreenMessage (const int32 Key, const FString &Message, FColor Color=FColor::Green) const
 
void SetCategoryName (const FLogCategoryBase &Category)
 

Protected Attributes

FGenericTeamId TeamID
 
ECharacterType CharacterType = ECharacterType::Defence
 
EFactionType OwnerFaction = EFactionType::Alliance
 
bool bDead = false
 
bool bOpenDoor = false
 
UCapsuleComponent * CapsuleComponent
 
UStaticMeshComponent * MeshComponent
 
USpringArmComponent * SpringArm
 
UCameraComponent * CameraComponent
 
USceneComponent * ExitLocation
 
USceneComponent * PilotLocation
 
UCharacterHealthComponent * HealthComponent
 
float ExplosionDamage = 500000.0f
 
bool bCanAIPilot = false
 
bool bAttachWhenEnter = false
 
bool bStopAILogicWhenEnter = false
 
AActor * Pilot = nullptr
 
TArray< AActor * > Passengers
 
int32 MaxPassengers = 3
 
- Protected Attributes inherited from AInteractablePawn
class UAudioReactionComponent * AudioReactionComponent
 
class UInteractableActorComponent * InteractableActorComponent
 
class UAIPerceptionStimuliSourceComponent * PerceptionStimuliComponent
 
bool bDebuggingMode = false
 

Constructor & Destructor Documentation

◆ AShipPawn()

AShipPawn::AShipPawn ( )
22{
23 InteractionData.InteractionTypes.Add(FInteractionType(EInteractionType::Pilot));
24 InteractionData.InteractionTypes.Add(FInteractionType(EInteractionType::Enter));
25 InteractionData.InteractionTypes.Add(FInteractionType(EInteractionType::Exit));
26 InteractionData.InteractionTypes.Add(FInteractionType(EInteractionType::Open));
27 InteractionData.InteractionTypes.Add(FInteractionType(EInteractionType::Close));
28
29
30
31 CapsuleComponent = CreateDefaultSubobject<UCapsuleComponent>(TEXT("Capsule"));
32 RootComponent = CapsuleComponent;
33 CapsuleComponent->InitCapsuleSize(140.0f, 155.0f);
34 MeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
35 MeshComponent->SetRelativeRotation(FRotator(0.0f,-90.0f,0.0f));
36 MeshComponent->SetupAttachment(RootComponent);
37 SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("Spring Arm"));
38 SpringArm->TargetArmLength = 750.0f;
39 //? @TODO Temp for Demo Ship
40 SpringArm->bUsePawnControlRotation = true;
41 SpringArm->TargetOffset = FVector(0.0f,0.0f,200.0f);
42 SpringArm->SetupAttachment(MeshComponent);
43 CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
44 CameraComponent->SetupAttachment(SpringArm);
45
46 ExitLocation = CreateDefaultSubobject<USceneComponent>(TEXT("Exit Location"));
47 ExitLocation->SetupAttachment(MeshComponent);
48 PilotLocation = CreateDefaultSubobject<USceneComponent>(TEXT("Pilot Location"));
49 PilotLocation->SetupAttachment(MeshComponent);
50
51 HealthComponent = CreateDefaultSubobject<UCharacterHealthComponent>(TEXT("Health Component"));
52 HealthComponent->bHasShield = false;
53
54 AIControllerClass = nullptr;
55 AutoPossessAI = EAutoPossessAI::Disabled;
56}
USceneComponent * PilotLocation
Definition ShipPawn.h:128
UCameraComponent * CameraComponent
Definition ShipPawn.h:124
USceneComponent * ExitLocation
Definition ShipPawn.h:126
UStaticMeshComponent * MeshComponent
Definition ShipPawn.h:120
UCapsuleComponent * CapsuleComponent
Definition ShipPawn.h:118
UCharacterHealthComponent * HealthComponent
Definition ShipPawn.h:131
USpringArmComponent * SpringArm
Definition ShipPawn.h:122
Definition BaseData.h:333

Member Function Documentation

◆ BeginPlay()

void AShipPawn::BeginPlay ( )
overrideprotectedvirtual

Reimplemented from AInteractablePawn.

110{
111 Super::BeginPlay();
113 if(HealthComponent != nullptr)
114 {
115 HealthComponent->OnDeath.AddUniqueDynamic(this, &AShipPawn::OnDeath);
116 }
117 OnTakePointDamage.AddUniqueDynamic(this, &AShipPawn::PointDamageTaken);
118 if(Passengers.Num() >= MaxPassengers)
119 {
120 InteractionData.SetInteractionHidden(EInteractionType::Enter, true);
121 }
122 InteractionData.SetInteractionHidden(EInteractionType::Exit, true);
123 if(bOpenDoor)
124 {
125 InteractionData.SetInteractionHidden(EInteractionType::Open, true);
126 }
127 else
128 {
129 InteractionData.SetInteractionHidden(EInteractionType::Close, true);
130 }
131}
virtual void SetGenericTeamId(const FGenericTeamId &NewTeamID) override
Definition ShipPawn.cpp:91
int32 MaxPassengers
Definition ShipPawn.h:148
TArray< AActor * > Passengers
Definition ShipPawn.h:145
EFactionType OwnerFaction
Definition ShipPawn.h:93
virtual void PointDamageTaken(AActor *DamagedActor, float Damage, class AController *InstigatedBy, FVector HitLocation, class UPrimitiveComponent *HitComponent, FName BoneName, FVector ShotFromDirection, const class UDamageType *DamageType, AActor *DamageCauser)
Definition ShipPawn.cpp:462
bool bOpenDoor
Definition ShipPawn.h:112
virtual void OnDeath(AActor *OwningActor, EDeathType DeathType, AActor *DeathCauser, AController *DeathInstigator)
Definition ShipPawn.cpp:481
static uint8 GetTeamIDFromFaction(const EFactionType Faction)
Definition AIBPLib.cpp:91

◆ CloseDoor()

void AShipPawn::CloseDoor ( )
protected
262{
263 if(bOpenDoor == false){return;}
264 bOpenDoor = false;
265 InteractionData.SetInteractionHidden(EInteractionType::Close, true);
266 InteractionData.SetInteractionHidden(EInteractionType::Open, false);
267 OnCloseDoor();
268}
void OnCloseDoor()

◆ EnterShip()

void AShipPawn::EnterShip ( AActor * Caller)
protectedvirtual
430{
431 if(Passengers.Num() >= MaxPassengers)
432 {
433 return;
434 }
435 const int32 NewPassenger = Passengers.AddUnique(Caller);
436 AAIController* AIController = Cast<AAIController>(Caller->GetInstigatorController());
437 SetCallerInShip(Caller, AIController);
438 //@TODO don't disable input //
439 APlayerController* PlayerController = Cast<APlayerController>(Caller->GetInstigatorController());
440 if(PlayerController != nullptr)
441 {
442 // PlayerController->DisableInput(PlayerController);
443 }
444 PassengerEnterShip(NewPassenger);
445}
virtual void SetCallerInShip(AActor *Caller, AAIController *AIController)
Definition ShipPawn.cpp:447
virtual void PassengerEnterShip(const int32 NewPassenger)
Definition ShipPawn.cpp:203

◆ GetCharacterFaction()

virtual EFactionType AShipPawn::GetCharacterFaction ( ) const
inlineoverrideprotectedvirtual

Implements ICharacterInterface.

98{return OwnerFaction;};

◆ GetCharacterType()

virtual ECharacterType AShipPawn::GetCharacterType ( ) const
inlineoverrideprotectedvirtual

Implements ICharacterInterface.

96{return CharacterType;};
ECharacterType CharacterType
Definition ShipPawn.h:91

◆ GetGenericTeamId()

virtual FGenericTeamId AShipPawn::GetGenericTeamId ( ) const
inlineoverridevirtual
33{return TeamID;};
FGenericTeamId TeamID
Definition ShipPawn.h:84

◆ GetIsDead()

virtual bool AShipPawn::GetIsDead ( ) const
inlineoverrideprotectedvirtual

Implements ICharacterInterface.

102{return bDead;};
bool bDead
Definition ShipPawn.h:110

◆ GetIsPiloted()

bool AShipPawn::GetIsPiloted ( ) const
inline
37{return Pilot != nullptr;};
AActor * Pilot
Definition ShipPawn.h:143

◆ GetPassengers()

int32 AShipPawn::GetPassengers ( ) const
inline
39{return Passengers.Num();};

◆ GetTeamAttitudeTowards()

ETeamAttitude::Type AShipPawn::GetTeamAttitudeTowards ( const AActor & Other) const
overridevirtual
59{
60 if(const APawn* OtherPawn = Cast<APawn>(&Other))
61 {
62 const IGenericTeamAgentInterface* TeamAgent = Cast<IGenericTeamAgentInterface>(OtherPawn);
63 if(TeamAgent == nullptr){TeamAgent = Cast<IGenericTeamAgentInterface>(OtherPawn->GetController());}
64 if(TeamAgent != nullptr)
65 {
66 const FGenericTeamId OtherTeamID = TeamAgent->GetGenericTeamId();
67 const EFactionType OtherPawnFaction = UAIBPLib::GetFactionFromTeamID(OtherTeamID);
68 bool bSuccess = false;
69 const FFactionRelationship Relationship = UAIBPLib::GetFactionRelationship(this, OwnerFaction, OtherPawnFaction, bSuccess);
70 if(bSuccess)
71 {
72 switch (Relationship.RelationshipStatus)
73 {
76 return ETeamAttitude::Friendly;
80 return ETeamAttitude::Neutral;
83 return ETeamAttitude::Hostile;
84 }
85 }
86 }
87 }
88 return ETeamAttitude::Neutral;
89}
EFactionType
Definition AIDataTypes.h:103
static EFactionType GetFactionFromTeamID(const uint8 TeamID)
Definition AIBPLib.cpp:120
static FFactionRelationship GetFactionRelationship(const UObject *WorldContextObject, const EFactionType Faction, const EFactionType TargetFaction, bool &bSuccess, UDataTable *DataTable=nullptr)
Definition AIBPLib.cpp:339
Definition AIDataTypes.h:279
ERelationshipStatus RelationshipStatus
Definition AIDataTypes.h:284

◆ GetTeamID()

int32 AShipPawn::GetTeamID ( ) const
inlineprotected
86{return (TeamID == FGenericTeamId::NoTeam) ? INDEX_NONE : (int32)TeamID;};

◆ OnCloseDoor()

void AShipPawn::OnCloseDoor ( )
protected

◆ OnDeath()

void AShipPawn::OnDeath ( AActor * OwningActor,
EDeathType DeathType,
AActor * DeathCauser,
AController * DeathInstigator )
protectedvirtual
482{
483 bDead = true;
484 AActor* PreviousPilot = Pilot;
486 UGameplayStatics::ApplyDamage(PreviousPilot, ExplosionDamage, DeathInstigator, DeathCauser, UExplosionDamage::StaticClass());
487}
float ExplosionDamage
Definition ShipPawn.h:134
virtual void PilotExitShip()
Definition ShipPawn.cpp:172

◆ OnInteract()

void AShipPawn::OnInteract ( AActor * Caller,
const int32 SelectedInteraction )
overrideprotectedvirtual
271{
272 Super::OnInteract(Caller, SelectedInteraction);
273 if(Caller == nullptr || Caller->GetInstigatorController() == nullptr){return;}
274 FInteractionType InteractionType;
275 if(UBaseHelpersBPLib::GetInteraction(InteractionType, InteractionData, SelectedInteraction) == false){return;}
276
277 if(InteractionType.InteractionType == EInteractionType::Pilot)
278 {
279 PilotShip(Caller);
280 CloseDoor();
281 }
282
283 if(InteractionType.InteractionType == EInteractionType::Enter)
284 {
285 EnterShip(Caller);
286 }
287 if(InteractionType.InteractionType == EInteractionType::Exit)
288 {
289 if(Passengers.Contains(Caller))
290 {
291 PassengerExitShip(Passengers.IndexOfByKey(Caller));
292 }
293 if(GetIsPiloted())
294 {
296 OpenDoor();
297 }
298 }
299 if(InteractionType.InteractionType == EInteractionType::Open)
300 {
301 OpenDoor();
302 }
303 if(InteractionType.InteractionType == EInteractionType::Close)
304 {
305 CloseDoor();
306 }
307
308 if(Passengers.Num() >= MaxPassengers)
309 {
310 InteractionData.SetInteractionHidden(EInteractionType::Enter, true);
311 }
312 else
313 {
314 InteractionData.SetInteractionHidden(EInteractionType::Enter, false);
315 }
316 if(GetIsPiloted())
317 {
318 InteractionData.SetInteractionHidden(EInteractionType::Pilot, true);
319 InteractionData.SetInteractionHidden(EInteractionType::Exit, false);
320 }
321 else
322 {
323 InteractionData.SetInteractionHidden(EInteractionType::Pilot, false);
324 }
325 const IBaseInterface* BaseCaller = Cast<IBaseInterface>(Caller);
326 if(BaseCaller != nullptr)
327 {
328 BaseCaller->InteractionDataUpdated();
329 }
330
331
332 // if(PlayerController != nullptr)
333 // {
334 // if(Pilot == nullptr)
335 // {
336 // Pilot = Caller;
337 // PlayerController->Possess(this);
338 // PilotEnterShip();
339 // OnPilotEntered(Pilot);
340 // }
341 // else
342 // {
343 // // if(Passengers.Num() >= MaxPassengers)
344 // // {
345 // // InteractionData.SetInteractionHidden(EInteractionType::Enter, true);
346 // // InteractionData.SetInteractionHidden(EInteractionType::Open, false);
347 // // // InteractionData.bShowDefault = true;
348 // // // InteractionData.DefaultInteraction = InteractionData.InteractionTypes.Add(FInteractionType(EInteractionType::Open));
349 // // return;
350 // // }
351 // if(Passengers.Num() >= MaxPassengers)
352 // {
353 // return;
354 // }
355 // Passengers.Add(Caller);
356 // PlayerController->DisableInput(PlayerController);
357 // }
358 // Caller->SetActorEnableCollision(false);
359 // if(bAttachWhenEnter)
360 // {
361 // const FAttachmentTransformRules TransformRules = FAttachmentTransformRules(EAttachmentRule::SnapToTarget, false);
362 // Caller->AttachToComponent(PilotLocation, TransformRules);
363 // }
364 // }
365 // else
366 // {
367 // // const AAIController* AIController = Cast<AAIController>(Caller->GetInstigatorController());
368 // if(AIController != nullptr)
369 // {
370 // if(bCanAIPilot && Pilot == nullptr)
371 // {
372 // Pilot = Caller;
373 // PilotEnterShip();
374 // OnPilotEntered(Pilot);
375 // }
376 // else
377 // {
378 // if(Passengers.Num() >= MaxPassengers)
379 // {
380 // return;
381 // }
382 // Passengers.Add(Caller);
383 // // if(Passengers.Num() >= MaxPassengers)
384 // // {
385 // // InteractionData.SetInteractionHidden(EInteractionType::Enter, true);
386 // // InteractionData.SetInteractionHidden(EInteractionType::Open, false);
387 // // // InteractionData.bShowDefault = true;
388 // // // InteractionData.DefaultInteraction = InteractionData.InteractionTypes.Add(FInteractionType(EInteractionType::Open));
389 // // }
390 //
391 // }
392 // Caller->SetActorEnableCollision(false);
393 // if(bAttachWhenEnter)
394 // {
395 // const FAttachmentTransformRules TransformRules = FAttachmentTransformRules(EAttachmentRule::SnapToTarget, false);
396 // Caller->AttachToComponent(PilotLocation, TransformRules);
397 // }
398 // if(AIController->GetBrainComponent() != nullptr)
399 // {
400 // AIController->GetBrainComponent()->StopLogic("Escape");
401 // }
402 // }
403 // }
404}
void OpenDoor()
Definition ShipPawn.cpp:251
virtual void PassengerExitShip(const int32 ExitPassenger)
Definition ShipPawn.cpp:221
virtual void EnterShip(AActor *Caller)
Definition ShipPawn.cpp:429
void CloseDoor()
Definition ShipPawn.cpp:261
virtual void PilotShip(AActor *Caller)
Definition ShipPawn.cpp:406
bool GetIsPiloted() const
Definition ShipPawn.h:37
Definition BaseInterface.h:17
static bool GetInteraction(FInteractionType &InteractionType, const FInteractionData &InteractionData, const int32 Value)
Definition BaseHelpersBPLib.cpp:522
EInteractionType InteractionType
Definition BaseData.h:337

◆ OnOpenDoor()

void AShipPawn::OnOpenDoor ( )
protected

◆ OnPassengerEntered()

void AShipPawn::OnPassengerEntered ( AActor * NewPassenger)
protected

◆ OnPassengerExited()

void AShipPawn::OnPassengerExited ( AActor * NewPassenger)
protected

◆ OnPilotEntered()

void AShipPawn::OnPilotEntered ( AActor * NewPilot)
protected

◆ OnPilotExited()

void AShipPawn::OnPilotExited ( AActor * NewPilot)
protected

◆ OpenDoor()

void AShipPawn::OpenDoor ( )
protected
252{
253 if(bOpenDoor){return;}
254
255 bOpenDoor = true;
256 InteractionData.SetInteractionHidden(EInteractionType::Close, false);
257 InteractionData.SetInteractionHidden(EInteractionType::Open, true);
258 OnOpenDoor();
259}
void OnOpenDoor()

◆ PassengerEnterShip()

void AShipPawn::PassengerEnterShip ( const int32 NewPassenger)
protectedvirtual
204{
205 if(Passengers.IsValidIndex(NewPassenger) == false || PilotLocation == nullptr){return;}
206 APawn* PassengerPawn = Cast<APawn>(Passengers[NewPassenger]);
207 if(PassengerPawn == nullptr){UE_LOG(LogCustomCharacters, Error, TEXT("Passenger not a Pawn of sHip ?? "))return;}
208 PassengerPawn->GetMovementComponent()->StopMovementImmediately();
209 PassengerPawn->SetActorLocation(PilotLocation->GetComponentLocation());
210 PassengerPawn->SetActorRotation(PilotLocation->GetComponentRotation());
211 PassengerPawn->SetActorHiddenInGame(true);
212 //@TODO Temp Mode
213 ICharacterInterface* Character = Cast<ICharacterInterface>(PassengerPawn);
214 if(Character != nullptr)
215 {
217 }
218 OnPassengerEntered(PassengerPawn);
219}
void OnPassengerEntered(AActor *NewPassenger)
Definition CharacterInterface.h:20
virtual void SetCharacterVehicleMode(const EVehicleMode Mode)=0

◆ PassengerExitShip()

void AShipPawn::PassengerExitShip ( const int32 ExitPassenger)
protectedvirtual
222{
223 if(Passengers.IsValidIndex(ExitPassenger) == false || ExitLocation == nullptr){return;}
224 APawn* PassengerPawn = Cast<APawn>(Passengers[ExitPassenger]);
225 if(PassengerPawn == nullptr){UE_LOG(LogCustomCharacters, Error, TEXT("PassengerPawn not a Pawn of sHip ?? "))return;}
226 PassengerPawn->SetActorEnableCollision(true);
227 PassengerPawn->SetActorLocation(ExitLocation->GetComponentLocation());
228 PassengerPawn->SetActorRotation(ExitLocation->GetComponentRotation());
229 APlayerController* PlayerController = Cast<APlayerController>(GetController());
230 if(PlayerController != nullptr)
231 {
232 PlayerController->EnableInput(PlayerController);
233 }
234 const AAIController* AIController = Cast<AAIController>(GetController());
235 if(bStopAILogicWhenEnter && AIController != nullptr && AIController->GetBrainComponent() != nullptr)
236 {
237 AIController->GetBrainComponent()->RestartLogic();
238 }
239 PassengerPawn->SetActorHiddenInGame(false);
240 //@TODO Temp Mode
241 ICharacterInterface* Character = Cast<ICharacterInterface>(PassengerPawn);
242 if(Character != nullptr)
243 {
244 Character->SetCharacterVehicleMode(EVehicleMode::None);
245 }
246 OnPassengerExited(PassengerPawn);
247 Passengers.RemoveAt(ExitPassenger);
248}
void OnPassengerExited(AActor *NewPassenger)
bool bStopAILogicWhenEnter
Definition ShipPawn.h:140

◆ PilotEnterShip()

void AShipPawn::PilotEnterShip ( )
protectedvirtual
153{
154 if(GetIsPiloted() == false || PilotLocation == nullptr){return;}
155 APawn* PilotPawn = Cast<APawn>(Pilot);
156 if(PilotPawn == nullptr){UE_LOG(LogCustomCharacters, Error, TEXT("Pilot not a Pawn of sHip ?? "))return;}
157 PilotPawn->GetMovementComponent()->StopMovementImmediately();
158 PilotPawn->SetActorLocation(PilotLocation->GetComponentLocation());
159 PilotPawn->SetActorRotation(PilotLocation->GetComponentRotation());
160 PilotPawn->SetActorHiddenInGame(true);
161 InteractionData.SetInteractionHidden(EInteractionType::Pilot, true);
162 //@TODO Temp Mode
164 if(Character != nullptr)
165 {
167 }
168}
EInteractionType
Definition BaseData.h:149

◆ PilotExitShip()

void AShipPawn::PilotExitShip ( )
protectedvirtual
173{
174 if(GetIsPiloted() == false || ExitLocation == nullptr){return;}
175 APawn* PilotPawn = Cast<APawn>(Pilot);
176 if(PilotPawn == nullptr){UE_LOG(LogCustomCharacters, Error, TEXT("Pilot not a Pawn of sHip ?? "))return;}
177 PilotPawn->SetActorEnableCollision(true);
178 APlayerController* PlayerController = Cast<APlayerController>(GetController());
179 if(PlayerController != nullptr)
180 {
181 PlayerController->Possess(PilotPawn);
182 }
183
184 PilotPawn->SetActorLocation(ExitLocation->GetComponentLocation());
185 PilotPawn->SetActorRotation(ExitLocation->GetComponentRotation());
186 const AAIController* AIController = Cast<AAIController>(GetController());
187 if(bStopAILogicWhenEnter && AIController != nullptr && AIController->GetBrainComponent() != nullptr)
188 {
189 AIController->GetBrainComponent()->RestartLogic();
190 }
191 PilotPawn->SetActorHiddenInGame(false);
192 InteractionData.SetInteractionHidden(EInteractionType::Pilot, false);
193 //@TODO Temp Mode
194 ICharacterInterface* Character = Cast<ICharacterInterface>(PilotPawn);
195 if(Character != nullptr)
196 {
197 Character->SetCharacterVehicleMode(EVehicleMode::None);
198 }
200 Pilot = nullptr;
201}
void OnPilotExited(AActor *NewPilot)

◆ PilotShip()

void AShipPawn::PilotShip ( AActor * Caller)
protectedvirtual
407{
408 AController* CallerController = Cast<AController>(Caller->GetInstigatorController());
409 bool bPlayer = true;
410 AAIController* AIController = Cast<AAIController>(Caller->GetInstigatorController());
411 if(AIController != nullptr)
412 {
413 bPlayer = false;
414 if(bCanAIPilot == false){EnterShip(Caller);return;}
415 }
416 if(CallerController != nullptr && Pilot == nullptr)
417 {
418 Pilot = Caller;
419 SetCallerInShip(Caller, AIController);
420 if(bPlayer)
421 {
422 CallerController->Possess(this);
423 }
426 }
427}
virtual void PilotEnterShip()
Definition ShipPawn.cpp:152
void OnPilotEntered(AActor *NewPilot)
bool bCanAIPilot
Definition ShipPawn.h:136

◆ PointDamageTaken()

void AShipPawn::PointDamageTaken ( AActor * DamagedActor,
float Damage,
class AController * InstigatedBy,
FVector HitLocation,
class UPrimitiveComponent * HitComponent,
FName BoneName,
FVector ShotFromDirection,
const class UDamageType * DamageType,
AActor * DamageCauser )
protectedvirtual
465{
466 if(InstigatedBy != nullptr && InstigatedBy->GetPawn() != nullptr)
467 {
468 bool bKillingHit = false;
469 if(HealthComponent != nullptr)
470 {
471 bKillingHit = HealthComponent->GetHealth() <= 0.0f;
472 }
473 IHitMarkerInterface* HitMarkerActor = Cast<IHitMarkerInterface>(InstigatedBy->GetPawn());
474 if(HitMarkerActor != nullptr)
475 {
476 HitMarkerActor->HitMarker(this, Damage, DamageType, BoneName, HitLocation, bKillingHit);
477 }
478 }
479}
Definition HitMarkerInterface.h:16
virtual void HitMarker(const AActor *ActorHit, const float Damage, const UDamageType *DamageType, const FName HitBone, const FVector HitLocation, const bool bKillingHit=false, const bool bInjuredPart=false)=0

◆ PossessedBy()

void AShipPawn::PossessedBy ( AController * NewController)
overrideprotectedvirtual
134{
135 Super::PossessedBy(NewController);
136 if(NewController == nullptr){return;}
137 const IGenericTeamAgentInterface* TeamOwner = Cast<IGenericTeamAgentInterface>(NewController);
138 if(TeamOwner == nullptr){return;}
139 SetGenericTeamId(TeamOwner->GetGenericTeamId());
141 if(HealthComponent != nullptr)
142 {
143 const APlayerController* PlayerController = Cast<APlayerController>(NewController);
144 if(PlayerController != nullptr && PlayerController->GetHUD() != nullptr)
145 {
146 HealthComponent->SetupComponent(nullptr, nullptr, NewController, Cast<AActor>(PlayerController->GetHUD()), false, bDead);
147 }
148 }
149 if(bDebuggingMode){const FString FactionName = UEnum::GetValueAsString(OwnerFaction);UE_LOG(LogCustomCharacters, Warning, TEXT("Owner Faction SET %s"), *FactionName);}
150}
bool bDebuggingMode
Definition InteractablePawn.h:69
virtual FGenericTeamId GetGenericTeamId() const override
Definition ShipPawn.h:33

◆ SetCallerInShip()

void AShipPawn::SetCallerInShip ( AActor * Caller,
AAIController * AIController )
protectedvirtual
448{
449 Caller->SetActorEnableCollision(false);
451 {
452 const FAttachmentTransformRules TransformRules = FAttachmentTransformRules(EAttachmentRule::SnapToTarget, false);
453 Caller->AttachToComponent(PilotLocation, TransformRules);
454 }
455 if(bStopAILogicWhenEnter && AIController != nullptr && AIController->GetBrainComponent() != nullptr)
456 {
457 AIController->GetBrainComponent()->StopLogic("Pilot");
458 }
459}
bool bAttachWhenEnter
Definition ShipPawn.h:138

◆ SetCharacterVehicleMode()

virtual void AShipPawn::SetCharacterVehicleMode ( const EVehicleMode Mode)
inlineoverrideprotectedvirtual

Implements ICharacterInterface.

107{return;};

◆ SetGenericTeamId()

void AShipPawn::SetGenericTeamId ( const FGenericTeamId & NewTeamID)
overridevirtual
92{
93 if(HasAuthority())
94 {
95 const FGenericTeamId OldTeamID = TeamID;
96
97 // MARK_PROPERTY_DIRTY_FROM_NAME(ThisClass, MyTeamID, this);
98 TeamID = NewTeamID;
99 if(bDebuggingMode){ UE_LOG(LogCustomCharacters, Error, TEXT("team %i"), NewTeamID.GetId());}
100
101 // ConditionalBroadcastTeamChanged(this, OldTeamID, NewTeamID);
102 }
103 else
104 {
105 if(bDebuggingMode){UE_LOG(LogTemp, Error, TEXT("Cannot set team for %s on non-authority"), *GetPathName(this));}
106 }
107}

Member Data Documentation

◆ bAttachWhenEnter

bool AShipPawn::bAttachWhenEnter = false
protected

◆ bCanAIPilot

bool AShipPawn::bCanAIPilot = false
protected

◆ bDead

bool AShipPawn::bDead = false
protected

◆ bOpenDoor

bool AShipPawn::bOpenDoor = false
protected

◆ bStopAILogicWhenEnter

bool AShipPawn::bStopAILogicWhenEnter = false
protected

◆ CameraComponent

UCameraComponent* AShipPawn::CameraComponent
protected

◆ CapsuleComponent

UCapsuleComponent* AShipPawn::CapsuleComponent
protected

◆ CharacterType

ECharacterType AShipPawn::CharacterType = ECharacterType::Defence
protected

◆ ExitLocation

USceneComponent* AShipPawn::ExitLocation
protected

◆ ExplosionDamage

float AShipPawn::ExplosionDamage = 500000.0f
protected

◆ HealthComponent

UCharacterHealthComponent* AShipPawn::HealthComponent
protected

◆ MaxPassengers

int32 AShipPawn::MaxPassengers = 3
protected

Not Including Pilot

◆ MeshComponent

UStaticMeshComponent* AShipPawn::MeshComponent
protected

◆ OwnerFaction

EFactionType AShipPawn::OwnerFaction = EFactionType::Alliance
protected

◆ Passengers

TArray<AActor*> AShipPawn::Passengers
protected

◆ Pilot

AActor* AShipPawn::Pilot = nullptr
protected

◆ PilotLocation

USceneComponent* AShipPawn::PilotLocation
protected

◆ SpringArm

USpringArmComponent* AShipPawn::SpringArm
protected

◆ TeamID

FGenericTeamId AShipPawn::TeamID
protected

The documentation for this class was generated from the following files: