diff --git a/Content/Audio/BetonTur.uasset b/Content/Audio/BetonTur.uasset new file mode 100644 index 0000000..4bf3d22 Binary files /dev/null and b/Content/Audio/BetonTur.uasset differ diff --git a/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/Elevator.uasset b/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/Elevator.uasset index eba5ae9..aa88c5f 100644 Binary files a/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/Elevator.uasset and b/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/Elevator.uasset differ diff --git a/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/KeyPad_Actor_ExtraSpecial.uasset b/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/KeyPad_Actor_ExtraSpecial.uasset new file mode 100644 index 0000000..ee96ce1 Binary files /dev/null and b/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/KeyPad_Actor_ExtraSpecial.uasset differ diff --git a/Content/Levels/FactoryHall.umap b/Content/Levels/FactoryHall.umap index 13f8591..2cc5170 100644 Binary files a/Content/Levels/FactoryHall.umap and b/Content/Levels/FactoryHall.umap differ diff --git a/Content/Levels/Raum4.umap b/Content/Levels/Raum4.umap index 2e9ef48..c99fee4 100644 Binary files a/Content/Levels/Raum4.umap and b/Content/Levels/Raum4.umap differ diff --git a/Content/Levels/Raum4_BuiltData.uasset b/Content/Levels/Raum4_BuiltData.uasset index 5a2995a..9af5c13 100644 Binary files a/Content/Levels/Raum4_BuiltData.uasset and b/Content/Levels/Raum4_BuiltData.uasset differ diff --git a/Content/Levels/VillaDesign.umap b/Content/Levels/VillaDesign.umap index 48e23a6..f76fd5a 100644 Binary files a/Content/Levels/VillaDesign.umap and b/Content/Levels/VillaDesign.umap differ diff --git a/Content/Levels/VillaDesign_BuiltData.uasset b/Content/Levels/VillaDesign_BuiltData.uasset index 3b1762c..51c91a1 100644 Binary files a/Content/Levels/VillaDesign_BuiltData.uasset and b/Content/Levels/VillaDesign_BuiltData.uasset differ diff --git a/Source/BuildingEscape/ExtraSpecialRotatingDoor.cpp b/Source/BuildingEscape/ExtraSpecialRotatingDoor.cpp new file mode 100644 index 0000000..24531d5 --- /dev/null +++ b/Source/BuildingEscape/ExtraSpecialRotatingDoor.cpp @@ -0,0 +1,95 @@ +#include "ExtraSpecialRotatingDoor.h" + +#include "Components/AudioComponent.h" +#include "Kismet/GameplayStatics.h" +#include "Engine/World.h" +#include "Engine/Public/TimerManager.h" + +UExtraSpecialRotatingDoor::UExtraSpecialRotatingDoor() +{ + PrimaryComponentTick.bCanEverTick = true; +} + +void UExtraSpecialRotatingDoor::BeginPlay() +{ + Super::BeginPlay(); +} + +void UExtraSpecialRotatingDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) +{ + Super::TickComponent(DeltaTime, TickType, ThisTickFunction); + if (rotating) + { + FRotator Rotation = GetOwner()->GetActorRotation(); + if (Rotation.Equals(targetRotation, 1.0f)) + { + rotating = false; + } + else + { + Rotation.Add(DeltaTime * RotationSpeed * tempPitchRotation, 0.0f, DeltaTime * RotationSpeed * tempRollRotation); + GetOwner()->SetActorRotation(Rotation); + } + } +} + +void UExtraSpecialRotatingDoor::Rotate(const FRotator TargetRotation) +{ + FTimerHandle handle; + if(RotationDelay == 0) + { + Move(TargetRotation); + }else + { + GetWorld()->GetTimerManager().SetTimer(handle, [this, TargetRotation]() { + Move(TargetRotation); + }, RotationDelay, 1); + } +} + +void UExtraSpecialRotatingDoor::Rotate() +{ + FRotator rotation = GetOwner()->GetActorRotation(); + rotation.Pitch = TargetAnglePitch; + rotation.Roll = TargetAngleRoll; + Rotate(rotation); +} + +void UExtraSpecialRotatingDoor::Move(const FRotator TargetRotation) +{ + this->targetRotation = TargetRotation; + rotating = true; + tempPitchRotation = (TargetRotation.Pitch < 0) ? -1.f : 1.f; + if (Negative) + { + tempPitchRotation = (TargetRotation.Pitch < 0) ? 1.f : -1.f; + } + + tempRollRotation = (TargetRotation.Roll < 0) ? -1.f : 1.f; + if (Negative) + { + tempRollRotation = (TargetRotation.Roll < 0) ? 1.f : -1.f; + } + + TArray Audios; + GetOwner()->GetComponents(Audios); + + if (Audios.Num() == 0) return; + if (soundHasBeenPlayed) return; + + for (auto Audio : Audios) + { + if (Audio->ComponentHasTag("location")) + { + UGameplayStatics::PlaySoundAtLocation(GetOwner(), Audio->Sound, GetOwner()->GetActorLocation(), + GetOwner()->GetActorRotation(), 1, 1, 0, + Audio->AttenuationSettings, nullptr, GetOwner()); + } + else + { + Audio->Play(); + } + } + + soundHasBeenPlayed = true; +} \ No newline at end of file diff --git a/Source/BuildingEscape/ExtraSpecialRotatingDoor.h b/Source/BuildingEscape/ExtraSpecialRotatingDoor.h new file mode 100644 index 0000000..d8b6d5a --- /dev/null +++ b/Source/BuildingEscape/ExtraSpecialRotatingDoor.h @@ -0,0 +1,54 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Components/ActorComponent.h" +#include "ExtraSpecialRotatingDoor.generated.h" + + +UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +class BUILDINGESCAPE_API UExtraSpecialRotatingDoor : public UActorComponent +{ + GENERATED_BODY() + +public: + // Sets default values for this component's properties + UExtraSpecialRotatingDoor(); + +protected: + virtual void BeginPlay() override; + + void Rotate(FRotator TargetRotation); + + UFUNCTION(BlueprintCallable) + void Rotate(); + +public: + virtual void TickComponent(float DeltaTime, ELevelTick TickType, + FActorComponentTickFunction* ThisTickFunction) override; + + UPROPERTY(EditAnywhere) + float TargetAnglePitch = 90.0f; + + UPROPERTY(EditAnywhere) + float TargetAngleRoll = 90.0f; + + UPROPERTY(EditAnywhere) + float RotationSpeed = 15.f; + + UPROPERTY(EditAnywhere) + float RotationDelay = 0.f; + + UPROPERTY(EditAnywhere) + bool Negative = false; + +private: + FRotator targetRotation; + bool rotating; + bool soundHasBeenPlayed; + float tempPitchRotation; + float tempRollRotation; + void Move(FRotator TargetRotation); + +}; \ No newline at end of file diff --git a/Source/BuildingEscape/RotatingActor.cpp b/Source/BuildingEscape/RotatingActor.cpp index a0a6a07..2737a79 100644 --- a/Source/BuildingEscape/RotatingActor.cpp +++ b/Source/BuildingEscape/RotatingActor.cpp @@ -21,7 +21,7 @@ void URotatingActor::TickComponent(float DeltaTime, ELevelTick TickType, FActorC if (rotating) { FRotator Rotation = GetOwner()->GetActorRotation(); - if (Rotation.Equals(targetRotation, Tolerance)) + if (Rotation.Equals(targetRotation, 1.0f)) { rotating = false; } diff --git a/Source/BuildingEscape/RotatingActor.h b/Source/BuildingEscape/RotatingActor.h index baae54d..0420ea0 100644 --- a/Source/BuildingEscape/RotatingActor.h +++ b/Source/BuildingEscape/RotatingActor.h @@ -39,9 +39,6 @@ public: UPROPERTY(EditAnywhere) bool Negative = false; - UPROPERTY(EditAnywhere) - float Tolerance = 1.0f; - private: FRotator targetRotation; bool rotating;