Cody WIP before cleanup

This commit is contained in:
2026-06-17 22:49:44 -04:00
parent 299687734f
commit abccaaa14c
7 changed files with 224 additions and 5 deletions

View File

@@ -13,6 +13,7 @@ AWeaponBase::AWeaponBase()
}
// Called when the game starts or when spawned
void AWeaponBase::BeginPlay()
{
@@ -46,3 +47,82 @@ void AWeaponBase::MagRepacking()
// }
}
}
void AWeaponBase::Server_SpawnProjectile_Implementation()
{
FVector Location;
if (WeaponMesh->DoesSocketExist("Socket_Projectile"))
Location = WeaponMesh->GetSocketLocation("Socket_Projectile");
FRotator Rotation = GetActorRotation();
FVector Dir = GetOwner()->GetActorForwardVector();
// GetActorEyesViewPoint(Location, Rotation);
if (Location.Equals(FVector::ZeroVector))
Location += Dir * 55.f;
else
{
GEngine->AddOnScreenDebugMessage(2,10.f,FColor::Green,TEXT("Server Failed to get Socket Location"));
return;
}
if (!ProjectileClass)
{
GEngine->AddOnScreenDebugMessage(2, 10.f, FColor::Emerald, "Server No Projectile Set");
return;
}
FActorSpawnParameters SpawnInfo;
SpawnInfo.Owner = GetOwner();
SpawnInfo.Instigator = GetInstigator();
SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
GEngine->AddOnScreenDebugMessage(2,10.f,FColor::Red,FString::Printf(TEXT("Server Spawning Projectile Location %f,%f,%f"), Location.X, Location.Y, Location.Z));
AActor* projectile = GetWorld()->SpawnActor<AActor>(ProjectileClass, Location, Rotation, SpawnInfo);
if (!projectile)
GEngine->AddOnScreenDebugMessage(2,10.f,FColor::Red,TEXT("Failed to Spawn"));
Client_SpawnProjectile();
}
bool AWeaponBase::Server_SpawnProjectile_Validate()
{
return true;
}
void AWeaponBase::Client_SpawnProjectile_Implementation()
{
FVector Location;
if (WeaponMesh->DoesSocketExist("Socket_Projectile"))
Location = WeaponMesh->GetSocketLocation("Socket_Projectile");
FRotator Rotation = GetActorRotation();
FVector Dir = GetActorForwardVector();
// GetActorEyesViewPoint(Location, Rotation);
if (Location.Equals(FVector::ZeroVector))
Location += Dir * 55.f;
else
{
GEngine->AddOnScreenDebugMessage(1,10.f,FColor::Green,TEXT("Client Failed to get Socket Location"));
return;
}
if (!ProjectileClass)
{
GEngine->AddOnScreenDebugMessage(1, 10.f, FColor::Emerald, "Client No Projectile Set");
return;
}
FActorSpawnParameters SpawnInfo;
SpawnInfo.Owner = this;
SpawnInfo.Instigator = GetInstigator();
SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
GEngine->AddOnScreenDebugMessage(1,10.f,FColor::Red,FString::Printf(TEXT("Client Spawning Projectile Location %f,%f,%f"), Location.X, Location.Y, Location.Z));
GetWorld()->SpawnActor<AActor>(ProjectileClass, Location, Rotation, SpawnInfo);
}
bool AWeaponBase::Client_SpawnProjectile_Validate()
{
return true;
}