第一次提交
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
|
||||
#include "Bullet/GCS_BulletSystemComponent.h"
|
||||
|
||||
#include "GCS_LogChannels.h"
|
||||
#include "Bullet/GCS_BulletInstance.h"
|
||||
#include "Bullet/GCS_BulletSubsystem.h"
|
||||
|
||||
|
||||
// Sets default values for this component's properties
|
||||
UGCS_BulletSystemComponent::UGCS_BulletSystemComponent()
|
||||
{
|
||||
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
|
||||
// off to improve performance if you don't need them.
|
||||
PrimaryComponentTick.bCanEverTick = false;
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
|
||||
// Called when the game starts
|
||||
void UGCS_BulletSystemComponent::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
UGCS_BulletSystemComponent* UGCS_BulletSystemComponent::GetBulletSystemComponent(const AActor* Actor)
|
||||
{
|
||||
return IsValid(Actor) ? Actor->FindComponentByClass<UGCS_BulletSystemComponent>() : nullptr;
|
||||
}
|
||||
|
||||
bool UGCS_BulletSystemComponent::FindBulletSystemComponent(const AActor* Actor, UGCS_BulletSystemComponent*& Component)
|
||||
{
|
||||
Component = GetBulletSystemComponent(Actor);
|
||||
return Component != nullptr;
|
||||
}
|
||||
|
||||
void UGCS_BulletSystemComponent::SpawnBullet(const FGCS_BulletSpawnParameters& SpawnParameters)
|
||||
{
|
||||
//SpawnBulletInternal(SpawnParameters);
|
||||
}
|
||||
|
||||
// TArray<AGCS_BulletInstance*> UGCS_BulletSystemComponent::SpawnBulletInternal(const FGCS_BulletSpawnParameters& SpawnParameters)
|
||||
// {
|
||||
// TArray<AGCS_BulletInstance*> RetInstances{};
|
||||
//
|
||||
// if (GetOwner()->GetLocalRole() < ROLE_AutonomousProxy)
|
||||
// {
|
||||
// GCS_CLOG(Warning, "No authority to spawn bullet!")
|
||||
// return RetInstances;
|
||||
// }
|
||||
//
|
||||
// UGCS_BulletSubsystem* Subsystem = UGCS_BulletSubsystem::Get(GetWorld());
|
||||
// if (Subsystem == nullptr)
|
||||
// {
|
||||
// return RetInstances;
|
||||
// }
|
||||
//
|
||||
// FGCS_BulletDefinition Definition;
|
||||
// if (SpawnParameters.DefinitionHandle.IsNull() || !Subsystem->LoadBulletDefinition(SpawnParameters.DefinitionHandle, Definition))
|
||||
// {
|
||||
// return RetInstances;
|
||||
// }
|
||||
//
|
||||
// RetInstances = Subsystem->GetOrCreateBulletInstances(SpawnParameters, Definition);
|
||||
//
|
||||
// for (int i = 0; i < RetInstances.Num(); ++i)
|
||||
// {
|
||||
// AGCS_BulletInstance* Instance = RetInstances[i];
|
||||
//
|
||||
// Instance->bServerInitiated = GetWorld()->GetNetMode() < NM_Client;
|
||||
// Instance->bIsLocalPredicting = SpawnParameters.bIsLocalPredicting;
|
||||
//
|
||||
// if (SpawnParameters.OverrideBulletIds.IsValidIndex(i))
|
||||
// {
|
||||
// Instance->SetBulletId(SpawnParameters.OverrideBulletIds[0]);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Instance->SetBulletId(FGuid::NewGuid());
|
||||
// }
|
||||
//
|
||||
// if (SpawnParameters.ParentId.IsValid() && BulletInstances.Contains(SpawnParameters.ParentId))
|
||||
// {
|
||||
// Instance->SetParentBulletId(SpawnParameters.ParentId);
|
||||
// // if (AGCS_BulletInstance* ParentBulletInstance = BulletInstances[SpawnParameters.ParentId])
|
||||
// // {
|
||||
// // if (ParentBulletInstance->Definition.bUseSharedHitList)
|
||||
// // {
|
||||
// // Instance->HitActors = ParentBulletInstance->HitActors;
|
||||
// // }
|
||||
// // }
|
||||
// }
|
||||
//
|
||||
// if (SpawnParameters.Request)
|
||||
// {
|
||||
// Instance->Request = SpawnParameters.Request;
|
||||
// }
|
||||
//
|
||||
// if (SpawnParameters.Owner)
|
||||
// {
|
||||
// Instance->SetOwner(SpawnParameters.Owner);
|
||||
// }
|
||||
// Instance->SetDefinitionHandle(SpawnParameters.DefinitionHandle);
|
||||
// BulletInstances.Emplace(Instance->BulletId, Instance);
|
||||
// }
|
||||
//
|
||||
// FRotator OriginalRotation = SpawnParameters.SpawnTransform.Rotator();
|
||||
// for (int i = 0; i < RetInstances.Num(); ++i)
|
||||
// {
|
||||
// FTransform ModifiedTransform = SpawnParameters.SpawnTransform;
|
||||
// FRotator RotationYawOffset(Definition.LaunchElevationAngle, Definition.LaunchAngle + Definition.LaunchAngleInterval * i, 0);
|
||||
// ModifiedTransform.SetRotation(UKismetMathLibrary::ComposeRotators(OriginalRotation, RotationYawOffset).Quaternion());
|
||||
// RetInstances[i]->SetActorTransform(ModifiedTransform, false, nullptr, ETeleportType::ResetPhysics);
|
||||
// }
|
||||
//
|
||||
// //batch beginplay.
|
||||
// for (AGCS_BulletInstance* Instance : RetInstances)
|
||||
// {
|
||||
// Instance->OnBulletBeginPlay();
|
||||
// }
|
||||
// return RetInstances;
|
||||
// }
|
||||
Reference in New Issue
Block a user