diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index 23f3d48..4234916 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -132,6 +132,7 @@ ManualIPAddress= +Profiles=(Name="Vehicle",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Vehicle",CustomResponses=,HelpMessage="Vehicle object that blocks Vehicle, WorldStatic, and WorldDynamic. All other channels will be set to default.") +Profiles=(Name="UI",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility"),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ") +DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Block,bTraceType=True,bStaticObject=False,Name="Bullet") ++DefaultChannelResponses=(Channel=ECC_GameTraceChannel2,DefaultResponse=ECR_Block,bTraceType=True,bStaticObject=False,Name="Enemy") +EditProfiles=(Name="NoCollision",CustomResponses=((Channel="Bullet",Response=ECR_Ignore))) +EditProfiles=(Name="OverlapAll",CustomResponses=((Channel="Bullet",Response=ECR_Overlap))) +EditProfiles=(Name="CharacterMesh",CustomResponses=((Channel="Bullet",Response=ECR_Ignore))) diff --git a/Content/Legumix/Player/BP_Play.uasset b/Content/Legumix/Player/BP_Play.uasset index 47cf459..e6a6d6b 100644 --- a/Content/Legumix/Player/BP_Play.uasset +++ b/Content/Legumix/Player/BP_Play.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:281dcd4cdfd08af9eaa65e33fe67f7d72e40c10d2ca503cb9668058e15549aa0 -size 463534 +oid sha256:813c95fbfb8d7a2b4ebafcc92aa220525154747e5135f83e5e17c0dc9a4ee8fd +size 464175 diff --git a/Source/LegumeMix/Private/Player/LMHealthComponent.cpp b/Source/LegumeMix/Private/Player/LMHealthComponent.cpp index 8be1033..7aa5ebd 100644 --- a/Source/LegumeMix/Private/Player/LMHealthComponent.cpp +++ b/Source/LegumeMix/Private/Player/LMHealthComponent.cpp @@ -27,6 +27,7 @@ void ULMHealthComponent::RegisterHitBoxes() for (const auto HitBox : HitBoxes) { HitBox->OnHitBoxHit.AddUniqueDynamic(this, &ULMHealthComponent::HitBoxHit); + HitBox->SetHealthComponent(this); } } diff --git a/Source/LegumeMix/Private/Player/LMHitBox.cpp b/Source/LegumeMix/Private/Player/LMHitBox.cpp index ec2603a..c869bb8 100644 --- a/Source/LegumeMix/Private/Player/LMHitBox.cpp +++ b/Source/LegumeMix/Private/Player/LMHitBox.cpp @@ -4,6 +4,7 @@ #include "Player/LMHitBox.h" #include "Player/LMBulletInfo.h" +#include "Player/LMHealthComponent.h" ULMHitBox::ULMHitBox() @@ -20,6 +21,14 @@ void ULMHitBox::OnHit(const FLMBulletInfo& BulletInfo) OnHitBoxHit.Broadcast(this, TotalDamage); } +bool ULMHitBox::CanBeHitByTeam(const ETeam Team) const +{ + if (!HealthComponent) + return false; + + return HealthComponent->CanBeHurtByTeam(Team); +} + float ULMHitBox::CalculateDamage_Implementation(const float Damage, const float Distance, UCurveFloat* Falloff, const float MaxDistance) { const float Absorption = Damage - FlatDamageAbsorption; diff --git a/Source/LegumeMix/Private/Player/LMPlayer.cpp b/Source/LegumeMix/Private/Player/LMPlayer.cpp index c21a898..1d96f14 100644 --- a/Source/LegumeMix/Private/Player/LMPlayer.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayer.cpp @@ -13,18 +13,11 @@ #include "Player/LMHitBox.h" #include "Weapon/LMWeaponManager.h" + ALMPlayer::ALMPlayer() { PrimaryActorTick.bCanEverTick = true; - // Camera = CreateDefaultSubobject(TEXT("Camera")); - // Camera->SetupAttachment(RootComponent); - // Camera->bUsePawnControlRotation = true; - // Camera->SetRelativeLocation(FVector(20, 0, 90)); - // - // ArmsMesh = CreateDefaultSubobject(TEXT("Arms Mesh")); - // ArmsMesh->SetupAttachment(Camera); - SpreadStream = FRandomStream(FMath::Rand()); HealthComponent = CreateDefaultSubobject(TEXT("HealthComponent")); @@ -37,7 +30,6 @@ ALMPlayer::ALMPlayer() NextPlayerViewOcclusionPercent = 0.f; PlayerViewOcclusionPercent = 0.f; AlphaLerpForPlayerViewOcclusionPercent = 0.f; - } void ALMPlayer::BeginPlay() @@ -159,6 +151,9 @@ void ALMPlayer::FireBullets(const FLMBulletInfo Settings) if (ULMHitBox* HitBox = Cast(OutHit.Component)) { + if (!HitBox->CanBeHitByTeam(Team)) + continue; + HitSomething = true; HitBox->OnHit(Settings); } @@ -215,7 +210,6 @@ void ALMPlayer::SetDisplayDamageParameters(float Health, float Damage) } - void ALMPlayer::SetPlayerViewOcclusionPercent() { AlphaLerpForPlayerViewOcclusionPercent = 0; diff --git a/Source/LegumeMix/Public/LMTeam.h b/Source/LegumeMix/Public/LMTeam.h new file mode 100644 index 0000000..d483a6d --- /dev/null +++ b/Source/LegumeMix/Public/LMTeam.h @@ -0,0 +1,11 @@ +#pragma once + +UENUM(BlueprintType) +enum class ETeam : uint8 +{ + ET_None UMETA(Hidden), + ET_Player UMETA(DisplayName = "Player"), + ET_Enemy UMETA(DisplayName = "Enemy"), + ET_Other UMETA(DisplayName = "Other"), + ET_Max UMETA(Hidden), +}; diff --git a/Source/LegumeMix/Public/Player/LMHealthComponent.h b/Source/LegumeMix/Public/Player/LMHealthComponent.h index a780596..4bbe8ea 100644 --- a/Source/LegumeMix/Public/Player/LMHealthComponent.h +++ b/Source/LegumeMix/Public/Player/LMHealthComponent.h @@ -3,6 +3,7 @@ #pragma once #include "CoreMinimal.h" +#include "LMTeam.h" #include "Components/ActorComponent.h" #include "LMHealthComponent.generated.h" @@ -75,6 +76,9 @@ public: UFUNCTION(BlueprintCallable, Category=Legumix, meta=(Keywords = "Refill, Health")) void FillHealth() { Health = MaxHealth; } + UFUNCTION(BlueprintCallable, Category=Legumix, meta=(Keywords = "Team")) + bool CanBeHurtByTeam(const ETeam AttackingTeam) const { return Team != AttackingTeam; } + public: /** Delegate called when this component receives damages. */ UPROPERTY(BlueprintAssignable, Category=Legumix) @@ -97,6 +101,9 @@ private: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true, ClampMin=0, UIMin=0, UIMax=1000)) float MaxHealth = 100.f; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true)) + ETeam Team = ETeam::ET_Enemy; + /** * A list of all associated LMHitboxes. */ diff --git a/Source/LegumeMix/Public/Player/LMHitBox.h b/Source/LegumeMix/Public/Player/LMHitBox.h index 1990ebc..3fe025f 100644 --- a/Source/LegumeMix/Public/Player/LMHitBox.h +++ b/Source/LegumeMix/Public/Player/LMHitBox.h @@ -4,10 +4,13 @@ #include "CoreMinimal.h" #include "LMBulletInfo.h" +#include "LMTeam.h" #include "Components/CapsuleComponent.h" #include "LMHitBox.generated.h" +class ULMHealthComponent; + UCLASS(Blueprintable, ClassGroup=(Legumix), meta=(BlueprintSpawnableComponent)) class LEGUMEMIX_API ULMHitBox : public UCapsuleComponent { @@ -18,6 +21,8 @@ class LEGUMEMIX_API ULMHitBox : public UCapsuleComponent public: ULMHitBox(); void OnHit(const FLMBulletInfo& BulletInfo); + void SetHealthComponent(ULMHealthComponent* NewHealthComponent) { HealthComponent = NewHealthComponent; } + bool CanBeHitByTeam(ETeam Team) const; public: UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category=Legumix) @@ -43,4 +48,7 @@ private: */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true, ClampMin=0.0f, UIMin=0.0f)) float FlatDamageAbsorption = 0.f; + + UPROPERTY(Transient) + TObjectPtr HealthComponent; }; diff --git a/Source/LegumeMix/Public/Player/LMPlayer.h b/Source/LegumeMix/Public/Player/LMPlayer.h index f86b10c..875e418 100644 --- a/Source/LegumeMix/Public/Player/LMPlayer.h +++ b/Source/LegumeMix/Public/Player/LMPlayer.h @@ -4,6 +4,7 @@ #include "CoreMinimal.h" #include "LMBulletInfo.h" +#include "LMTeam.h" #include "Camera/CameraComponent.h" #include "GameFramework/Character.h" #include "LMPlayer.generated.h" @@ -173,6 +174,9 @@ private: UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category=Legumix, meta = (AllowPrivateAccess = true)) float AlphaLerpForPlayerViewOcclusionPercent; + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true)) + ETeam Team = ETeam::ET_Player; + /** * Actualize all parameters needed to calculate PlayerViewOcclusionPercent */