diff --git a/Config/DefaultEditor.ini b/Config/DefaultEditor.ini index 1beb666..a7bc978 100644 --- a/Config/DefaultEditor.ini +++ b/Config/DefaultEditor.ini @@ -1,5 +1,8 @@ [/Script/UnrealEd.BlueprintEditorProjectSettings] +bForceAllDependenciesToRecompile=False +bValidateUnloadedSoftActorReferences=True bEnableChildActorExpansionInTreeView=False +DefaultChildActorTreeViewMode=ComponentOnly diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index b645b60..234c129 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -3,6 +3,7 @@ [/Script/EngineSettings.GameMapsSettings] GameDefaultMap=/Game/Levels/MainMenu_Level.MainMenu_Level EditorStartupMap=/Game/Levels/StartMap.StartMap +GlobalDefaultGameMode=/Script/SkyFrontier.ScoreAttackGameMode [/Script/HardwareTargeting.HardwareTargetingSettings] TargetedHardwareClass=Desktop diff --git a/Config/DefaultGame.ini b/Config/DefaultGame.ini index 0b9e63d..2bfae50 100644 --- a/Config/DefaultGame.ini +++ b/Config/DefaultGame.ini @@ -3,5 +3,5 @@ ProjectID=49D77AEE4F076637F90AB5AE443787F8 [/Script/UnrealEd.ProjectPackagingSettings] -BuildConfiguration=PPBC_Shipping +BuildConfiguration=PPBC_Development diff --git a/Config/DefaultGameplayTags.ini b/Config/DefaultGameplayTags.ini new file mode 100644 index 0000000..aa9660b --- /dev/null +++ b/Config/DefaultGameplayTags.ini @@ -0,0 +1,11 @@ +[/Script/GameplayTags.GameplayTagsSettings] +ImportTagsFromConfig=True +WarnOnInvalidTags=True +ClearInvalidTags=False +FastReplication=False +InvalidTagCharacters="\"\'," +NumBitsForContainerSize=6 +NetIndexFirstBitSegment=16 ++GameplayTagList=(Tag="Player1",DevComment="") ++GameplayTagList=(Tag="Player2",DevComment="") + diff --git a/Content/Assets/Items/MagneticShield/MagneticShield_BP_WM.uasset b/Content/Assets/Items/MagneticShield/MagneticShield_BP_WM.uasset index 868eeb8..94af52e 100644 --- a/Content/Assets/Items/MagneticShield/MagneticShield_BP_WM.uasset +++ b/Content/Assets/Items/MagneticShield/MagneticShield_BP_WM.uasset Binary files differ diff --git a/Content/Assets/Items/MagneticShield/MagneticShield_WM.uasset b/Content/Assets/Items/MagneticShield/MagneticShield_WM.uasset index 6b4a8a9..6817aa8 100644 --- a/Content/Assets/Items/MagneticShield/MagneticShield_WM.uasset +++ b/Content/Assets/Items/MagneticShield/MagneticShield_WM.uasset Binary files differ diff --git a/Content/Assets/Items/MagneticShield_BP.uasset b/Content/Assets/Items/MagneticShield_BP.uasset index 8e0b956..9563614 100644 --- a/Content/Assets/Items/MagneticShield_BP.uasset +++ b/Content/Assets/Items/MagneticShield_BP.uasset Binary files differ diff --git a/Content/Assets/Items/OverCharge_BP.uasset b/Content/Assets/Items/OverCharge_BP.uasset index 0d7091f..87bb2e9 100644 --- a/Content/Assets/Items/OverCharge_BP.uasset +++ b/Content/Assets/Items/OverCharge_BP.uasset Binary files differ diff --git a/Content/Assets/Items/Overcharge/OverCharge_BP_WM.uasset b/Content/Assets/Items/Overcharge/OverCharge_BP_WM.uasset index a3eb2f7..4052aa7 100644 --- a/Content/Assets/Items/Overcharge/OverCharge_BP_WM.uasset +++ b/Content/Assets/Items/Overcharge/OverCharge_BP_WM.uasset Binary files differ diff --git a/Content/Assets/Items/RepairKit/RepairKit_BP_WM.uasset b/Content/Assets/Items/RepairKit/RepairKit_BP_WM.uasset index 3a4e953..d125747 100644 --- a/Content/Assets/Items/RepairKit/RepairKit_BP_WM.uasset +++ b/Content/Assets/Items/RepairKit/RepairKit_BP_WM.uasset Binary files differ diff --git a/Content/Assets/Items/RepairKit_BP.uasset b/Content/Assets/Items/RepairKit_BP.uasset index 9715730..525cf58 100644 --- a/Content/Assets/Items/RepairKit_BP.uasset +++ b/Content/Assets/Items/RepairKit_BP.uasset Binary files differ diff --git a/Content/Assets/NewTargetSystem/BP_target_marker.uasset b/Content/Assets/NewTargetSystem/BP_target_marker.uasset index 019e395..cc79fea 100644 --- a/Content/Assets/NewTargetSystem/BP_target_marker.uasset +++ b/Content/Assets/NewTargetSystem/BP_target_marker.uasset Binary files differ diff --git a/Content/Assets/NewTargetSystem/Missile_NT.uasset b/Content/Assets/NewTargetSystem/Missile_NT.uasset index 190071d..7283c94 100644 --- a/Content/Assets/NewTargetSystem/Missile_NT.uasset +++ b/Content/Assets/NewTargetSystem/Missile_NT.uasset Binary files differ diff --git a/Content/Assets/NewTargetSystem/P_Target_new.uasset b/Content/Assets/NewTargetSystem/P_Target_new.uasset index 377317b..eba7213 100644 --- a/Content/Assets/NewTargetSystem/P_Target_new.uasset +++ b/Content/Assets/NewTargetSystem/P_Target_new.uasset Binary files differ diff --git a/Content/Assets/NewTargetSystem/Targets_BP.uasset b/Content/Assets/NewTargetSystem/Targets_BP.uasset new file mode 100644 index 0000000..f1787e3 --- /dev/null +++ b/Content/Assets/NewTargetSystem/Targets_BP.uasset Binary files differ diff --git a/Content/Assets/NormieAsset/MainPlane_BP.uasset b/Content/Assets/NormieAsset/MainPlane_BP.uasset new file mode 100644 index 0000000..890814c --- /dev/null +++ b/Content/Assets/NormieAsset/MainPlane_BP.uasset Binary files differ diff --git a/Content/Assets/NormieAsset/Test_anim.uasset b/Content/Assets/NormieAsset/Test_anim.uasset deleted file mode 100644 index 99f82da..0000000 --- a/Content/Assets/NormieAsset/Test_anim.uasset +++ /dev/null Binary files differ diff --git a/Content/Assets/Projectiles/BulletsMaterial.uasset b/Content/Assets/Projectiles/BulletsMaterial.uasset new file mode 100644 index 0000000..476a4ec --- /dev/null +++ b/Content/Assets/Projectiles/BulletsMaterial.uasset Binary files differ diff --git a/Content/Assets/Projectiles/BulletsMaterial_MachineGun.uasset b/Content/Assets/Projectiles/BulletsMaterial_MachineGun.uasset new file mode 100644 index 0000000..2553553 --- /dev/null +++ b/Content/Assets/Projectiles/BulletsMaterial_MachineGun.uasset Binary files differ diff --git a/Content/Assets/Projectiles/HomingProjectile_BP.uasset b/Content/Assets/Projectiles/HomingProjectile_BP.uasset new file mode 100644 index 0000000..e2244f7 --- /dev/null +++ b/Content/Assets/Projectiles/HomingProjectile_BP.uasset Binary files differ diff --git a/Content/Assets/Projectiles/Missile.uasset b/Content/Assets/Projectiles/Missile.uasset new file mode 100644 index 0000000..53d44c3 --- /dev/null +++ b/Content/Assets/Projectiles/Missile.uasset Binary files differ diff --git a/Content/Assets/Projectiles/Projectile.uasset b/Content/Assets/Projectiles/Projectile.uasset new file mode 100644 index 0000000..a014f1c --- /dev/null +++ b/Content/Assets/Projectiles/Projectile.uasset Binary files differ diff --git a/Content/Assets/Projectiles/Projectile_BP.uasset b/Content/Assets/Projectiles/Projectile_BP.uasset new file mode 100644 index 0000000..9dadee7 --- /dev/null +++ b/Content/Assets/Projectiles/Projectile_BP.uasset Binary files differ diff --git a/Content/Levels/MainMenu_Level.umap b/Content/Levels/MainMenu_Level.umap index 757a21e..fd0853e 100644 --- a/Content/Levels/MainMenu_Level.umap +++ b/Content/Levels/MainMenu_Level.umap Binary files differ diff --git a/Content/Levels/Main_Level.umap b/Content/Levels/Main_Level.umap deleted file mode 100644 index b1bfd22..0000000 --- a/Content/Levels/Main_Level.umap +++ /dev/null Binary files differ diff --git a/Content/Levels/Sergio_Level.umap b/Content/Levels/Sergio_Level.umap deleted file mode 100644 index 620029e..0000000 --- a/Content/Levels/Sergio_Level.umap +++ /dev/null Binary files differ diff --git a/Content/Levels/StartMap.umap b/Content/Levels/StartMap.umap index c0cf200..a3fc072 100644 --- a/Content/Levels/StartMap.umap +++ b/Content/Levels/StartMap.umap Binary files differ diff --git a/Content/Levels/StartMaptEST.umap b/Content/Levels/StartMaptEST.umap deleted file mode 100644 index 2f0528f..0000000 --- a/Content/Levels/StartMaptEST.umap +++ /dev/null Binary files differ diff --git a/Content/Levels/test_idk.umap b/Content/Levels/test_idk.umap deleted file mode 100644 index 72f4e02..0000000 --- a/Content/Levels/test_idk.umap +++ /dev/null Binary files differ diff --git a/Content/Matchmaking_Widget.uasset b/Content/Matchmaking_Widget.uasset deleted file mode 100644 index 1761516..0000000 --- a/Content/Matchmaking_Widget.uasset +++ /dev/null Binary files differ diff --git a/Content/NewGameMode_BP.uasset b/Content/NewGameMode_BP.uasset deleted file mode 100644 index 9b1769d..0000000 --- a/Content/NewGameMode_BP.uasset +++ /dev/null Binary files differ diff --git a/Content/NunoContent/Megascans/3D_Assets/Huge_Nordic_Coastal_Cliff_venrdcgga_00/Huge_Nordic_Coastal_Cliff_LOD0_venrdcgga.uasset b/Content/NunoContent/Megascans/3D_Assets/Huge_Nordic_Coastal_Cliff_venrdcgga_00/Huge_Nordic_Coastal_Cliff_LOD0_venrdcgga.uasset index 03090ae..16dc451 100644 --- a/Content/NunoContent/Megascans/3D_Assets/Huge_Nordic_Coastal_Cliff_venrdcgga_00/Huge_Nordic_Coastal_Cliff_LOD0_venrdcgga.uasset +++ b/Content/NunoContent/Megascans/3D_Assets/Huge_Nordic_Coastal_Cliff_venrdcgga_00/Huge_Nordic_Coastal_Cliff_LOD0_venrdcgga.uasset Binary files differ diff --git a/Content/NunoContent/Menus/Widgets/MainMenu_Widget.uasset b/Content/NunoContent/Menus/Widgets/MainMenu_Widget.uasset index 96871b7..29e4e9d 100644 --- a/Content/NunoContent/Menus/Widgets/MainMenu_Widget.uasset +++ b/Content/NunoContent/Menus/Widgets/MainMenu_Widget.uasset Binary files differ diff --git a/Content/NunoContent/UI/InGame.uasset b/Content/NunoContent/UI/InGame.uasset index 7a0ed39..82f972b 100644 --- a/Content/NunoContent/UI/InGame.uasset +++ b/Content/NunoContent/UI/InGame.uasset Binary files differ diff --git a/Content/PlaneTest/AirPlaneTestMovement.umap b/Content/PlaneTest/AirPlaneTestMovement.umap deleted file mode 100644 index fb65f90..0000000 --- a/Content/PlaneTest/AirPlaneTestMovement.umap +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BiPlane/BiPlanePawn_BP.uasset b/Content/PlaneTest/BiPlane/BiPlanePawn_BP.uasset deleted file mode 100644 index 3ba3630..0000000 --- a/Content/PlaneTest/BiPlane/BiPlanePawn_BP.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BiPlane/Biplane.uasset b/Content/PlaneTest/BiPlane/Biplane.uasset deleted file mode 100644 index aab098b..0000000 --- a/Content/PlaneTest/BiPlane/Biplane.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BiPlane/BiplaneWing.uasset b/Content/PlaneTest/BiPlane/BiplaneWing.uasset deleted file mode 100644 index 8e24f2b..0000000 --- a/Content/PlaneTest/BiPlane/BiplaneWing.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BiPlane/Biplane_Diffuse.uasset b/Content/PlaneTest/BiPlane/Biplane_Diffuse.uasset deleted file mode 100644 index e646a37..0000000 --- a/Content/PlaneTest/BiPlane/Biplane_Diffuse.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BiPlane/Biplane_Normal.uasset b/Content/PlaneTest/BiPlane/Biplane_Normal.uasset deleted file mode 100644 index 83501e7..0000000 --- a/Content/PlaneTest/BiPlane/Biplane_Normal.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BiPlane/Biplane_Wing_Diffuse.uasset b/Content/PlaneTest/BiPlane/Biplane_Wing_Diffuse.uasset deleted file mode 100644 index 8be8478..0000000 --- a/Content/PlaneTest/BiPlane/Biplane_Wing_Diffuse.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BiPlane/Biplane_Wing_Normal.uasset b/Content/PlaneTest/BiPlane/Biplane_Wing_Normal.uasset deleted file mode 100644 index f31eb4a..0000000 --- a/Content/PlaneTest/BiPlane/Biplane_Wing_Normal.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BiPlane/Biplane_rigged.uasset b/Content/PlaneTest/BiPlane/Biplane_rigged.uasset deleted file mode 100644 index 80cab83..0000000 --- a/Content/PlaneTest/BiPlane/Biplane_rigged.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BiPlane/Biplane_rigged_PhysicsAsset.uasset b/Content/PlaneTest/BiPlane/Biplane_rigged_PhysicsAsset.uasset deleted file mode 100644 index c2c95aa..0000000 --- a/Content/PlaneTest/BiPlane/Biplane_rigged_PhysicsAsset.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BiPlane/Biplane_rigged_Skeleton.uasset b/Content/PlaneTest/BiPlane/Biplane_rigged_Skeleton.uasset deleted file mode 100644 index e0ca8f4..0000000 --- a/Content/PlaneTest/BiPlane/Biplane_rigged_Skeleton.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BiPlane/Biplane_rigged_Skeleton1.uasset b/Content/PlaneTest/BiPlane/Biplane_rigged_Skeleton1.uasset deleted file mode 100644 index e377162..0000000 --- a/Content/PlaneTest/BiPlane/Biplane_rigged_Skeleton1.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BiPlane/Fbx_Default_Material_1.uasset b/Content/PlaneTest/BiPlane/Fbx_Default_Material_1.uasset deleted file mode 100644 index 1e8a0fb..0000000 --- a/Content/PlaneTest/BiPlane/Fbx_Default_Material_1.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BiPlane/M_UE4Man_Body1.uasset b/Content/PlaneTest/BiPlane/M_UE4Man_Body1.uasset deleted file mode 100644 index c1911c6..0000000 --- a/Content/PlaneTest/BiPlane/M_UE4Man_Body1.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BiPlane/MannequinPosed_mesh.uasset b/Content/PlaneTest/BiPlane/MannequinPosed_mesh.uasset deleted file mode 100644 index f83f226..0000000 --- a/Content/PlaneTest/BiPlane/MannequinPosed_mesh.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BiPlane/MannequinPosed_mesh_PhysicsAsset.uasset b/Content/PlaneTest/BiPlane/MannequinPosed_mesh_PhysicsAsset.uasset deleted file mode 100644 index dbc3f2f..0000000 --- a/Content/PlaneTest/BiPlane/MannequinPosed_mesh_PhysicsAsset.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BiPlane/MannequinPosed_mesh_Skeleton.uasset b/Content/PlaneTest/BiPlane/MannequinPosed_mesh_Skeleton.uasset deleted file mode 100644 index 96efd81..0000000 --- a/Content/PlaneTest/BiPlane/MannequinPosed_mesh_Skeleton.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BiPlane/MannequinPosed_mesh_Skeleton1.uasset b/Content/PlaneTest/BiPlane/MannequinPosed_mesh_Skeleton1.uasset deleted file mode 100644 index a289aa9..0000000 --- a/Content/PlaneTest/BiPlane/MannequinPosed_mesh_Skeleton1.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BiPlane/NewPawn.uasset b/Content/PlaneTest/BiPlane/NewPawn.uasset deleted file mode 100644 index d46df48..0000000 --- a/Content/PlaneTest/BiPlane/NewPawn.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BiPlane/biplane_staticmesh.uasset b/Content/PlaneTest/BiPlane/biplane_staticmesh.uasset deleted file mode 100644 index a5564bf..0000000 --- a/Content/PlaneTest/BiPlane/biplane_staticmesh.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BulletsMaterial.uasset b/Content/PlaneTest/BulletsMaterial.uasset deleted file mode 100644 index 9687647..0000000 --- a/Content/PlaneTest/BulletsMaterial.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/BulletsMaterial_MachineGun.uasset b/Content/PlaneTest/BulletsMaterial_MachineGun.uasset deleted file mode 100644 index 16aefb5..0000000 --- a/Content/PlaneTest/BulletsMaterial_MachineGun.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/HomingProjectile_BP.uasset b/Content/PlaneTest/HomingProjectile_BP.uasset deleted file mode 100644 index 6309879..0000000 --- a/Content/PlaneTest/HomingProjectile_BP.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/Missile.uasset b/Content/PlaneTest/Missile.uasset deleted file mode 100644 index fc17b7b..0000000 --- a/Content/PlaneTest/Missile.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/Projectile_BP.uasset b/Content/PlaneTest/Projectile_BP.uasset deleted file mode 100644 index 846f752..0000000 --- a/Content/PlaneTest/Projectile_BP.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/Targets_BP.uasset b/Content/PlaneTest/Targets_BP.uasset deleted file mode 100644 index 2cb41f4..0000000 --- a/Content/PlaneTest/Targets_BP.uasset +++ /dev/null Binary files differ diff --git a/Content/PlaneTest/ThirdPersonFlying.uasset b/Content/PlaneTest/ThirdPersonFlying.uasset deleted file mode 100644 index ea578b4..0000000 --- a/Content/PlaneTest/ThirdPersonFlying.uasset +++ /dev/null Binary files differ diff --git a/Content/Projectile.uasset b/Content/Projectile.uasset deleted file mode 100644 index 31c2704..0000000 --- a/Content/Projectile.uasset +++ /dev/null Binary files differ diff --git a/Content/ScoreGameMode_BP.uasset b/Content/ScoreGameMode_BP.uasset new file mode 100644 index 0000000..6280bf5 --- /dev/null +++ b/Content/ScoreGameMode_BP.uasset Binary files differ diff --git a/SkyFrontier.uproject b/SkyFrontier.uproject index de53b0e..c4f9f7e 100644 --- a/SkyFrontier.uproject +++ b/SkyFrontier.uproject @@ -10,7 +10,8 @@ "LoadingPhase": "Default", "AdditionalDependencies": [ "Engine", - "UMG" + "UMG", + "CoreUObject" ] } ], diff --git a/Source/SkyFrontier/Private/DamageSystem.cpp b/Source/SkyFrontier/Private/DamageSystem.cpp index 6ffce29..fa034bd 100644 --- a/Source/SkyFrontier/Private/DamageSystem.cpp +++ b/Source/SkyFrontier/Private/DamageSystem.cpp @@ -1,6 +1,3 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - #include "DamageSystem.h" // Sets default values for this component's properties @@ -8,16 +5,16 @@ { PrimaryComponentTick.bCanEverTick = false; PrimaryComponentTick.bStartWithTickEnabled = false; + SetIsReplicated(true); + ShootingDamage = 20; + MissileDamage = 50; } // Called when the game starts void UDamageSystem::BeginPlay() { - Super::BeginPlay(); - ShootingDamage = 20; - MissileDamage = 50; - + Super::BeginPlay(); } float UDamageSystem::GetShootingDamage() const diff --git a/Source/SkyFrontier/Private/HealthSystem.cpp b/Source/SkyFrontier/Private/HealthSystem.cpp index 3643f42..f15c573 100644 --- a/Source/SkyFrontier/Private/HealthSystem.cpp +++ b/Source/SkyFrontier/Private/HealthSystem.cpp @@ -1,22 +1,30 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - #include "HealthSystem.h" +#include "Net/UnrealNetwork.h" +#include "Engine/Engine.h" +#include "Components/ActorComponent.h" UHealthSystem::UHealthSystem() { PrimaryComponentTick.bCanEverTick = false; PrimaryComponentTick.bStartWithTickEnabled = false; + SetIsReplicated(true); + MaxHealth = 100; } void UHealthSystem::BeginPlay() { Super::BeginPlay(); - Health = MaxHealth; Shield = 0; } +void UHealthSystem::GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const +{ + Super::GetLifetimeReplicatedProps(OutLifetimeProps); + + DOREPLIFETIME(UHealthSystem, Health); +} + float UHealthSystem::GetHealth() const { return Health; @@ -27,66 +35,53 @@ return MaxHealth; } -float UHealthSystem::GetHealthAsPercentage() const -{ - return Health / MaxHealth; -} - float UHealthSystem::GetShield() const { return Shield; } -void UHealthSystem::ModifyHealth(const float Amount) -{ - if(Amount == 0) - return; - - Health += Amount; - - Amount > 0 ? OnDamageHealedEvent.Broadcast(Amount) : OnDamageTakenEvent.Broadcast(Amount); -} - void UHealthSystem::TakeDamage(const float Amount) { - if(Amount > 0) + if (Amount > 0) { Health -= Amount; OnDamageTakenEvent.Broadcast(Amount); } } - + + + void UHealthSystem::RecoverHealth(const float Amount) { - if(Amount > 0) + if (Amount > 0) { Health += Amount; if (Health >= MaxHealth) { Health = MaxHealth; } - + OnDamageHealedEvent.Broadcast(Amount); } } void UHealthSystem::ReceiveShield(const float Amount) { - if(Amount >= 0) + if (Amount >= 0) { Shield += Amount; - + OnShieldReceiveEvent.Broadcast(Amount); } } void UHealthSystem::RemoveShield(const float Amount) { - if(Amount >= 0) + if (Amount >= 0) { Shield -= Amount; - + if (Shield < 0) { Shield = 0; diff --git a/Source/SkyFrontier/Private/MatchmakingJob.cpp b/Source/SkyFrontier/Private/MatchmakingJob.cpp new file mode 100644 index 0000000..829b69d --- /dev/null +++ b/Source/SkyFrontier/Private/MatchmakingJob.cpp @@ -0,0 +1,116 @@ +#include "MatchmakingJob.h" +#include "Sockets.h" +#include "Interfaces/IPv4/IPv4Endpoint.h" + +#pragma optimize("", off) + +MatchmakingJob::MatchmakingJob(FString& stateToWriteInto) + : currentState(stateToWriteInto) +{} + +bool MatchmakingJob::Init() +{ + const FIPv4Endpoint RemoteAddressForConnection = FIPv4Endpoint(FIPv4Address(127, 0, 0, 1), 1336); + ConnectionSocket = ISocketSubsystem::Get()->CreateSocket("Stream", "MatchmakingServer"); + if(!ConnectionSocket) + { + return false; + } + + const TSharedRef Address = ISocketSubsystem::Get()->CreateInternetAddr(RemoteAddressForConnection.Address.Value, RemoteAddressForConnection.Port); + return ConnectionSocket->Connect(Address.Get()); +} + +uint32 MatchmakingJob::Run() +{ + // Let's Start Connecting To The Matchmaking Server And Send Some Requests! + currentState = "Connected To matchmaking Server!"; + // As the system is super fast we're adding these in here to showcase the system working, you'd never use them otherwise + SleepThread(); + +#pragma region SendRequest + // Let's Send A Request! + // In this case we use a super simple way to send messages across, but we can add more to the string to parameterize certain things like gamemodes etc just make sure the server knows how to read the parameters + // (you make those rules) + // Creation of scope to reuse variable names for this example + FString Serialized = FString::FromInt(CLIENT_MESSAGE_REQUESTCONNECTION); + const TCHAR* serializedChar = Serialized.GetCharArray().GetData(); + int32 Size = FCString::Strlen(serializedChar); + int32 Sent = 0; + + // This should be a while until you've sent all the bytes through, as this is super simple it'll always send the full message + if(!ConnectionSocket->Send(reinterpret_cast(TCHAR_TO_UTF8(serializedChar)), Size, Sent)) + { + // Some Error Message + JobCompletedEvent.Broadcast(false, ""); + return 1; // Returns an exit code, you can use this to figure out where something failed or the type of failure + } + + // Let The UI Know What's Going On + currentState = "Request Sent! Waiting For Server To Find Match"; + SleepThread(); +#pragma endregion + +#pragma region ReceiveReply + // Now The Request Went To The Server, Let's Read And Wait For Their Reply! + uint8 ReceiveBuffer[128]; + FMemory::Memset(ReceiveBuffer, 0, sizeof(uint8) * 128); + int32 BytesRead = 0; + + FString FullMessage = ""; + + // Again Our Examples Are Small But Bigger Data Would Be Read In Chunks And Reconstructed + // Block and wait for a message to return, then read all remaining bits of said message + if(!ConnectionSocket->Recv(ReceiveBuffer, 128, BytesRead)) + { + // Some Error Use something like FScoket::GetLastError (I dont remember the exact syntax) ESocketError Return Type + JobCompletedEvent.Broadcast(false, ""); + return 2; + } + // Reinterpret the bits back into a const char* and apply it to the FString + FullMessage.Append(reinterpret_cast(ReceiveBuffer)); + + currentState = "Ready To Connect To Server!: " + FullMessage; + FPlatformProcess::Sleep(1.0f); +#pragma endregion + +#pragma region SendConfirmation + // Tell The Server We're Done! + // Reusing Variables, you could and SHOULD place these into smaller easier to read functions + Serialized = TEXT( "" + FString::FromInt(CLIENT_MESSAGE_CONFIRMDONE) ); + serializedChar = Serialized.GetCharArray().GetData(); + Size = FCString::Strlen(serializedChar); + Sent = 0; + + // This should be a while until you've sent all the bytes through, as this is super simple it'll always send the full message + if(!ConnectionSocket->Send(reinterpret_cast(TCHAR_TO_UTF8(serializedChar)), Size, Sent)) + { + // Some Error Message + JobCompletedEvent.Broadcast(false, ""); + return 3; + } +#pragma endregion + + JobCompletedEvent.Broadcast(true, FullMessage); + + return 0; // return the error! None in this case! :D +} + +void MatchmakingJob::Exit() +{ + FRunnable::Exit(); +} + +void MatchmakingJob::Stop() +{ + FRunnable::Stop(); +} + +void MatchmakingJob::SleepThread() +{ +#if !UE_BUILD_SHIPPING + FPlatformProcess::Sleep(1.0f); +#endif +} + +#pragma optimize("", on) \ No newline at end of file diff --git a/Source/SkyFrontier/Private/MatchmakingSubsystem.cpp b/Source/SkyFrontier/Private/MatchmakingSubsystem.cpp new file mode 100644 index 0000000..2ac1e8f --- /dev/null +++ b/Source/SkyFrontier/Private/MatchmakingSubsystem.cpp @@ -0,0 +1,24 @@ +#include "MatchmakingSubsystem.h" + + +void UMatchmakingSubsystem::Initialize(FSubsystemCollectionBase& Collection) +{ + // Force the intiialization of any other dependency you might have + //Collection.InitializeDependency(); + Super::Initialize(Collection); +} + +void UMatchmakingSubsystem::RequestGame() +{ + FindMatchJob = new MatchmakingJob(CurrentState); + FindMatchJob->JobCompletedEvent.AddUFunction(this, "OnMatchmakerThreadDone"); + + FRunnableThread::Create(FindMatchJob, TEXT("FindMatchJob")); +} + +void UMatchmakingSubsystem::OnMatchmakerThreadDone(bool CompletionState, FString ServerIP) +{ + if(CompletionState) + MatchFoundEvent.Broadcast(ServerIP); + else ServerToConnectTo = "Failed To Connect!"; +} diff --git a/Source/SkyFrontier/Private/MyButton.cpp b/Source/SkyFrontier/Private/MyButton.cpp deleted file mode 100644 index ed16293..0000000 --- a/Source/SkyFrontier/Private/MyButton.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - -#include "MyButton.h" - -UMyButton::UMyButton() -{ - OnClicked.AddDynamic(this, &UMyButton::OnClick); -} -void UMyButton::SetSessionInfo(int sID, TCPClient *tclient) -{ - sessionID = sID; tcpClient = tclient; -} -void UMyButton::OnClick() -{ - tcpClient->JoinGameSession(sessionID); -} \ No newline at end of file diff --git a/Source/SkyFrontier/Private/MyButtonHost.cpp b/Source/SkyFrontier/Private/MyButtonHost.cpp deleted file mode 100644 index f382b9d..0000000 --- a/Source/SkyFrontier/Private/MyButtonHost.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - -#include "MyButtonHost.h" - -UMyButtonHost::UMyButtonHost() -{ - OnClicked.AddDynamic(this, &UMyButtonHost::OnClick); -} -void UMyButtonHost::SetSessionInfo(FString sname, TCPClient *tclient) -{ - sessionName = sname; tcpClient = tclient; -} -void UMyButtonHost::OnClick() -{ - tcpClient->CreateNewGameSession(sessionName); -} \ No newline at end of file diff --git a/Source/SkyFrontier/Private/MyPlayerState.cpp b/Source/SkyFrontier/Private/MyPlayerState.cpp deleted file mode 100644 index 38f2d07..0000000 --- a/Source/SkyFrontier/Private/MyPlayerState.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - -#include "MyPlayerState.h" - -#include "MyButton.h" -#include "TCPClient.h" -#include "Blueprint/UserWidget.h" -#include "Components/Button.h" -#include "Components/ScrollBox.h" -#include "Components/TextBlock.h" -#include "Components/VerticalBox.h" -#include "Components/VerticalBoxSlot.h" - -void AMyPlayerState::BeginPlay() -{ - FString levelName = GetWorld()->GetMapName(); - levelName.RemoveFromStart(GetWorld()->StreamingLevelsPrefix); - if (levelName == "StartMap") - { - tcpClient = new TCPClient(this); - canConnectToGameServer = false; - if ((MatchmakingWidgetClass) && (tcpClient->IsConnected())) - { - serversList = new TArray(); - GetWorld()->GetTimerManager().SetTimer(serverListTimerHandle, this, &AMyPlayerState::OnUpdateServerList, 2, true); - MatchmakingWidget = CreateWidget(GetWorld(),MatchmakingWidgetClass); - MatchmakingWidget->AddToViewport(); - serverListScrollBoxWidget = Cast(MatchmakingWidget->GetWidgetFromName(TEXT("MyScrollBox"))); - UButton* newSessionButton = Cast(MatchmakingWidget->GetWidgetFromName(TEXT("NewSession"))); - if (newSessionButton) - { - newSessionButton->SetIsEnabled(true); - newSessionButton->OnClicked.AddDynamic(this, &AMyPlayerState::OnNewSessionClicked); - } - } - } -} -void AMyPlayerState::OnNewSessionClicked() -{ - tcpClient->CreateNewGameSession("My test session"); -} -void AMyPlayerState::UpdateSessionsList(FString serverinfo) -{ - TArray Out; serverinfo.ParseIntoArray(Out, TEXT("|"), true); - for (int i = 1; i < Out.Num() - 1; i += 2) { FSessionInfo *tempInfo = new FSessionInfo(); - tempInfo->id = FCString::Atoi(*Out[i]); - tempInfo->name = Out[i + 1]; - tempInfo->serverip = ""; - tempInfo->serverport = -1; - serversList->Add(tempInfo); } -} -void AMyPlayerState::ConnectToGameServer(FSessionInfo session) -{ - canConnectToGameServer = true; connectToGameServerSession = session; -} -void AMyPlayerState::OnUpdateServerList() { - if (tcpClient) { - if (tcpClient->IsConnected()) { - if (serversList->Num() > 0) { - if ((MatchmakingWidget) && (serverListScrollBoxWidget)) { - TArray allChildren = serverListScrollBoxWidget-> GetAllChildren(); - for (int i = 0; i < allChildren.Num(); i++) - { - allChildren[i]->RemoveFromParent(); - } - for (int i = 0; i < serversList->Num(); i++) - { - UVerticalBox* ItemWidgetsBox = NewObject(); - serverListScrollBoxWidget->AddChild(ItemWidgetsBox); - UMyButton* ItemWidget = NewObject(this); - ItemWidget->SetSessionInfo((*serversList)[i]->id, tcpClient); - UTextBlock* ItemWidgetText = NewObject(); - ItemWidgetText->SetText(FText::FromString( (*serversList)[i]->name)); - ItemWidget->AddChild(ItemWidgetText); - UVerticalBoxSlot* Slot = ItemWidgetsBox-> AddChildToVerticalBox(ItemWidget); - static FMargin Padding(5); - Slot->SetPadding(Padding); - } - } - } - if (canConnectToGameServer){ APlayerController* pController = GetWorld()-> GetFirstPlayerController(); - if (pController){ FString cmd = "open " + connectToGameServerSession.serverip + ":" + FString::FromInt(connectToGameServerSession.serverport); - tcpClient->Stop(); - canConnectToGameServer = false; - MatchmakingWidget->RemoveFromViewport(); - pController->ConsoleCommand(cmd); - } - } - } - } -} \ No newline at end of file diff --git a/Source/SkyFrontier/Private/PointsComponent.cpp b/Source/SkyFrontier/Private/PointsComponent.cpp new file mode 100644 index 0000000..c950c74 --- /dev/null +++ b/Source/SkyFrontier/Private/PointsComponent.cpp @@ -0,0 +1,34 @@ +#include "PointsComponent.h" +#include "Net/UnrealNetwork.h" + +UPointsComponent::UPointsComponent() +{ + PrimaryComponentTick.bCanEverTick = false; + PrimaryComponentTick.bStartWithTickEnabled = false; + SetIsReplicated(true); +} + +void UPointsComponent::BeginPlay() +{ + Super::BeginPlay(); + Points = 0; +} + +void UPointsComponent::GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const +{ + Super::GetLifetimeReplicatedProps(OutLifetimeProps); + + DOREPLIFETIME(UPointsComponent, Points); +} + +int UPointsComponent::GetPoints() const +{ + return Points; +} + +void UPointsComponent::AddPoints_Implementation(const int PointsToAdd) +{ + Points += PointsToAdd; + + OnPointsReceiveEvent.Broadcast(PointsToAdd); +} \ No newline at end of file diff --git a/Source/SkyFrontier/Private/ScoreAttackGameMode.cpp b/Source/SkyFrontier/Private/ScoreAttackGameMode.cpp new file mode 100644 index 0000000..93c8f34 --- /dev/null +++ b/Source/SkyFrontier/Private/ScoreAttackGameMode.cpp @@ -0,0 +1,56 @@ +#include "ScoreAttackGameMode.h" +#include "PointsComponent.h" +#include +#include "GameFramework/Controller.h" + + +AScoreAttackGameMode::AScoreAttackGameMode() +{ + GoalScore = 10; +} + +void AScoreAttackGameMode::PostInitializeComponents() +{ + Super::PostInitializeComponents(); + + TArray FoundActors; + UGameplayStatics::GetAllActorsOfClass(GetWorld(), APawn::StaticClass(), FoundActors); + + if (FoundActors.Num() == 2) + { + Pawn1 = Cast(FoundActors[0]); + Pawn2 = Cast(FoundActors[1]); + + if (Pawn1 && Pawn2) + { + PointsComponent1 = Pawn1->FindComponentByClass(); + PointsComponent2 = Pawn2->FindComponentByClass(); + } + } +} + +void AScoreAttackGameMode::BeginPlay() +{ + Super::BeginPlay(); + bGameEnded = false; + UE_LOG(LogTemp, Warning, TEXT("IS THIS WORKING")); +} + +void AScoreAttackGameMode::Tick(const float DeltaSeconds) +{ + Super::Tick(DeltaSeconds); + + if (PointsComponent1 && PointsComponent2 && !bGameEnded) + { + if (PointsComponent1->Points >= GoalScore) + { + UE_LOG(LogTemp, Warning, TEXT("Player 1 Wins!")); + bGameEnded = true; + } + else if (PointsComponent2->Points >= GoalScore) + { + UE_LOG(LogTemp, Warning, TEXT("Player 2 Wins!")); + bGameEnded = true; + } + } +} \ No newline at end of file diff --git a/Source/SkyFrontier/Private/TCPClient.cpp b/Source/SkyFrontier/Private/TCPClient.cpp deleted file mode 100644 index 4edafa8..0000000 --- a/Source/SkyFrontier/Private/TCPClient.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - -#include "TCPClient.h" - -#include "MyPlayerState.h" -#include "Sockets.h" -#include "SocketSubsystem.h" -#include "Interfaces/IPv4/IPv4Address.h" -#include "TraceServices/Model/Diagnostics.h" - -TCPClient::TCPClient(AMyPlayerState* pState) -{ - Thread = FRunnableThread::Create(this, TEXT("TCPClientThread"), 0, TPri_Normal); PlayerState = pState; -} -TCPClient::~TCPClient() -{ - TCPClient::Stop(); delete Thread; -} -void TCPClient::Stop() -{ - running = false; -} -bool TCPClient::IsConnected() -{ - return connected; -} - -bool TCPClient::Init() -{ - Socket = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateSocket(NAME_Stream, TEXT("default"), false); - int32 NewSize = 0; - Socket->SetReceiveBufferSize(1024, NewSize); - FIPv4Address matchmakingServerIP(127, 0, 0, 1); - TSharedRef matchmakingServer = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr(); - matchmakingServer->SetIp(matchmakingServerIP.Value); - matchmakingServer->SetPort(8856); - - connected = Socket->Connect(*matchmakingServer); - if (connected) - { - UE_LOG(LogTemp, Log, TEXT("CONNECTED!")); - FString serialized = TEXT("g|#"); - TCHAR *serializedChar = serialized.GetCharArray().GetData(); - int32 size = FCString::Strlen(serializedChar); - int32 sent = 0; - bool successful = Socket->Send((uint8*)TCHAR_TO_UTF8(serializedChar), size, sent); - if (successful) - {UE_LOG(LogTemp, Log, TEXT("MESSAGE SENT!")); - return true; - } - else - { - UE_LOG(LogTemp, Log, TEXT("ERROR: NOT CONNECTED!"));return false; - } - } - return 0; -} - uint32 TCPClient::Run() - { - running = true; - TArray ReceivedData; - while (running) - { - uint32 Size = 0; - if (Socket->HasPendingData(Size)) - { - ReceivedData.Init(0, Size); - int32 Read = 0; - Socket->Recv(ReceivedData.GetData(), ReceivedData.Num(), Read); - FString ServerMessage = FString(UTF8_TO_TCHAR(ReceivedData.GetData())); - UE_LOG(LogTemp, Log, TEXT("RECEIVED: %s"), *ServerMessage); - if ((ServerMessage[0] == 's') && (PlayerState)) - { - PlayerState->UpdateSessionsList(ServerMessage); - } - else if((ServerMessage[0] == 'o') && (PlayerState)) - { - TArray Out; - ServerMessage.ParseIntoArray(Out, TEXT("|"), true); - FSessionInfo session; - session.id = -1; - session.name = ""; - session.serverip = Out[1]; - session.serverport = FCString::Atoi(*Out[2]); - PlayerState->ConnectToGameServer(session); - } - } - } - return 0; - } - - void TCPClient::CreateNewGameSession(FString sname) - { - FString serialized = "c|" + sname + "|#"; - TCHAR *serializedChar = serialized.GetCharArray().GetData(); - int32 size = FCString::Strlen(serializedChar); - int32 sent = 0; - bool successful = Socket->Send((uint8*) TCHAR_TO_UTF8(serializedChar), size, sent); - if (successful) - UE_LOG(LogTemp, Log, TEXT("MESSAGE SENT!!!!")); - } - void TCPClient::JoinGameSession(int sID) - { - FString serialized = "j|" + FString::FromInt(sID) + "|#"; - TCHAR *serializedChar = serialized.GetCharArray().GetData(); - int32 size = FCString::Strlen(serializedChar); - int32 sent = 0; - bool successful = Socket->Send((uint8*) TCHAR_TO_UTF8(serializedChar), size, sent); - if (successful) - UE_LOG(LogTemp, Log, TEXT("MESSAGE SENT!!!!")); - } \ No newline at end of file diff --git a/Source/SkyFrontier/Public/DamageSystem.h b/Source/SkyFrontier/Public/DamageSystem.h index 3f660d8..0fc455d 100644 --- a/Source/SkyFrontier/Public/DamageSystem.h +++ b/Source/SkyFrontier/Public/DamageSystem.h @@ -1,5 +1,3 @@ -// Fill out your copyright notice in the Description page of Project Settings. - #pragma once #include "CoreMinimal.h" diff --git a/Source/SkyFrontier/Public/HealthSystem.h b/Source/SkyFrontier/Public/HealthSystem.h index 3f5377b..93d1e4e 100644 --- a/Source/SkyFrontier/Public/HealthSystem.h +++ b/Source/SkyFrontier/Public/HealthSystem.h @@ -1,49 +1,44 @@ -// Fill out your copyright notice in the Description page of Project Settings. - #pragma once #include "CoreMinimal.h" +#include "Net/UnrealNetwork.h" #include "Components/ActorComponent.h" #include "HealthSystem.generated.h" -DECLARE_EVENT_OneParam(UCPP_HealthComponent, DamageTakenEvent, float ) -DECLARE_EVENT_OneParam(UCPP_HealthComponent, HealDamageEvent, float ) -DECLARE_EVENT_OneParam(UCPP_HealthComponent, ShieldReceiveEvent, float ) +DECLARE_EVENT_OneParam(UCPP_HealthComponent, DamageTakenEvent, float) +DECLARE_EVENT_OneParam(UCPP_HealthComponent, HealDamageEvent, float) +DECLARE_EVENT_OneParam(UCPP_HealthComponent, ShieldReceiveEvent, float) -UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class SKYFRONTIER_API UHealthSystem : public UActorComponent { GENERATED_BODY() -public: +public: // Sets default values for this component's properties UHealthSystem(); - UFUNCTION(BlueprintPure) - float GetHealth() const; + float GetHealth() const; UFUNCTION(BlueprintPure) - float GetMaxHealth() const; + float GetMaxHealth() const; UFUNCTION(BlueprintPure) - float GetHealthAsPercentage() const; - UFUNCTION(BlueprintPure) - float GetShield() const; + float GetShield() const; UFUNCTION(BlueprintCallable) - void ModifyHealth(float Amount); - + void TakeDamage(float Amount); UFUNCTION(BlueprintCallable) - void TakeDamage(float Amount); + void RecoverHealth(float Amount); UFUNCTION(BlueprintCallable) - void RecoverHealth(float Amount); + void ReceiveShield(float Amount); UFUNCTION(BlueprintCallable) - void ReceiveShield(float Amount); - UFUNCTION(BlueprintCallable) - void RemoveShield(float Amount); + void RemoveShield(float Amount); protected: // Functions - virtual void BeginPlay() override; - + virtual void BeginPlay() override; + + virtual void GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const override; + public: // Events DamageTakenEvent OnDamageTakenEvent; @@ -52,11 +47,10 @@ private: // This can be protected if we want to subclass the Health Component - UPROPERTY(VisibleAnywhere) - float Health; + UPROPERTY(Replicated, VisibleAnywhere) + float Health; UPROPERTY(EditAnywhere) - float MaxHealth; + float MaxHealth; UPROPERTY(VisibleAnywhere) - float Shield; - + float Shield; }; diff --git a/Source/SkyFrontier/Public/MatchmakingJob.h b/Source/SkyFrontier/Public/MatchmakingJob.h new file mode 100644 index 0000000..d0b495a --- /dev/null +++ b/Source/SkyFrontier/Public/MatchmakingJob.h @@ -0,0 +1,43 @@ +#pragma once + +#include "CoreMinimal.h" + +// Bool if it did it's job correctly and the ip:port to connect to. +DECLARE_MULTICAST_DELEGATE_TwoParams(FOnMatchMakerThreadCompleted, bool, FString); + +// Declaration Of All The Messages The Clients Are Allowed To Send AKA The Message ID's +#define CLIENT_MESSAGE_REQUESTCONNECTION 1 +#define CLIENT_MESSAGE_CONFIRMDONE 2 + +class SKYFRONTIER_API MatchmakingJob : public FRunnable +{ +public: + // Dissalow default construction of this objects + // Simple example, but you could control the copy/move contructors and copy/move operators too! + MatchmakingJob(); + explicit MatchmakingJob(FString& stateToWriteInto); + +private: + // Do your setup here, allocate memory, ect. + virtual bool Init() override; + + // Main data processing happens here + virtual uint32 Run() override; + + // Called when thread is done + virtual void Exit() override; + + // Clean up any memory you allocated here happens when a stop is requested + virtual void Stop() override; + + void SleepThread(); + + // Reference To Strings That Exist In The Matchmaking System, Thread Writes Directly Into Them! + FString& currentState; + + // Pointer To Our Current Socket Object + FSocket* ConnectionSocket; + +public: + FOnMatchMakerThreadCompleted JobCompletedEvent; +}; \ No newline at end of file diff --git a/Source/SkyFrontier/Public/MatchmakingSubsystem.h b/Source/SkyFrontier/Public/MatchmakingSubsystem.h new file mode 100644 index 0000000..e8b8c0c --- /dev/null +++ b/Source/SkyFrontier/Public/MatchmakingSubsystem.h @@ -0,0 +1,38 @@ +#pragma once + +#include "CoreMinimal.h" +#include "MatchmakingJob.h" +#include "Subsystems/GameInstanceSubsystem.h" +#include "MatchmakingSubsystem.generated.h" + +DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnMatchFound, FString, ServerIP); + +UCLASS() +class SKYFRONTIER_API UMatchmakingSubsystem : public UGameInstanceSubsystem +{ + GENERATED_BODY() +public: + virtual void Initialize(FSubsystemCollectionBase& Collection) override; + + // Start Requesting A Game Launch the thread and the widget can poll the string value for an update till the threads done. + UFUNCTION(BlueprintCallable) + void RequestGame(); + + // Callback From The Thread When It's Done + UFUNCTION() + void OnMatchmakerThreadDone(bool CompletionState, FString ServerIP); + + // String the blueprint widget will look at + UPROPERTY(BlueprintReadOnly) + FString CurrentState; + + UPROPERTY(BlueprintReadOnly) + FString ServerToConnectTo; + + // Actual Threaded Job + MatchmakingJob* FindMatchJob; + + // Event To Let Someone Else Handle The Level Loading Stuff + UPROPERTY(BlueprintAssignable) + FOnMatchFound MatchFoundEvent; +}; \ No newline at end of file diff --git a/Source/SkyFrontier/Public/MyButton.h b/Source/SkyFrontier/Public/MyButton.h deleted file mode 100644 index 57e7828..0000000 --- a/Source/SkyFrontier/Public/MyButton.h +++ /dev/null @@ -1,26 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once - -#include "CoreMinimal.h" -#include "TCPClient.h" -#include "Components/Button.h" -#include "MyButton.generated.h" - -/** - * - */ -UCLASS() -class SKYFRONTIER_API UMyButton : public UButton -{ - GENERATED_BODY() -public: - UMyButton(); - void SetSessionInfo(int sID, TCPClient *tclient); -protected: int sessionID; - TCPClient *tcpClient; - - UFUNCTION() - void OnClick(); - -}; diff --git a/Source/SkyFrontier/Public/MyButtonHost.h b/Source/SkyFrontier/Public/MyButtonHost.h deleted file mode 100644 index c810c7b..0000000 --- a/Source/SkyFrontier/Public/MyButtonHost.h +++ /dev/null @@ -1,26 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once - -#include "CoreMinimal.h" -#include "TCPClient.h" -#include "Components/Button.h" -#include "MyButtonHost.generated.h" - -/** - * - */ -UCLASS() -class SKYFRONTIER_API UMyButtonHost : public UButton -{ - GENERATED_BODY() -public: - UMyButtonHost(); - void SetSessionInfo(FString sname, TCPClient *tclient); -protected: FString sessionName; - TCPClient *tcpClient; - - UFUNCTION() - void OnClick(); - -}; \ No newline at end of file diff --git a/Source/SkyFrontier/Public/MyPlayerState.h b/Source/SkyFrontier/Public/MyPlayerState.h deleted file mode 100644 index 816fe70..0000000 --- a/Source/SkyFrontier/Public/MyPlayerState.h +++ /dev/null @@ -1,52 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once - -#include "CoreMinimal.h" -#include "GameFramework/PlayerState.h" -#include "MyPlayerState.generated.h" - -USTRUCT() -struct FSessionInfo -{ - GENERATED_BODY() - UPROPERTY() - int id; - UPROPERTY() - FString name; - UPROPERTY() - FString serverip; - UPROPERTY() - int serverport; -}; - -UCLASS() -class SKYFRONTIER_API AMyPlayerState : public APlayerState -{ - GENERATED_BODY() -public: - void UpdateSessionsList(FString serverinfo); - void ConnectToGameServer(FSessionInfo session); - -protected: - virtual void BeginPlay() override; - - class TCPClient* tcpClient; - - UPROPERTY(EditDefaultsOnly, Category = "UI") - TSubclassOf MatchmakingWidgetClass; - class UUserWidget* MatchmakingWidget; - class UScrollBox* serverListScrollBoxWidget; - - TArray *serversList; - FTimerHandle serverListTimerHandle; - - bool canConnectToGameServer; - FSessionInfo connectToGameServerSession; - - UFUNCTION() - void OnNewSessionClicked(); - - UFUNCTION() - void OnUpdateServerList(); -}; diff --git a/Source/SkyFrontier/Public/PointsComponent.h b/Source/SkyFrontier/Public/PointsComponent.h new file mode 100644 index 0000000..5248c0f --- /dev/null +++ b/Source/SkyFrontier/Public/PointsComponent.h @@ -0,0 +1,39 @@ +#pragma once + +#include "CoreMinimal.h" +#include "Net/UnrealNetwork.h" +#include "Components/ActorComponent.h" +#include "PointsComponent.generated.h" + +DECLARE_EVENT_OneParam(UCPP_PointsComponent, PointsReceiveEvent, int) + +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) +class SKYFRONTIER_API UPointsComponent : public UActorComponent +{ + GENERATED_BODY() + +public: + UPointsComponent(); + + UFUNCTION(BlueprintCallable, Category = "Points") + int GetPoints() const; + + UFUNCTION(Server, Reliable, BlueprintCallable, Category = "Points") + void AddPoints(int PointsToAdd); + +protected: // Functions + + virtual void BeginPlay() override; + + virtual void GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const override; + + +public: // Events + + PointsReceiveEvent OnPointsReceiveEvent; + +public: + + UPROPERTY(Replicated, VisibleAnywhere, Category = "Points") + int Points; +}; \ No newline at end of file diff --git a/Source/SkyFrontier/Public/ScoreAttackGameMode.h b/Source/SkyFrontier/Public/ScoreAttackGameMode.h new file mode 100644 index 0000000..6afb7c1 --- /dev/null +++ b/Source/SkyFrontier/Public/ScoreAttackGameMode.h @@ -0,0 +1,28 @@ +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/GameModeBase.h" +#include "PointsComponent.h" +#include "ScoreAttackGameMode.generated.h" + +UCLASS() +class SKYFRONTIER_API AScoreAttackGameMode : public AGameModeBase +{ + GENERATED_BODY() + +public: + AScoreAttackGameMode(); + + virtual void PostInitializeComponents() override; + virtual void BeginPlay() override; + virtual void Tick(const float DeltaSeconds) override; + +private: + int GoalScore; + bool bGameEnded; + APawn* Pawn1; + APawn* Pawn2; + UPointsComponent* PointsComponent1; + UPointsComponent* PointsComponent2; + +}; \ No newline at end of file diff --git a/Source/SkyFrontier/Public/TCPClient.h b/Source/SkyFrontier/Public/TCPClient.h deleted file mode 100644 index 5e83447..0000000 --- a/Source/SkyFrontier/Public/TCPClient.h +++ /dev/null @@ -1,29 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once - -#include "CoreMinimal.h" - -/** - * - */ -class SKYFRONTIER_API TCPClient : public FRunnable -{ -public: - TCPClient(class AMyPlayerState* pState); - ~TCPClient(); - virtual bool Init(); - virtual uint32 Run(); - virtual void Stop(); - void CreateNewGameSession(FString sname); - void JoinGameSession(int sID); - bool IsConnected(); - -private: - FRunnableThread* Thread; - FSocket* Socket; - FSocket* ListenerSocket; - bool running; - bool connected; - class AMyPlayerState* PlayerState; -}; diff --git a/Source/SkyFrontierServer.Target.cs b/Source/SkyFrontierServer.Target.cs new file mode 100644 index 0000000..933dffa --- /dev/null +++ b/Source/SkyFrontierServer.Target.cs @@ -0,0 +1,14 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +using UnrealBuildTool; +using System.Collections.Generic; + +public class SkyFrontierServerTarget : TargetRules +{ + public SkyFrontierServerTarget( TargetInfo Target) : base(Target) + { + Type = TargetType.Server; + DefaultBuildSettings = BuildSettingsVersion.V2; + ExtraModuleNames.AddRange( new string[] { "SkyFrontier" } ); + } +}