Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added bot_add and bot_place commands #237

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Content/Environment/Ball/BP_Ball.uasset
Binary file not shown.
Binary file modified Content/Game/BP_Cloud9Console.uasset
Binary file not shown.
Binary file modified Content/Maps/warmup.umap
Binary file not shown.
12 changes: 4 additions & 8 deletions Source/Cloud9/Character/Cloud9Character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const FName ACloud9Character::AnimationComponentName = TEXT("AnimationComponent"
ACloud9Character::ACloud9Character(const FObjectInitializer& ObjectInitializer) : Super(
ObjectInitializer.SetDefaultSubobjectClass<UCloud9CharacterMovement>(CharacterMovementComponentName))
{
constexpr float CharacterHeight = 72.0f;
constexpr float CharacterHeight = 144.0f;
constexpr float CharacterRadius = 32.0f;
constexpr float CharacterRotationYaw = -90.0f;
constexpr float CharacterCameraBoomYaw = -60.0f;
Expand All @@ -70,7 +70,7 @@ ACloud9Character::ACloud9Character(const FObjectInitializer& ObjectInitializer)
DestroyAfterTime = 10.0f;

let MyCapsuleComponent = GetCapsuleComponent();
MyCapsuleComponent->InitCapsuleSize(CharacterRadius, CharacterHeight);
MyCapsuleComponent->InitCapsuleSize(CharacterRadius, CharacterHeight / 2.0f);
MyCapsuleComponent->CanCharacterStepUpOn = CanStepUpOn;

let Movement = GetCharacterMovement();
Expand All @@ -90,7 +90,7 @@ ACloud9Character::ACloud9Character(const FObjectInitializer& ObjectInitializer)
TopDownCameraComponent->bUsePawnControlRotation = false; // Camera does not rotate relative to arm

USkeletalMeshComponent* MyMesh = GetMesh();
MyMesh->SetRelativeLocation({0.0f, 0.0f, -CharacterHeight});
MyMesh->SetRelativeLocation({0.0f, 0.0f, -MyCapsuleComponent->GetScaledCapsuleHalfHeight()});
MyMesh->SetRelativeRotation({0.0f, CharacterRotationYaw, 0.0f});

// Create a decal in the world to show the cursor's location
Expand Down Expand Up @@ -264,11 +264,7 @@ UCloud9InventoryComponent* ACloud9Character::GetInventoryComponent() const { ret

UCloud9HealthComponent* ACloud9Character::GetHealthComponent() const { return HealthComponent; }

UCloud9AnimationComponent* ACloud9Character::GetAnimationComponent() const
{
assertf(IsValid(AnimationComponent), "AnimationComponent isn't valid")
return AnimationComponent;
}
UCloud9AnimationComponent* ACloud9Character::GetAnimationComponent() const { return AnimationComponent; }

void ACloud9Character::AddScore()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ UCloud9InventoryComponent::UCloud9InventoryComponent()
WeaponSlots.SetNum(SlotsNumber);
}

void UCloud9InventoryComponent::OnUnregister()
{
Super::OnUnregister();
// TODO: Drop the most expensive weapon when owner died but for now just destroy all items
WeaponSlots
| ETContainer::Filter{[](let It) { return It != nullptr; }}
| ETContainer::ForEach{[](let It) { It->Destroy(); }};
}

bool UCloud9InventoryComponent::Initialize(const TArray<FWeaponConfig>& WeaponConfigs, EWeaponSlot WeaponSlot)
{
WeaponConfigs
Expand Down
2 changes: 2 additions & 0 deletions Source/Cloud9/Character/Components/Cloud9InventoryComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class CLOUD9_API UCloud9InventoryComponent : public UActorComponent
public:
UCloud9InventoryComponent();

virtual void OnUnregister() override;

bool Initialize(const TArray<FWeaponConfig>& WeaponConfigs, EWeaponSlot WeaponSlot);

/**
Expand Down
16 changes: 14 additions & 2 deletions Source/Cloud9/Contollers/Cloud9MouseController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ UCloud9MouseController::UCloud9MouseController()

CameraRotationBase = FVector2D::ZeroVector;
IsMouseRotationMode = false;

bIsLastCrosshairLocationValid = false;
}

FVector2D UCloud9MouseController::GetMousePosition() const
Expand Down Expand Up @@ -113,7 +115,7 @@ void UCloud9MouseController::SetCameraZoomLevel(float Value) const
// ReSharper disable once CppMemberFunctionMayBeConst
void UCloud9MouseController::OnCharacterMove() { ProcessCharacterView(); }

void UCloud9MouseController::ProcessCharacterView() const
void UCloud9MouseController::ProcessCharacterView()
{
if (let Pawn = GetCloud9Pawn(); IsValid(Pawn))
{
Expand All @@ -126,7 +128,17 @@ void UCloud9MouseController::ProcessCharacterView() const
true,
ActorsToIgnore
};
Pawn->SetViewDirection(CursorHit);

if (CursorHit.IsSet())
{
LastCrosshairLocation = CursorHit->Location;
bIsLastCrosshairLocationValid = true;
Pawn->SetViewDirection(CursorHit);
}
else
{
bIsLastCrosshairLocationValid = true;
}
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion Source/Cloud9/Contollers/Cloud9MouseController.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class CLOUD9_API UCloud9MouseController
float GetCameraZoomHeightLevel() const;
void SetCameraZoomLevel(float Value) const;

void ProcessCharacterView() const;
void ProcessCharacterView();
void ProcessCameraRotation();
void ProcessCameraZoom(float DeltaTime);

Expand Down Expand Up @@ -107,6 +107,12 @@ class CLOUD9_API UCloud9MouseController
UPROPERTY(EditDefaultsOnly, Category = Smooth, meta=(AllowPrivateAccess))
float CameraZoomSmoothSpeed;

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=State, meta=(AllowPrivateAccess))
FVector LastCrosshairLocation;

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=State, meta=(AllowPrivateAccess))
bool bIsLastCrosshairLocationValid;

FVector2D CameraRotationBase;
float TargetCameraZoomLevel;
float TargetCameraZoomSpeed;
Expand Down
2 changes: 1 addition & 1 deletion Source/Cloud9/Weapon/Classes/Cloud9WeaponBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ bool ACloud9WeaponBase::ChangeState(EWeaponBond NewBond, bool Instant, bool Forc
}

if (let AnimComponent = Character->GetAnimationComponent();
not Force and AnimComponent->IsAnyMontagePlaying())
not Force and IsValid(AnimComponent) and AnimComponent->IsAnyMontagePlaying())
{
log(Verbose, "[Weapon='%s' Bond='%s'] Montage is playing now", *GetName(), BOND_NAME);
return false;
Expand Down
7 changes: 7 additions & 0 deletions Source/Cloud9/Weapon/Classes/Cloud9WeaponBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ class CLOUD9_API ACloud9WeaponBase : public AActor
return; \
}

#define WEAPON_ANIM_COMPONENT_GUARD() \
if (not IsValid(AnimComponent)) \
{ \
log(Warning, "[Weapon='%s'] AnimComponent isn't valid", *GetName()); \
return; \
}

#define WEAPON_IS_ACTION_IN_PROGRESS_GUARD() \
if (IsActionInProgress()) \
{ \
Expand Down
3 changes: 3 additions & 0 deletions Source/Cloud9/Weapon/Classes/Cloud9WeaponFirearm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ void ACloud9WeaponFirearm::Tick(float DeltaSeconds)

let Character = GetOwner<ACloud9Character>(); // suppose weapon has owner cus we pass bond guard
let AnimComponent = Character->GetAnimationComponent();

WEAPON_ANIM_COMPONENT_GUARD();

let WeaponInfo = WeaponDefinition.GetWeaponInfo<FFirearmWeaponInfo>();
let PoseMontages = WeaponDefinition.GetPoseMontages(Character->bIsCrouched);
let CommonData = WeaponDefinition.GetCommonData();
Expand Down
3 changes: 3 additions & 0 deletions Source/Cloud9/Weapon/Classes/Cloud9WeaponGrenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ void ACloud9WeaponGrenade::Tick(float DeltaSeconds)

let Character = GetOwner<ACloud9Character>();
let AnimComponent = Character->GetAnimationComponent();

WEAPON_ANIM_COMPONENT_GUARD();

let PoseMontages = WeaponDefinition.GetPoseMontages(Character->bIsCrouched);

if (WeaponState.IsActionActive(EWeaponAction::Deploy))
Expand Down
3 changes: 3 additions & 0 deletions Source/Cloud9/Weapon/Classes/Cloud9WeaponMelee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ void ACloud9WeaponMelee::Tick(float DeltaSeconds)

let Character = GetOwner<ACloud9Character>();
let AnimComponent = Character->GetAnimationComponent();

WEAPON_ANIM_COMPONENT_GUARD();

let WeaponInfo = WeaponDefinition.GetWeaponInfo<FMeleeWeaponInfo>();
let PoseMontages = WeaponDefinition.GetPoseMontages(Character->bIsCrouched);

Expand Down