Skip to content

Commit

Permalink
#248 WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
xthebat committed Apr 25, 2024
1 parent c3b755a commit 67f9b8c
Show file tree
Hide file tree
Showing 21 changed files with 67 additions and 39 deletions.
Binary file modified Content/Characters/Common/Materials/M_CharacterBase.uasset
Binary file not shown.
Binary file added Content/Characters/Effects/BP_ShieldEffect.uasset
Binary file not shown.
Binary file modified Content/Characters/Sas/Materials/MI_ctm_sas_body.uasset
Binary file not shown.
Binary file modified Content/Characters/Sas/Materials/MI_ctm_sas_bodylegs.uasset
Binary file not shown.
Binary file modified Content/Characters/Sas/Materials/MI_ctm_sas_head_gasmask.uasset
Binary file not shown.
Binary file modified Content/Maps/warmup.umap
Binary file not shown.
Binary file modified Content/Modes/BP_Cloud9Default.uasset
Binary file not shown.
Binary file modified Content/Weapons/Rifle/ak47/Materials/MI_w_rifle_ak47_vulkan.uasset
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Source/Cloud9/Character/Cloud9Character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const FName ACloud9Character::SpringArmComponentName = TEXT("CameraBoom");
const FName ACloud9Character::CameraComponentName = TEXT("TopDownCamera");
const FName ACloud9Character::DecalComponentName = TEXT("CursorToWorld");
const FName ACloud9Character::InventoryComponentName = TEXT("InventoryComponent");
const FName ACloud9Character::EffectsComponentName = TEXT("EffectsComponent");
const FName ACloud9Character::HealthComponentName = TEXT("HealthComponent");
const FName ACloud9Character::AnimationComponentName = TEXT("AnimationComponent");
const FName ACloud9Character::WidgetInteractionComponentName = TEXT("WidgetInteractionComponent");
Expand Down Expand Up @@ -101,6 +102,7 @@ ACloud9Character::ACloud9Character(const FObjectInitializer& ObjectInitializer)
);
CursorToWorld->SetRelativeRotation({CrosshairRotationPitch, 0.0, 0.0f});

EffectsComponent = CreateDefaultSubobject<UCloud9EffectsComponent>(EffectsComponentName);
InventoryComponent = CreateDefaultSubobject<UCloud9InventoryComponent>(InventoryComponentName);
HealthComponent = CreateDefaultSubobject<UCloud9HealthComponent>(HealthComponentName);
AnimationComponent = CreateDefaultSubobject<UCloud9AnimationComponent>(AnimationComponentName);
Expand Down
1 change: 1 addition & 0 deletions Source/Cloud9/Character/Cloud9Character.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ACloud9Character : public ACharacter
static const FName CameraComponentName;
static const FName DecalComponentName;
static const FName InventoryComponentName;
static const FName EffectsComponentName;
static const FName HealthComponentName;
static const FName AnimationComponentName;
static const FName WidgetInteractionComponentName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ UCloud9EffectsComponent::UCloud9EffectsComponent()
UCloud9CharacterEffectTrait* UCloud9EffectsComponent::AddEffect(
TSubclassOf<UCloud9CharacterEffectTrait> EffectClass)
{
if (let Effect = NewObject<UCloud9CharacterEffectTrait>(this, EffectClass->StaticClass()); Effect->CanApply())
if (let Effect = NewObject<UCloud9CharacterEffectTrait>(this, EffectClass); Effect->CanApply())
{
Effect->OnApply();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class UCloud9EffectsComponent;

UCLASS()
UCLASS(Abstract, BlueprintType, Blueprintable, meta=(BlueprintSpawnableComponent))
class CLOUD9_API UCloud9CharacterEffectTrait : public UObject
{
GENERATED_BODY()
Expand Down
24 changes: 21 additions & 3 deletions Source/Cloud9/Character/Effects/Cloud9CharacterShieldEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include "Cloud9/Tools/Extensions/TContainer.h"

const FName UCloud9CharacterShieldEffect::ShieldEnableName = TEXT("Shield Enabled");
const FName UCloud9CharacterShieldEffect::ShieldReflectName = TEXT("Shield Reflect");
const FName UCloud9CharacterShieldEffect::ShieldPowerName = TEXT("Shield Power");
const FName UCloud9CharacterShieldEffect::ShieldColorName = TEXT("Shield Color");

void UCloud9CharacterShieldEffect::ToggleEffect(bool IsEnabled) const
{
Expand All @@ -23,17 +26,32 @@ void UCloud9CharacterShieldEffect::ToggleEffect(bool IsEnabled) const
Mesh->GetMaterials()
| ETContainer::Transform{[](let It) { return Cast<UMaterialInstanceDynamic>(It); }}
| ETContainer::Filter{[](let It) { return IsValid(It); }}
| ETContainer::ForEach{[IsEnabled](let It) { It->SetScalarParameterValue(ShieldEnableName, IsEnabled); }};
| ETContainer::ForEach{
[this, IsEnabled](let It)
{
if (IsEnabled)
{
It->SetScalarParameterValue(ShieldReflectName, Reflect);
It->SetScalarParameterValue(ShieldPowerName, Power);
It->SetVectorParameterValue(ShieldColorName, Color);
}

It->SetScalarParameterValue(ShieldEnableName, IsEnabled);
}
};
}
}

UCloud9CharacterShieldEffect::UCloud9CharacterShieldEffect()
{
EffectTime = 0.0f;
Duration = 5.0f;
Color = FLinearColor::Red;
Power = 10.0f;
Reflect = 0.004f;
ElapsedTime = 0.0f;
}

bool UCloud9CharacterShieldEffect::IsExtinguished_Implementation() const { return ElapsedTime >= EffectTime; }
bool UCloud9CharacterShieldEffect::IsExtinguished_Implementation() const { return ElapsedTime >= Duration; }

void UCloud9CharacterShieldEffect::OnApply_Implementation() { ToggleEffect(true); }

Expand Down
20 changes: 16 additions & 4 deletions Source/Cloud9/Character/Effects/Cloud9CharacterShieldEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,33 @@
#include "Cloud9CharacterShieldEffect.generated.h"


UCLASS(Blueprintable, meta=(BlueprintSpawnableComponent))
UCLASS(BlueprintType, Blueprintable, meta=(BlueprintSpawnableComponent))
class CLOUD9_API UCloud9CharacterShieldEffect : public UCloud9CharacterEffectTrait
{
GENERATED_BODY()

public:
static const FName ShieldEnableName;
static const FName ShieldReflectName;
static const FName ShieldPowerName;
static const FName ShieldColorName;

UCloud9CharacterShieldEffect();

protected:
UPROPERTY()
float EffectTime;
UPROPERTY(EditDefaultsOnly, Category=Config)
float Duration;

UPROPERTY()
UPROPERTY(EditDefaultsOnly, Category=Config)
FLinearColor Color;

UPROPERTY(EditDefaultsOnly, Category=Config)
float Reflect;

UPROPERTY(EditDefaultsOnly, Category=Config)
float Power;

UPROPERTY(BlueprintReadOnly, Category=Implementation)
float ElapsedTime;

virtual bool IsExtinguished_Implementation() const override;
Expand Down
4 changes: 4 additions & 0 deletions Source/Cloud9/Modes/Cloud9DefaultGameMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ bool ACloud9DefaultGameMode::OnWorldStart(FSavedInfo& SavedInfo)

Inventory->Initialize(PlayerConfig.WeaponConfigs, PlayerConfig.WeaponSlot);
Health->Initialize(PlayerConfig.HealthConfig);

PlayerConfig.Effects | ETContainer::ForEach{
[Character](let EffectClass) { Character->AddCharacterEffect(EffectClass); }
};
}
};
}
Expand Down
9 changes: 0 additions & 9 deletions Source/Cloud9/Structures/CommonGameInfo.cpp

This file was deleted.

21 changes: 0 additions & 21 deletions Source/Cloud9/Structures/CommonGameInfo.h

This file was deleted.

21 changes: 21 additions & 0 deletions Source/Cloud9/Structures/PlayerSavedInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,40 @@

#include "PlayerSavedInfo.generated.h"

class UCloud9CharacterEffectTrait;

/**
* Player's saved info to transfer between maps and initialize players.
* Transferring each of the properties depends on actual GameMode.
*/
USTRUCT(BlueprintType)
struct FPlayerSavedInfo
{
GENERATED_BODY()

/**
* Initial player's health
*/
UPROPERTY(Category=Health, EditDefaultsOnly, BlueprintReadOnly)
FHealthConfig HealthConfig;

/**
* Initial player's weapon starting slot
*/
UPROPERTY(Category=Weapon, EditDefaultsOnly, BlueprintReadOnly)
EWeaponSlot WeaponSlot = EWeaponSlot::NotSelected;

/**
* Initial player's weapons in inventory
*/
UPROPERTY(Category=Weapon, EditDefaultsOnly, BlueprintReadOnly)
TArray<FWeaponConfig> WeaponConfigs;

/**
* Initial player's applied effects (e.g., shield)
*/
UPROPERTY(Category=Effects, EditDefaultsOnly, BlueprintReadOnly)
TSet<TSubclassOf<UCloud9CharacterEffectTrait>> Effects;

void Reset();
};

0 comments on commit 67f9b8c

Please sign in to comment.