diff --git a/Source/Cloud9/Character/Cloud9Character.cpp b/Source/Cloud9/Character/Cloud9Character.cpp index 8a63c21eb..0f2c01dda 100644 --- a/Source/Cloud9/Character/Cloud9Character.cpp +++ b/Source/Cloud9/Character/Cloud9Character.cpp @@ -1,3 +1,26 @@ +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + #include "Cloud9Character.h" #include "DrawDebugHelpers.h" @@ -16,7 +39,6 @@ #include "GameFramework/SpringArmComponent.h" #include "Materials/Material.h" #include "Engine/World.h" -#include "GameFramework/GameUserSettings.h" #include "Kismet/KismetMathLibrary.h" class UCloud9SpringArmComponent; @@ -34,7 +56,7 @@ ACloud9Character::ACloud9Character(const FObjectInitializer& ObjectInitializer) GetCapsuleComponent()->InitCapsuleSize(32.f, 72.0f); - const auto Movement = GetCharacterMovement(); + let Movement = GetCharacterMovement(); Movement->bOrientRotationToMovement = false; Movement->bConstrainToPlane = true; Movement->bSnapToPlaneAtStart = true; @@ -62,7 +84,7 @@ ACloud9Character::ACloud9Character(const FObjectInitializer& ObjectInitializer) UCloud9CharacterMovement* ACloud9Character::GetCloud9CharacterMovement() const { - const auto Movement = GetCharacterMovement(); + let Movement = GetCharacterMovement(); return IsValid(Movement) ? Cast(Movement) : nullptr; } @@ -73,7 +95,7 @@ ACloud9PlayerController* ACloud9Character::GetCloud9Controller() const bool ACloud9Character::CanSneak() const { - if (const auto Movement = GetCloud9CharacterMovement(); IsValid(Movement)) + if (let Movement = GetCloud9CharacterMovement(); IsValid(Movement)) { return !Movement->IsCrouching(); } @@ -83,7 +105,7 @@ bool ACloud9Character::CanSneak() const void ACloud9Character::Sneak() const { - if (const auto Movement = GetCloud9CharacterMovement(); IsValid(Movement)) + if (let Movement = GetCloud9CharacterMovement(); IsValid(Movement)) { Movement->Sneak(); } @@ -91,7 +113,7 @@ void ACloud9Character::Sneak() const void ACloud9Character::UnSneak() const { - if (const auto Movement = GetCloud9CharacterMovement(); IsValid(Movement)) + if (let Movement = GetCloud9CharacterMovement(); IsValid(Movement)) { Movement->UnSneak(); } @@ -101,15 +123,15 @@ void ACloud9Character::SetViewDirection(const FHitResult& HitResult, bool bIsHit { if (IsValid(CursorToWorld)) { - const auto ImpactNormal = HitResult.ImpactNormal; - const auto ImpactRotation = ImpactNormal.Rotation(); + let ImpactNormal = HitResult.ImpactNormal; + let ImpactRotation = ImpactNormal.Rotation(); CursorToWorld->SetWorldLocation(HitResult.Location); CursorToWorld->SetWorldRotation(ImpactRotation); SetCursorIsHidden(false); } - const auto Settings = UCloud9DeveloperSettings::GetCloud9DeveloperSettings(); + let Settings = UCloud9DeveloperSettings::GetCloud9DeveloperSettings(); if (Settings->bIsDrawHitCursorLine) { @@ -146,9 +168,9 @@ void ACloud9Character::SetViewDirection(const FHitResult& HitResult, bool bIsHit if (bIsHitValid) { - const auto TargetLocation = FVector{HitResult.Location.X, HitResult.Location.Y, 0.0f}; - const auto ActorLocation = GetActorLocation(); - const auto LookRotation = UKismetMathLibrary::FindLookAtRotation(ActorLocation, TargetLocation); + let TargetLocation = FVector{HitResult.Location.X, HitResult.Location.Y, 0.0f}; + let ActorLocation = GetActorLocation(); + let LookRotation = UKismetMathLibrary::FindLookAtRotation(ActorLocation, TargetLocation); GetCloud9CharacterMovement()->Rotate({0.0f, LookRotation.Yaw, 0.0f}); } } @@ -169,13 +191,13 @@ void ACloud9Character::AddCameraRotationYaw(float Angle) const float ACloud9Character::GetCameraRotationRoll() const { - const auto Rotation = CameraBoom->GetRelativeRotation(); + let Rotation = CameraBoom->GetRelativeRotation(); return -Rotation.Pitch; } void ACloud9Character::SetCameraRotationRoll(float Angle) const { - auto Rotation = CameraBoom->GetRelativeRotation(); + var Rotation = CameraBoom->GetRelativeRotation(); Rotation.Pitch = -Angle; UE_LOG(LogCloud9, Display, TEXT("SetRelativeRotation Yaw: %s"), *Rotation.ToString()); CameraBoom->SetRelativeRotation(Rotation); @@ -204,7 +226,7 @@ void ACloud9Character::OnConstruction(const FTransform& Transform) UE_LOG(LogCloud9, Display, TEXT("Contruction transform %s"), *Transform.ToString()); - const auto Rotator = Transform.Rotator(); + let Rotator = Transform.Rotator(); SetCameraRotationYaw(Rotator.Yaw); GetCloud9CharacterMovement()->Rotate({0.0f, Rotator.Yaw, 0.0f}, true); @@ -218,9 +240,9 @@ void ACloud9Character::OnConstruction(const FTransform& Transform) CursorToWorld->DecalSize = FVector(16.0f, 32.0f, 32.0f); } - if (const auto MyMesh = GetMesh(); IsValid(MyMesh) && !CameraTargetBoneName.IsNone()) + if (let MyMesh = GetMesh(); IsValid(MyMesh) && !CameraTargetBoneName.IsNone()) { - const auto HeadBoneLocation = MyMesh->GetBoneLocation(CameraTargetBoneName, EBoneSpaces::WorldSpace); + let HeadBoneLocation = MyMesh->GetBoneLocation(CameraTargetBoneName, EBoneSpaces::WorldSpace); UE_LOG(LogCloud9, Display, TEXT("Setup CameraBoom = %s"), *HeadBoneLocation.ToString()); CameraBoom->SetWorldLocation(HeadBoneLocation); } diff --git a/Source/Cloud9/Character/Cloud9Character.h b/Source/Cloud9/Character/Cloud9Character.h index c66fec461..6a376d516 100644 --- a/Source/Cloud9/Character/Cloud9Character.h +++ b/Source/Cloud9/Character/Cloud9Character.h @@ -1,3 +1,26 @@ +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + #pragma once #include "CoreMinimal.h" diff --git a/Source/Cloud9/Character/Components/Cloud9CharacterComponent.cpp b/Source/Cloud9/Character/Components/Cloud9CharacterComponent.cpp index f102f2ee7..48375da96 100644 --- a/Source/Cloud9/Character/Components/Cloud9CharacterComponent.cpp +++ b/Source/Cloud9/Character/Components/Cloud9CharacterComponent.cpp @@ -1,21 +1,49 @@ -#include "Cloud9CharacterComponent.h" +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +#include "Cloud9CharacterComponent.h" + +#include "Cloud9/Cloud9.h" #include "Cloud9/Character/Cloud9Character.h" #include "Cloud9/Game/Cloud9PlayerController.h" ACloud9Character* ICloud9CharacterComponent::GetPawn() const { - if (const auto Component = Cast(this)) + if (let Component = Cast(this); IsValid(Component)) + { return Component->GetOwner(); + } return nullptr; } ACloud9PlayerController* ICloud9CharacterComponent::GetPlayerController() const { - if (const auto Pawn = GetPawn()) + if (let Pawn = GetPawn(); IsValid(Pawn)) + { return Cast(Pawn->GetController()); + } return nullptr; } diff --git a/Source/Cloud9/Character/Components/Cloud9CharacterComponent.h b/Source/Cloud9/Character/Components/Cloud9CharacterComponent.h index 3fff2a5b7..a4afb76b8 100644 --- a/Source/Cloud9/Character/Components/Cloud9CharacterComponent.h +++ b/Source/Cloud9/Character/Components/Cloud9CharacterComponent.h @@ -1,4 +1,27 @@ -#pragma once +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#pragma once #include "CoreMinimal.h" #include "UObject/Interface.h" diff --git a/Source/Cloud9/Character/Components/Cloud9CharacterMovement.cpp b/Source/Cloud9/Character/Components/Cloud9CharacterMovement.cpp index 1a270bd66..c27c0d4ec 100644 --- a/Source/Cloud9/Character/Components/Cloud9CharacterMovement.cpp +++ b/Source/Cloud9/Character/Components/Cloud9CharacterMovement.cpp @@ -1,4 +1,29 @@ -#include "Cloud9CharacterMovement.h" +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#include "Cloud9CharacterMovement.h" + +#include "Cloud9/Cloud9.h" #include "Cloud9/Character/Cloud9Character.h" UCloud9CharacterMovement::UCloud9CharacterMovement() @@ -10,7 +35,7 @@ UCloud9CharacterMovement::UCloud9CharacterMovement() MaxSneakSpeed = 270.0f; MaxWalkSpeedCrouched = 170.0f; - auto& NavAgentProperties = GetNavAgentPropertiesRef(); + var& NavAgentProperties = GetNavAgentPropertiesRef(); NavAgentProperties.bCanCrouch = true; NavAgentProperties.bCanSwim = false; NavAgentProperties.bCanFly = false; @@ -23,13 +48,13 @@ ACloud9Character* UCloud9CharacterMovement::GetCloud9CharacterOwner() const bool UCloud9CharacterMovement::IsSneaking() const { - const auto Owner = GetCloud9CharacterOwner(); + let Owner = GetCloud9CharacterOwner(); return IsValid(Owner) && Owner->bIsSneaking; } void UCloud9CharacterMovement::Sneak() const { - if (const auto Owner = GetCloud9CharacterOwner(); IsValid(Owner)) + if (let Owner = GetCloud9CharacterOwner(); IsValid(Owner)) { Owner->bIsSneaking = true; } @@ -37,7 +62,7 @@ void UCloud9CharacterMovement::Sneak() const void UCloud9CharacterMovement::UnSneak() const { - if (const auto Owner = GetCloud9CharacterOwner(); IsValid(Owner)) + if (let Owner = GetCloud9CharacterOwner(); IsValid(Owner)) { Owner->bIsSneaking = false; } @@ -47,7 +72,7 @@ void UCloud9CharacterMovement::Rotate(FRotator Rotator, bool Instant) { TargetRotator = Rotator; - if (const auto Owner = GetCloud9CharacterOwner(); Instant && IsValid(Owner)) + if (let Owner = GetCloud9CharacterOwner(); Instant && IsValid(Owner)) { Owner->SetActorRotation(TargetRotator); } @@ -55,7 +80,7 @@ void UCloud9CharacterMovement::Rotate(FRotator Rotator, bool Instant) float UCloud9CharacterMovement::GetMaxSpeed() const { - const auto MaxSpeed = Super::GetMaxSpeed(); + let MaxSpeed = Super::GetMaxSpeed(); return IsSneaking() ? FMath::Min(MaxSneakSpeed, MaxSpeed) : MaxSpeed; } @@ -66,12 +91,12 @@ void UCloud9CharacterMovement::TickComponent( { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); - if (const auto Owner = GetCloud9CharacterOwner(); IsValid(Owner)) + if (let Owner = GetCloud9CharacterOwner(); IsValid(Owner)) { - auto NewRotation = TargetRotator; + var NewRotation = TargetRotator; if (RotationLag != 0.0f) { - const auto ActorRotation = Owner->GetActorRotation(); + let ActorRotation = Owner->GetActorRotation(); NewRotation = FMath::Lerp(ActorRotation, TargetRotator, DeltaTime / RotationLag * RotationLagScale); } Owner->SetActorRotation(NewRotation); diff --git a/Source/Cloud9/Character/Components/Cloud9CharacterMovement.h b/Source/Cloud9/Character/Components/Cloud9CharacterMovement.h index ef8005537..ace9c8f07 100644 --- a/Source/Cloud9/Character/Components/Cloud9CharacterMovement.h +++ b/Source/Cloud9/Character/Components/Cloud9CharacterMovement.h @@ -1,4 +1,27 @@ -#pragma once +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#pragma once #include "CoreMinimal.h" #include "Cloud9CharacterComponent.h" diff --git a/Source/Cloud9/Character/Components/Cloud9Inventory.cpp b/Source/Cloud9/Character/Components/Cloud9Inventory.cpp index 195ae80aa..eef9bd8da 100644 --- a/Source/Cloud9/Character/Components/Cloud9Inventory.cpp +++ b/Source/Cloud9/Character/Components/Cloud9Inventory.cpp @@ -1,4 +1,27 @@ -#include "Cloud9Inventory.h" +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#include "Cloud9Inventory.h" #include "Cloud9/Cloud9.h" #include "Cloud9/Weapon/Cloud9WeaponBase.h" @@ -11,7 +34,7 @@ UCloud9Inventory::UCloud9Inventory() SelectedWeaponSlot = EWeaponSlot::NotSelected; PendingWeaponSlot = EWeaponSlot::NotSelected; - const auto SlotsNumber = StaticEnum()->NumEnums(); + let SlotsNumber = StaticEnum()->NumEnums(); WeaponSlots.SetNum(SlotsNumber); DefaultKnifeClass = ACloud9WeaponKnife::StaticClass(); @@ -24,9 +47,9 @@ void UCloud9Inventory::BeginPlay() FActorSpawnParameters SpawnParams; SpawnParams.Owner = GetOwner(); - const auto DefaultKnife = GetWorld()->SpawnActor(DefaultKnifeClass, SpawnParams); - const auto DefaultPistol = GetWorld()->SpawnActor(DefaultPistolClass, SpawnParams); - // const auto DefaultMain = GetWorld()->SpawnActor(ACloud9WeaponSniper::StaticClass(), SpawnParams); + let DefaultKnife = GetWorld()->SpawnActor(DefaultKnifeClass, SpawnParams); + let DefaultPistol = GetWorld()->SpawnActor(DefaultPistolClass, SpawnParams); + // let DefaultMain = GetWorld()->SpawnActor(ACloud9WeaponSniper::StaticClass(), SpawnParams); SetWeaponAt(EWeaponSlot::Knife, DefaultKnife); SetWeaponAt(EWeaponSlot::Pistol, DefaultPistol); @@ -43,19 +66,23 @@ bool UCloud9Inventory::SelectWeapon(EWeaponSlot Slot) return false; } - if (Slot == SelectedWeaponSlot) - return true; - - if (const auto PendingWeapon = GetWeaponAt(Slot)) + if (Slot != SelectedWeaponSlot) { - if (const auto SelectedWeapon = GetWeaponAt(SelectedWeaponSlot)) - SelectedWeapon->SetActorHiddenInGame(true); - PendingWeapon->SetActorHiddenInGame(false); - PendingWeaponSlot = Slot; - return true; + if (let PendingWeapon = GetWeaponAt(Slot)) + { + if (let SelectedWeapon = GetWeaponAt(SelectedWeaponSlot)) + { + SelectedWeapon->SetActorHiddenInGame(true); + } + PendingWeapon->SetActorHiddenInGame(false); + PendingWeaponSlot = Slot; + return true; + } + + return false; } - return false; + return true; } void UCloud9Inventory::OnWeaponChangeFinished() { SelectedWeaponSlot = PendingWeaponSlot; } @@ -63,16 +90,18 @@ void UCloud9Inventory::OnWeaponChangeFinished() { SelectedWeaponSlot = PendingWe bool UCloud9Inventory::SetWeaponAt(EWeaponSlot Slot, ACloud9WeaponBase* Weapon) { if (GetWeaponAt(Slot)) + { return false; + } - const auto Index = static_cast(Slot); + let Index = static_cast(Slot); WeaponSlots[Index] = Weapon; return true; } ACloud9WeaponBase* UCloud9Inventory::GetWeaponAt(EWeaponSlot Slot) const { - const auto Index = static_cast(Slot); + let Index = static_cast(Slot); return WeaponSlots[Index]; } @@ -82,16 +111,20 @@ bool UCloud9Inventory::IsWeaponChanging() const { return SelectedWeaponSlot != P EWeaponType UCloud9Inventory::GetSelectedWeaponType() const { - if (const auto Weapon = GetWeaponAt(SelectedWeaponSlot)) + if (let Weapon = GetWeaponAt(SelectedWeaponSlot)) + { return Weapon->GetWeaponType(); + } return EWeaponType::NoWeapon; } EWeaponType UCloud9Inventory::GetPendingWeaponType() const { - if (const auto Weapon = GetWeaponAt(PendingWeaponSlot)) + if (let Weapon = GetWeaponAt(PendingWeaponSlot)) + { return Weapon->GetWeaponType(); + } return EWeaponType::NoWeapon; } diff --git a/Source/Cloud9/Character/Components/Cloud9Inventory.h b/Source/Cloud9/Character/Components/Cloud9Inventory.h index 732b3a1c7..1faebc24e 100644 --- a/Source/Cloud9/Character/Components/Cloud9Inventory.h +++ b/Source/Cloud9/Character/Components/Cloud9Inventory.h @@ -1,4 +1,27 @@ -#pragma once +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#pragma once #include "CoreMinimal.h" #include "Cloud9CharacterComponent.h" @@ -15,13 +38,13 @@ class ACloud9WeaponBase; UCLASS(Blueprintable) class CLOUD9_API UCloud9Inventory : public UActorComponent - , public ICloud9CharacterComponent + , public ICloud9CharacterComponent { GENERATED_BODY() public: UCloud9Inventory(); - + UFUNCTION(BlueprintCallable) bool SelectWeapon(EWeaponSlot Slot); @@ -33,10 +56,10 @@ class CLOUD9_API UCloud9Inventory UFUNCTION(BlueprintCallable) EWeaponSlot GetSelectedWeaponSlot() const; - + UFUNCTION(BlueprintCallable) bool SetWeaponAt(EWeaponSlot Slot, ACloud9WeaponBase* Weapon); - + UFUNCTION(BlueprintCallable) ACloud9WeaponBase* GetWeaponAt(EWeaponSlot Slot) const; @@ -45,16 +68,16 @@ class CLOUD9_API UCloud9Inventory UFUNCTION(BlueprintCallable) bool IsWeaponChanging() const; - + UFUNCTION(BlueprintCallable) void OnWeaponChangeFinished(); protected: virtual void BeginPlay() override; - + UPROPERTY(EditDefaultsOnly, Category = Weapons, meta = (AllowPrivateAccess = "true")) TSubclassOf DefaultKnifeClass; - + UPROPERTY(EditDefaultsOnly, Category = Weapons, meta = (AllowPrivateAccess = "true")) TSubclassOf DefaultPistolClass; diff --git a/Source/Cloud9/Character/Components/Cloud9SpringArmComponent.cpp b/Source/Cloud9/Character/Components/Cloud9SpringArmComponent.cpp index dff34bd3c..744ff7752 100644 --- a/Source/Cloud9/Character/Components/Cloud9SpringArmComponent.cpp +++ b/Source/Cloud9/Character/Components/Cloud9SpringArmComponent.cpp @@ -1,5 +1,29 @@ -#include "Cloud9SpringArmComponent.h" - +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#include "Cloud9SpringArmComponent.h" + +#include "Cloud9/Cloud9.h" #include "Cloud9/Tools/Cloud9ToolsLibrary.h" @@ -61,7 +85,7 @@ void UCloud9SpringArmComponent::UpdateDesiredArmLocation( FVector DesiredLoc = ArmOrigin; if (bDoLocationLag) { - const auto LocationLag = CameraLagSpeed * CameraLagVector; + let LocationLag = CameraLagSpeed * CameraLagVector; if (bUseCameraLagSubstepping && DeltaTime > CameraLagMaxTimeStep @@ -86,7 +110,7 @@ void UCloud9SpringArmComponent::UpdateDesiredArmLocation( DesiredLoc = UCloud9ToolsLibrary::VInterpTo(PreviousDesiredLoc, DesiredLoc, DeltaTime, LocationLag); } - if (const auto FromOrigin = DesiredLoc - ArmOrigin; + if (let FromOrigin = DesiredLoc - ArmOrigin; CameraLagMaxDistance > 0.f && FromOrigin.SizeSquared() > FMath::Square(CameraLagMaxDistance)) { DesiredLoc = ArmOrigin + FromOrigin.GetClampedToMaxSize(CameraLagMaxDistance); diff --git a/Source/Cloud9/Character/Components/Cloud9SpringArmComponent.h b/Source/Cloud9/Character/Components/Cloud9SpringArmComponent.h index b6ff9ab8e..16ce19899 100644 --- a/Source/Cloud9/Character/Components/Cloud9SpringArmComponent.h +++ b/Source/Cloud9/Character/Components/Cloud9SpringArmComponent.h @@ -1,4 +1,27 @@ -#pragma once +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#pragma once #include "CoreMinimal.h" #include "GameFramework/SpringArmComponent.h" diff --git a/Source/Cloud9/Character/Enums/Cloud9WeaponClass.h b/Source/Cloud9/Character/Enums/Cloud9WeaponClass.h index 6157a66d0..f73f82509 100644 --- a/Source/Cloud9/Character/Enums/Cloud9WeaponClass.h +++ b/Source/Cloud9/Character/Enums/Cloud9WeaponClass.h @@ -1,4 +1,27 @@ -#pragma once +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#pragma once UENUM(BlueprintType) enum class EWeaponClass : uint8 diff --git a/Source/Cloud9/Character/Enums/Cloud9WeaponSlot.h b/Source/Cloud9/Character/Enums/Cloud9WeaponSlot.h index 60d6601ae..cc089ced3 100644 --- a/Source/Cloud9/Character/Enums/Cloud9WeaponSlot.h +++ b/Source/Cloud9/Character/Enums/Cloud9WeaponSlot.h @@ -1,4 +1,27 @@ -#pragma once +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#pragma once UENUM(BlueprintType) enum class EWeaponSlot : uint8 diff --git a/Source/Cloud9/Character/Enums/Cloud9WeaponType.h b/Source/Cloud9/Character/Enums/Cloud9WeaponType.h index d826c601e..0c922c12c 100644 --- a/Source/Cloud9/Character/Enums/Cloud9WeaponType.h +++ b/Source/Cloud9/Character/Enums/Cloud9WeaponType.h @@ -1,4 +1,27 @@ -#pragma once +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#pragma once UENUM(BlueprintType) enum class EWeaponType : uint8 @@ -7,12 +30,12 @@ enum class EWeaponType : uint8 Knife UMETA(DisplayName = "Knife"), Pistol UMETA(DisplayName = "Pistol"), - + Smg UMETA(DisplayName = "Smg"), Shotgun UMETA(DisplayName = "Shotgun"), Rifle UMETA(DisplayName = "Rifle"), Sniper UMETA(DisplayName = "Sniper"), - + Heavy UMETA(DisplayName = "Heavy"), Grenade UMETA(DisplayName = "Grenade"), C4 UMETA(DisplayName = "C4"), diff --git a/Source/Cloud9/Console/Cloud9Console.cpp b/Source/Cloud9/Console/Cloud9Console.cpp index dd7b9e73a..af72bc141 100644 --- a/Source/Cloud9/Console/Cloud9Console.cpp +++ b/Source/Cloud9/Console/Cloud9Console.cpp @@ -1,6 +1,27 @@ -#include "Cloud9Console.h" +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. -#include "Cloud9/Cloud9.h" +#include "Cloud9Console.h" UCloud9Console::UCloud9Console() { diff --git a/Source/Cloud9/Console/Cloud9Console.h b/Source/Cloud9/Console/Cloud9Console.h index f10a2c373..d91f9e9b9 100644 --- a/Source/Cloud9/Console/Cloud9Console.h +++ b/Source/Cloud9/Console/Cloud9Console.h @@ -1,4 +1,27 @@ -#pragma once +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#pragma once #include "CoreMinimal.h" #include "GameFramework/Actor.h" diff --git a/Source/Cloud9/Console/Cloud9ConsoleComponent.cpp b/Source/Cloud9/Console/Cloud9ConsoleComponent.cpp index 5cf6cbb95..d4c0db443 100644 --- a/Source/Cloud9/Console/Cloud9ConsoleComponent.cpp +++ b/Source/Cloud9/Console/Cloud9ConsoleComponent.cpp @@ -1,6 +1,28 @@ -#include "Cloud9ConsoleComponent.h" +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#include "Cloud9ConsoleComponent.h" #include "Cloud9Console.h" -#include "Cloud9/Cloud9.h" UCloud9ConsoleComponent::UCloud9ConsoleComponent() { @@ -15,21 +37,13 @@ void UCloud9ConsoleComponent::BeginPlay() Super::BeginPlay(); // We only want to spawn the objects on the server, so they replicate down to the client. - if (!GetOwner()->HasAuthority()) - return; - - if (ConsoleClass == nullptr) - return; - - const auto Owner = GetOwner(); - - Console = NewObject(Owner, ConsoleClass); + if (GetOwner()->HasAuthority() && IsValid(ConsoleClass)) + { + Console = NewObject(GetOwner(), ConsoleClass); + } } bool UCloud9ConsoleComponent::ProcessConsoleExec(const TCHAR* Cmd, FOutputDevice& Ar, UObject* Executor) { - if (Console->ProcessConsoleExec(Cmd, Ar, Executor)) - return true; - - return Super::ProcessConsoleExec(Cmd, Ar, Executor); + return Console->ProcessConsoleExec(Cmd, Ar, Executor) ? true : Super::ProcessConsoleExec(Cmd, Ar, Executor); } diff --git a/Source/Cloud9/Console/Cloud9ConsoleComponent.h b/Source/Cloud9/Console/Cloud9ConsoleComponent.h index 333f82508..6b5389805 100644 --- a/Source/Cloud9/Console/Cloud9ConsoleComponent.h +++ b/Source/Cloud9/Console/Cloud9ConsoleComponent.h @@ -1,4 +1,27 @@ -#pragma once +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#pragma once #include "CoreMinimal.h" #include "Kismet/BlueprintFunctionLibrary.h" diff --git a/Source/Cloud9/Game/Cloud9ControllerComponent.cpp b/Source/Cloud9/Game/Cloud9ControllerComponent.cpp index b961e711b..ac54b7b1c 100644 --- a/Source/Cloud9/Game/Cloud9ControllerComponent.cpp +++ b/Source/Cloud9/Game/Cloud9ControllerComponent.cpp @@ -1,20 +1,48 @@ -#include "Cloud9ControllerComponent.h" +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#include "Cloud9ControllerComponent.h" #include "Cloud9PlayerController.h" +#include "Cloud9/Cloud9.h" #include "Cloud9/Character/Cloud9Character.h" ACloud9Character* ICloud9ControllerComponent::GetCloud9Pawn() const { - if (const auto Controller = GetCloud9Controller()) + if (let Controller = GetCloud9Controller(); IsValid(Controller)) + { return Controller->GetPawn(); + } return nullptr; } ACloud9PlayerController* ICloud9ControllerComponent::GetCloud9Controller() const { - if (const auto Component = Cast(this)) + if (let Component = Cast(this)) + { return Component->GetOwner(); - + } + return nullptr; } diff --git a/Source/Cloud9/Game/Cloud9ControllerComponent.h b/Source/Cloud9/Game/Cloud9ControllerComponent.h index eb97abd7a..29c27921b 100644 --- a/Source/Cloud9/Game/Cloud9ControllerComponent.h +++ b/Source/Cloud9/Game/Cloud9ControllerComponent.h @@ -1,4 +1,27 @@ -#pragma once +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#pragma once #include "CoreMinimal.h" #include "UObject/Interface.h" diff --git a/Source/Cloud9/Game/Cloud9GameMode.cpp b/Source/Cloud9/Game/Cloud9GameMode.cpp index b0c385ed2..71ead80cb 100644 --- a/Source/Cloud9/Game/Cloud9GameMode.cpp +++ b/Source/Cloud9/Game/Cloud9GameMode.cpp @@ -1,7 +1,31 @@ +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + #include "Cloud9GameMode.h" #include "Cloud9DeveloperSettings.h" #include "Cloud9PlayerController.h" +#include "Cloud9/Cloud9.h" #include "Cloud9/Character/Cloud9Character.h" #include "UObject/ConstructorHelpers.h" @@ -22,15 +46,14 @@ void ACloud9GameMode::Tick(float DeltaSeconds) { Super::Tick(DeltaSeconds); - const auto Settings = UCloud9DeveloperSettings::GetCloud9DeveloperSettings(); + let Settings = UCloud9DeveloperSettings::GetCloud9DeveloperSettings(); if (Settings->NetGraph > 0) { - const auto Fps = 1.0f / DeltaSeconds; - - const auto Location = GetCharacter()->GetActorLocation(); - const auto Velocity = GetCharacter()->GetVelocity(); - const auto Text = FString::Printf( + let Fps = 1.0f / DeltaSeconds; + let Location = GetCharacter()->GetActorLocation(); + let Velocity = GetCharacter()->GetVelocity(); + let Text = FString::Printf( TEXT("Location = %s Velocity = %.0f fps = %.1f"), *Location.ToString(), Velocity.Size(), diff --git a/Source/Cloud9/Game/Cloud9GameMode.h b/Source/Cloud9/Game/Cloud9GameMode.h index 539e9823c..30f03643e 100644 --- a/Source/Cloud9/Game/Cloud9GameMode.h +++ b/Source/Cloud9/Game/Cloud9GameMode.h @@ -1,4 +1,25 @@ -// Copyright Epic Games, Inc. All Rights Reserved. +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. #pragma once diff --git a/Source/Cloud9/Game/Cloud9KeyboardController.cpp b/Source/Cloud9/Game/Cloud9KeyboardController.cpp index 5bf1ab5ab..53afd2984 100644 --- a/Source/Cloud9/Game/Cloud9KeyboardController.cpp +++ b/Source/Cloud9/Game/Cloud9KeyboardController.cpp @@ -1,5 +1,31 @@ -// ReSharper disable CppMemberFunctionMayBeConst +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +// ReSharper disable CppMemberFunctionMayBeConst + #include "Cloud9KeyboardController.h" + +#include "Cloud9/Cloud9.h" #include "Cloud9/Character/Enums/Cloud9WeaponSlot.h" #include "GameFramework/SpringArmComponent.h" @@ -19,17 +45,18 @@ void UCloud9KeyboardController::TickComponent( { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); - const auto Pawn = GetCloud9Pawn(); - - if (IsValid(Pawn) && (FMath::Abs(ForwardScale) > 0.0f ||FMath::Abs(RightScale) > 0.0f)) + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn)) { - const auto FV = ForwardScale * Pawn->GetCameraBoom()->GetForwardVector(); - const auto RV = RightScale * Pawn->GetCameraBoom()->GetRightVector(); - - auto DirectionXY = FVector{FV.X + RV.X, FV.Y + RV.Y, 0.0f}; - DirectionXY.Normalize(); - Pawn->AddMovementInput(DirectionXY); - OnMoveDelegate.Broadcast(); + if (FMath::Abs(ForwardScale) > 0.0f || FMath::Abs(RightScale) > 0.0f) + { + let FV = ForwardScale * Pawn->GetCameraBoom()->GetForwardVector(); + let RV = RightScale * Pawn->GetCameraBoom()->GetRightVector(); + + var DirectionXY = FVector{FV.X + RV.X, FV.Y + RV.Y, 0.0f}; + DirectionXY.Normalize(); + Pawn->AddMovementInput(DirectionXY); + OnMoveDelegate.Broadcast(); + } } // UpdateMove([](auto Pawn) { return Pawn->GetCameraBoom()->GetForwardVector(); }, ForwardScale); @@ -39,12 +66,10 @@ void UCloud9KeyboardController::TickComponent( template void UCloud9KeyboardController::UpdateMove(TGetDirection GetDirection, float Scale) { - const auto Pawn = GetCloud9Pawn(); - - if (IsValid(Pawn) && FMath::Abs(Scale) > 0.0f) + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn) && FMath::Abs(Scale) > 0.0f) { - auto Direction3D = GetDirection(Pawn); - auto DirectionXY = FVector{Direction3D.X, Direction3D.Y, 0.0f}; + var Direction3D = GetDirection(Pawn); + var DirectionXY = FVector{Direction3D.X, Direction3D.Y, 0.0f}; DirectionXY.Normalize(); Pawn->AddMovementInput(DirectionXY, Scale); OnMoveDelegate.Broadcast(); @@ -57,73 +82,95 @@ void UCloud9KeyboardController::OnMoveRight(float Value) { RightScale = Value; } void UCloud9KeyboardController::OnWalkPressed() { - if (IsValid(GetCloud9Pawn())) - GetCloud9Pawn()->Sneak(); + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn)) + { + Pawn->Sneak(); + } } void UCloud9KeyboardController::OnWalkReleased() { - if (IsValid(GetCloud9Pawn())) - GetCloud9Pawn()->UnSneak(); + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn)) + { + Pawn->UnSneak(); + } } void UCloud9KeyboardController::OnCrouchPressed() { - if (IsValid(GetCloud9Pawn())) - GetCloud9Pawn()->Crouch(false); + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn)) + { + Pawn->Crouch(false); + } } void UCloud9KeyboardController::OnCrouchReleased() { - if (IsValid(GetCloud9Pawn())) - GetCloud9Pawn()->UnCrouch(false); + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn)) + { + Pawn->UnCrouch(false); + } } void UCloud9KeyboardController::OnJumpPressed() { - if (IsValid(GetCloud9Pawn())) - GetCloud9Pawn()->Jump(); + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn)) + { + Pawn->Jump(); + } } void UCloud9KeyboardController::OnJumpReleased() { - if (IsValid(GetCloud9Pawn())) - GetCloud9Pawn()->StopJumping(); + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn)) + { + Pawn->StopJumping(); + } } void UCloud9KeyboardController::OnSlot1() { - if (IsValid(GetCloud9Pawn())) - GetCloud9Pawn()->GetInventory()->SelectWeapon(EWeaponSlot::Main); + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn)) + { + Pawn->GetInventory()->SelectWeapon(EWeaponSlot::Main); + } } void UCloud9KeyboardController::OnSlot2() { - if (IsValid(GetCloud9Pawn())) - GetCloud9Pawn()->GetInventory()->SelectWeapon(EWeaponSlot::Pistol); + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn)) + { + Pawn->GetInventory()->SelectWeapon(EWeaponSlot::Pistol); + } } void UCloud9KeyboardController::OnSlot3() { - if (IsValid(GetCloud9Pawn())) - GetCloud9Pawn()->GetInventory()->SelectWeapon(EWeaponSlot::Knife); + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn)) + { + Pawn->GetInventory()->SelectWeapon(EWeaponSlot::Knife); + } } void UCloud9KeyboardController::OnSlot4() { - if (IsValid(GetCloud9Pawn())) - GetCloud9Pawn()->GetInventory()->SelectWeapon(EWeaponSlot::Grenade); + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn)) + { + Pawn->GetInventory()->SelectWeapon(EWeaponSlot::Grenade); + } } void UCloud9KeyboardController::OnSlot5() { - if (IsValid(GetCloud9Pawn())) - GetCloud9Pawn()->GetInventory()->SelectWeapon(EWeaponSlot::Stuff); + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn)) + { + Pawn->GetInventory()->SelectWeapon(EWeaponSlot::Stuff); + } } void UCloud9KeyboardController::Reload() { - if (IsValid(GetCloud9Pawn())) + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn)) { // TODO: Reload } diff --git a/Source/Cloud9/Game/Cloud9KeyboardController.h b/Source/Cloud9/Game/Cloud9KeyboardController.h index 706c763e9..8aecad7d1 100644 --- a/Source/Cloud9/Game/Cloud9KeyboardController.h +++ b/Source/Cloud9/Game/Cloud9KeyboardController.h @@ -1,4 +1,27 @@ -#pragma once +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#pragma once #include "CoreMinimal.h" #include "Cloud9ControllerComponent.h" @@ -9,13 +32,13 @@ DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnMoveDelegate); UCLASS() class CLOUD9_API UCloud9KeyboardController : public UActorComponent - , public ICloud9ControllerComponent + , public ICloud9ControllerComponent { GENERATED_BODY() public: UCloud9KeyboardController(); - + virtual void TickComponent( float DeltaTime, ELevelTick TickType, diff --git a/Source/Cloud9/Game/Cloud9MouseController.cpp b/Source/Cloud9/Game/Cloud9MouseController.cpp index 531fa13c8..753dd4b68 100644 --- a/Source/Cloud9/Game/Cloud9MouseController.cpp +++ b/Source/Cloud9/Game/Cloud9MouseController.cpp @@ -1,4 +1,27 @@ -#include "Cloud9MouseController.h" +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#include "Cloud9MouseController.h" #include "Cloud9PlayerController.h" #include "Cloud9/Cloud9.h" #include "Cloud9/Tools/Cloud9ToolsLibrary.h" @@ -32,23 +55,29 @@ UCloud9MouseController::UCloud9MouseController() FVector2D UCloud9MouseController::GetMousePosition() const { - FVector2D MousePosition = FVector2D::ZeroVector; - GetOwner()->GetMousePosition(MousePosition.X, MousePosition.Y); - return MousePosition; + if (let Owner = GetOwner(); IsValid(Owner)) + { + FVector2D MousePosition = FVector2D::ZeroVector; + GetOwner()->GetMousePosition(MousePosition.X, MousePosition.Y); + return MousePosition; + } + + UE_LOG(LogCloud9, Fatal, TEXT("Can't get Cloud9PlayerController")); + return FVector2D::ZeroVector; } float UCloud9MouseController::GetCameraZoomHeightLevel() const { - if (IsValid(GetCloud9Pawn())) + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn)) { - const auto ZoomHeightLevel = UCloud9ToolsLibrary::InverseLerp( + let ZoomHeightLevel = UCloud9ToolsLibrary::InverseLerp( MinCameraZoomHeight, MaxCameraZoomHeight, - GetCloud9Pawn()->GetCameraZoomHeight()); - const auto ZoomAngleLevel = UCloud9ToolsLibrary::InverseLerp( + Pawn->GetCameraZoomHeight()); + let ZoomAngleLevel = UCloud9ToolsLibrary::InverseLerp( MinCameraZoomAngle, MaxCameraZoomAngle, - GetCloud9Pawn()->GetCameraRotationRoll()); + Pawn->GetCameraRotationRoll()); if (!FMath::IsNearlyEqual(ZoomHeightLevel, ZoomAngleLevel, 0.001f)) { @@ -60,22 +89,23 @@ float UCloud9MouseController::GetCameraZoomHeightLevel() const return ZoomHeightLevel; } + UE_LOG(LogCloud9, Fatal, TEXT("Can't get Cloud9Pawn")); return InvalidCameraZoomLevel; } void UCloud9MouseController::SetCameraZoomLevel(float Value) const { - if (IsValid(GetCloud9Pawn())) + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn)) { Value = FMath::Clamp(Value, MinCameraZoomLevel, MaxCameraZoomLevel); - const auto NewZoomHeight = FMath::Lerp(MinCameraZoomHeight, MaxCameraZoomHeight, Value); - GetCloud9Pawn()->SetCameraZoomHeight(NewZoomHeight); + let NewZoomHeight = FMath::Lerp(MinCameraZoomHeight, MaxCameraZoomHeight, Value); + Pawn->SetCameraZoomHeight(NewZoomHeight); if (bIsCameraChangeAngleEnabled) { - const auto NewZoomAngle = FMath::Lerp(MinCameraZoomAngle, MaxCameraZoomAngle, Value); - GetCloud9Pawn()->SetCameraRotationRoll(NewZoomAngle); + let NewZoomAngle = FMath::Lerp(MinCameraZoomAngle, MaxCameraZoomAngle, Value); + Pawn->SetCameraRotationRoll(NewZoomAngle); } } } @@ -85,50 +115,65 @@ void UCloud9MouseController::OnCharacterMove() { ProcessCharacterView(); } void UCloud9MouseController::ProcessCharacterView() const { - FHitResult TraceHitResult; - const auto bIsHitValid = GetCloud9Controller()->GetHitResultUnderCursor(ECC_Visibility, true, TraceHitResult); - GetCloud9Pawn()->SetViewDirection(TraceHitResult, bIsHitValid); + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn)) + { + if (let Controller = GetCloud9Controller(); IsValid(Controller)) + { + FHitResult TraceHitResult; + let bIsHitValid = Controller->GetHitResultUnderCursor( + ECC_Visibility, + true, + TraceHitResult); + Pawn->SetViewDirection(TraceHitResult, bIsHitValid); + } + } } void UCloud9MouseController::ProcessCameraRotation() { - if (IsMouseRotationMode) + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn) && IsMouseRotationMode) { - const auto NewMousePosition = GetMousePosition(); - const auto Offset = (NewMousePosition - CameraRotationBase).X; + let NewMousePosition = GetMousePosition(); + let Offset = (NewMousePosition - CameraRotationBase).X; CameraRotationBase = NewMousePosition; - const auto Angle = Offset * CameraRotateSensitivity; - GetCloud9Pawn()->AddCameraRotationYaw(Angle); + let Angle = Offset * CameraRotateSensitivity; + Pawn->AddCameraRotationYaw(Angle); } } void UCloud9MouseController::ProcessCameraZoom(float DeltaTime) { - if (TargetCameraZoomLevel == InvalidCameraZoomLevel) - return; + if (TargetCameraZoomLevel != InvalidCameraZoomLevel) + { + let CurrentCameraZoomLevel = GetCameraZoomHeightLevel(); - const auto CurrentCameraZoomLevel = GetCameraZoomHeightLevel(); + if (TargetCameraZoomLevel == CurrentCameraZoomLevel) + { + TargetCameraZoomLevel = InvalidCameraZoomLevel; + return; + } - if (TargetCameraZoomLevel == CurrentCameraZoomLevel) - { - TargetCameraZoomLevel = InvalidCameraZoomLevel; - return; - } + float NewCameraZoomLevel = TargetCameraZoomLevel; - float NewCameraZoomLevel = TargetCameraZoomLevel; + if (bIsCameraZoomSmoothEnabled) + { + NewCameraZoomLevel = CurrentCameraZoomLevel - DeltaTime * TargetCameraZoomSpeed; + if (TargetCameraZoomLevel > CurrentCameraZoomLevel) + { + NewCameraZoomLevel = FMath::Min(TargetCameraZoomLevel, NewCameraZoomLevel); + } + else if (TargetCameraZoomLevel < CurrentCameraZoomLevel) + { + NewCameraZoomLevel = FMath::Max(TargetCameraZoomLevel, NewCameraZoomLevel); + } + } - if (bIsCameraZoomSmoothEnabled) - { - NewCameraZoomLevel = CurrentCameraZoomLevel - DeltaTime * TargetCameraZoomSpeed; - if (TargetCameraZoomLevel > CurrentCameraZoomLevel) - NewCameraZoomLevel = FMath::Min(TargetCameraZoomLevel, NewCameraZoomLevel); - else if (TargetCameraZoomLevel < CurrentCameraZoomLevel) - NewCameraZoomLevel = FMath::Max(TargetCameraZoomLevel, NewCameraZoomLevel); + SetCameraZoomLevel(NewCameraZoomLevel); + if (NewCameraZoomLevel == TargetCameraZoomLevel) + { + TargetCameraZoomLevel = InvalidCameraZoomLevel; + } } - - SetCameraZoomLevel(NewCameraZoomLevel); - if (NewCameraZoomLevel == TargetCameraZoomLevel) - TargetCameraZoomLevel = InvalidCameraZoomLevel; } void UCloud9MouseController::BeginPlay() @@ -151,36 +196,39 @@ void UCloud9MouseController::TickComponent( void UCloud9MouseController::OnCameraZoom(float Value) { - if (IsValid(GetCloud9Pawn()) && FMath::Abs(Value) > 0.0f && TargetCameraZoomLevel == InvalidCameraZoomLevel) + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn)) { - const auto CurrentCameraZoomLevel = GetCameraZoomHeightLevel(); + if (FMath::Abs(Value) > 0.0f && TargetCameraZoomLevel == InvalidCameraZoomLevel) + { + let CurrentCameraZoomLevel = GetCameraZoomHeightLevel(); - TargetCameraZoomLevel = FMath::Clamp( - CurrentCameraZoomLevel - Value * CameraZoomSensitivity, - MinCameraZoomLevel, - MaxCameraZoomLevel - ); + TargetCameraZoomLevel = FMath::Clamp( + CurrentCameraZoomLevel - Value * CameraZoomSensitivity, + MinCameraZoomLevel, + MaxCameraZoomLevel + ); - TargetCameraZoomSpeed = Value * CameraZoomSmoothSpeed; + TargetCameraZoomSpeed = Value * CameraZoomSmoothSpeed; + } } } void UCloud9MouseController::OnCameraRotationPressed() { - if (IsValid(GetCloud9Pawn())) + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn)) { CameraRotationBase = GetMousePosition(); IsMouseRotationMode = true; - GetCloud9Pawn()->SetCursorIsHidden(true); + Pawn->SetCursorIsHidden(true); } } void UCloud9MouseController::OnCameraRotationReleased() { - if (IsValid(GetCloud9Pawn())) + if (let Pawn = GetCloud9Pawn(); IsValid(Pawn)) { CameraRotationBase = FVector2D::ZeroVector; IsMouseRotationMode = false; - GetCloud9Pawn()->SetCursorIsHidden(false); + Pawn->SetCursorIsHidden(false); } } diff --git a/Source/Cloud9/Game/Cloud9MouseController.h b/Source/Cloud9/Game/Cloud9MouseController.h index 4fcf0e7cd..fcfee8786 100644 --- a/Source/Cloud9/Game/Cloud9MouseController.h +++ b/Source/Cloud9/Game/Cloud9MouseController.h @@ -1,4 +1,27 @@ -#pragma once +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#pragma once #include "CoreMinimal.h" #include "Cloud9ControllerComponent.h" diff --git a/Source/Cloud9/Game/Cloud9PlayerController.cpp b/Source/Cloud9/Game/Cloud9PlayerController.cpp index 3fdf279e6..5a9fd2c15 100644 --- a/Source/Cloud9/Game/Cloud9PlayerController.cpp +++ b/Source/Cloud9/Game/Cloud9PlayerController.cpp @@ -1,8 +1,32 @@ +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + #include "Cloud9PlayerController.h" #include "Cloud9DeveloperSettings.h" #include "Cloud9KeyboardController.h" #include "Cloud9MouseController.h" +#include "Cloud9/Cloud9.h" #include "Cloud9/Console/Cloud9ConsoleComponent.h" #include "Engine/World.h" @@ -23,7 +47,7 @@ void ACloud9PlayerController::PlayerTick(float DeltaTime) { Super::PlayerTick(DeltaTime); - const auto Settings = UCloud9DeveloperSettings::GetCloud9DeveloperSettings(); + let Settings = UCloud9DeveloperSettings::GetCloud9DeveloperSettings(); bShowMouseCursor = Settings->bIsShowMouseCursor; } diff --git a/Source/Cloud9/Game/Cloud9PlayerController.h b/Source/Cloud9/Game/Cloud9PlayerController.h index 7062ed8a2..e6a351ec3 100644 --- a/Source/Cloud9/Game/Cloud9PlayerController.h +++ b/Source/Cloud9/Game/Cloud9PlayerController.h @@ -1,4 +1,25 @@ -// Copyright Epic Games, Inc. All Rights Reserved. +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. #pragma once diff --git a/Source/Cloud9/Weapon/Cloud9WeaponBase.cpp b/Source/Cloud9/Weapon/Cloud9WeaponBase.cpp index 79f9cf158..326a4687e 100644 --- a/Source/Cloud9/Weapon/Cloud9WeaponBase.cpp +++ b/Source/Cloud9/Weapon/Cloud9WeaponBase.cpp @@ -1,5 +1,29 @@ -#include "Cloud9WeaponBase.h" +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +#include "Cloud9WeaponBase.h" + +#include "Cloud9/Cloud9.h" #include "Cloud9/Character/Cloud9Character.h" const FName ACloud9WeaponBase::CapsuleComponentName = TEXT("CapsuleComponent"); @@ -52,9 +76,9 @@ void ACloud9WeaponBase::OnConstruction(const FTransform& Transform) SetActorHiddenInGame(true); SetActorEnableCollision(false); - if (const auto MyOwner = Cast(GetOwner())) + if (let MyOwner = Cast(GetOwner())) { - const auto ParentMesh = MyOwner->GetMesh(); + let ParentMesh = MyOwner->GetMesh(); AttachToComponent(ParentMesh, FAttachmentTransformRules::SnapToTargetIncludingScale, EquippedWeaponSocketName); } } diff --git a/Source/Cloud9/Weapon/Cloud9WeaponBase.h b/Source/Cloud9/Weapon/Cloud9WeaponBase.h index 7d74a1bdd..8f0ee69b4 100644 --- a/Source/Cloud9/Weapon/Cloud9WeaponBase.h +++ b/Source/Cloud9/Weapon/Cloud9WeaponBase.h @@ -1,4 +1,27 @@ -#pragma once +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#pragma once #include "CoreMinimal.h" #include "NiagaraComponent.h" @@ -24,7 +47,7 @@ class CLOUD9_API ACloud9WeaponBase : public AActor static const FName HolsteredGrenadeWeaponSocketName; ACloud9WeaponBase(); - + UFUNCTION(BlueprintCallable) EWeaponType GetWeaponType() const; @@ -42,12 +65,12 @@ class CLOUD9_API ACloud9WeaponBase : public AActor protected: virtual void OnConstruction(const FTransform& Transform) override; - + virtual void BeginPlay() override; - + UPROPERTY(Category=Weapon, BlueprintGetter=GetWeaponClass) EWeaponClass WeaponClass; - + UPROPERTY(Category=Weapon, BlueprintGetter=GetWeaponType) EWeaponType WeaponType; @@ -59,12 +82,12 @@ class CLOUD9_API ACloud9WeaponBase : public AActor UPROPERTY(Category=Weapon, BlueprintGetter=IsAutomatic) bool bIsAutomatic; - + // EditDefaultsOnly - + UPROPERTY(Category=Weapon, BlueprintReadOnly, EditDefaultsOnly, meta=(AllowPrivateAccess = "true")) UStaticMeshComponent* Mesh; - + UPROPERTY(Category=Weapon, BlueprintReadOnly, EditDefaultsOnly, meta=(AllowPrivateAccess = "true")) float PrimaryActionCooldown; @@ -73,12 +96,12 @@ class CLOUD9_API ACloud9WeaponBase : public AActor UPROPERTY(Category=Weapon, BlueprintReadOnly, EditDefaultsOnly, meta=(AllowPrivateAccess = "true")) float BaseDamage; - + UPROPERTY(Category=Weapon, BlueprintReadOnly, EditDefaultsOnly, meta=(AllowPrivateAccess = "true")) float DeployTime; - + // Sounds - + UPROPERTY(Category=Sounds, BlueprintReadOnly, EditDefaultsOnly, meta=(AllowPrivateAccess = "true")) USoundBase* PrimaryActionSound; diff --git a/Source/Cloud9/Weapon/Cloud9WeaponFirearm.cpp b/Source/Cloud9/Weapon/Cloud9WeaponFirearm.cpp index e354ed156..d1420d184 100644 --- a/Source/Cloud9/Weapon/Cloud9WeaponFirearm.cpp +++ b/Source/Cloud9/Weapon/Cloud9WeaponFirearm.cpp @@ -1,14 +1,36 @@ -#include "Cloud9WeaponFirearm.h" +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +#include "Cloud9WeaponFirearm.h" ACloud9WeaponFirearm::ACloud9WeaponFirearm() { WeaponClass = EWeaponClass::Firearm; - + ReloadTime = 0.0; MagazineRoundsCount = 0; TotalRoundsCount = 0; - + if (IsValid(Mesh)) { MuzzleFlash = CreateDefaultSubobject(MuzzleFlashComponentName); diff --git a/Source/Cloud9/Weapon/Cloud9WeaponFirearm.h b/Source/Cloud9/Weapon/Cloud9WeaponFirearm.h index 7a7424104..61496c804 100644 --- a/Source/Cloud9/Weapon/Cloud9WeaponFirearm.h +++ b/Source/Cloud9/Weapon/Cloud9WeaponFirearm.h @@ -1,4 +1,25 @@ -// +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. #pragma once diff --git a/Source/Cloud9/Weapon/Cloud9WeaponKnife.cpp b/Source/Cloud9/Weapon/Cloud9WeaponKnife.cpp index 09f718d1e..08d4c751e 100644 --- a/Source/Cloud9/Weapon/Cloud9WeaponKnife.cpp +++ b/Source/Cloud9/Weapon/Cloud9WeaponKnife.cpp @@ -1,4 +1,27 @@ -#include "Cloud9WeaponKnife.h" +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#include "Cloud9WeaponKnife.h" ACloud9WeaponKnife::ACloud9WeaponKnife() { diff --git a/Source/Cloud9/Weapon/Cloud9WeaponKnife.h b/Source/Cloud9/Weapon/Cloud9WeaponKnife.h index 396cea227..7effcbe0a 100644 --- a/Source/Cloud9/Weapon/Cloud9WeaponKnife.h +++ b/Source/Cloud9/Weapon/Cloud9WeaponKnife.h @@ -1,4 +1,25 @@ -// +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. #pragma once diff --git a/Source/Cloud9/Weapon/Cloud9WeaponPistol.cpp b/Source/Cloud9/Weapon/Cloud9WeaponPistol.cpp index 3da3792e5..1468c6a43 100644 --- a/Source/Cloud9/Weapon/Cloud9WeaponPistol.cpp +++ b/Source/Cloud9/Weapon/Cloud9WeaponPistol.cpp @@ -1,5 +1,27 @@ -#include "Cloud9WeaponPistol.h" +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +#include "Cloud9WeaponPistol.h" ACloud9WeaponPistol::ACloud9WeaponPistol() { diff --git a/Source/Cloud9/Weapon/Cloud9WeaponPistol.h b/Source/Cloud9/Weapon/Cloud9WeaponPistol.h index 9785afc26..05edb08b5 100644 --- a/Source/Cloud9/Weapon/Cloud9WeaponPistol.h +++ b/Source/Cloud9/Weapon/Cloud9WeaponPistol.h @@ -1,4 +1,27 @@ -#pragma once +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#pragma once #include "CoreMinimal.h" #include "Cloud9WeaponFirearm.h" diff --git a/Source/Cloud9/Weapon/Cloud9WeaponSniper.cpp b/Source/Cloud9/Weapon/Cloud9WeaponSniper.cpp index efc834bf0..a2196d47b 100644 --- a/Source/Cloud9/Weapon/Cloud9WeaponSniper.cpp +++ b/Source/Cloud9/Weapon/Cloud9WeaponSniper.cpp @@ -1,4 +1,27 @@ -#include "Cloud9WeaponSniper.h" +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#include "Cloud9WeaponSniper.h" ACloud9WeaponSniper::ACloud9WeaponSniper() { diff --git a/Source/Cloud9/Weapon/Cloud9WeaponSniper.h b/Source/Cloud9/Weapon/Cloud9WeaponSniper.h index 273abf3ec..b028b23e0 100644 --- a/Source/Cloud9/Weapon/Cloud9WeaponSniper.h +++ b/Source/Cloud9/Weapon/Cloud9WeaponSniper.h @@ -1,4 +1,27 @@ -#pragma once +// Copyright (c) 2023 Alexei Gladkikh +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#pragma once #include "CoreMinimal.h" #include "Cloud9WeaponFirearm.h"