add go to bed

This commit is contained in:
2020-08-06 18:33:05 +05:00
parent 885b887193
commit e2cc806e9f
10 changed files with 90 additions and 11 deletions
+35
View File
@@ -0,0 +1,35 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Bed.h"
// Sets default values
ABed::ABed()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
Root = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
RootComponent = Root;
Body = CreateAbstractDefaultSubobject<UStaticMeshComponent>(TEXT("Body"));
Body->SetupAttachment(Root);
BoxCollision = CreateDefaultSubobject<UBoxComponent>(TEXT("Box Collision"));
BoxCollision->SetupAttachment(Root);
}
// Called when the game starts or when spawned
void ABed::BeginPlay()
{
Super::BeginPlay();
}
/*
// Called every frame
void ABed::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}*/
+15 -10
View File
@@ -23,6 +23,7 @@ void AFemale::BeginPlay()
capsule->OnComponentEndOverlap.AddDynamic(this, &AFemale::OnOverlapEnd);
maxMood = 0.0f;
currentMood = 0.0f;
isGoToBed = false;
GetData();
}
@@ -38,17 +39,17 @@ void AFemale::OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherA
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep,
const FHitResult& SweepResult)
{
UE_LOG(LogTemp, Warning, TEXT("not in place"), InPlace);
ItemForWork = Cast<ABaseItem>(OtherActor);
if (!ItemForWork->used && ItemForWork->nameItem == NameItem)
if(!isGoToBed)
{
GetWorldTimerManager().SetTimer(MemberTimerHandle, this, &AFemale::StartUseItem, 0.5f, false);
//StartUseItem();
UE_LOG(LogTemp, Warning, TEXT("start anim working"));
UE_LOG(LogTemp, Warning, TEXT("not in place"), InPlace);
ItemForWork = Cast<ABaseItem>(OtherActor);
if (!ItemForWork->used && ItemForWork->nameItem == NameItem)
{
GetWorldTimerManager().SetTimer(MemberTimerHandle, this, &AFemale::StartUseItem, 0.5f, false);
//StartUseItem();
UE_LOG(LogTemp, Warning, TEXT("start anim working"));
}
}
}
void AFemale::OnOverlapEnd(UPrimitiveComponent* OverlappedComp, AActor* OtherActor,
@@ -89,6 +90,7 @@ void AFemale::CheckingUpset()
}
}
void AFemale::MoodDecreace()
{
@@ -114,7 +116,10 @@ void AFemale::EndUseItem_Implementation()
void AFemale::whatShouldIDo_Implementation()
{
}
void AFemale::SetIsGoToBed(bool goes)
{
isGoToBed = goes;
}
// Called every frame
+35
View File
@@ -0,0 +1,35 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Components/BoxComponent.h"
#include "Bed.generated.h"
UCLASS()
class WBIF_API ABed : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ABed();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// ===================Variables===================================
UPROPERTY(EditAnyWhere, BlueprintReadWrite, Category = "Objects")
USceneComponent* Root;
UPROPERTY(EditAnyWhere, BlueprintReadWrite, Category = "Objects")
UStaticMeshComponent* Body;
UPROPERTY(EditAnyWhere, BlueprintReadWrite, Category = "Objects")
UBoxComponent* BoxCollision;
public:
// Called every frame
//virtual void Tick(float DeltaTime) override;
};
+5 -1
View File
@@ -54,6 +54,8 @@ protected:
FName NameItem;
UPROPERTY(EditAnyWhere, BlueprintReadWrite, Category= "Data")
UWBIFGameInstance* gameInstance;
UPROPERTY(EditAnywhere, Category = "Data")
bool isGoToBed;
@@ -63,7 +65,7 @@ public:
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
// ===================Functions===================================
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, Category = "Animations")
void SartAnimUseItem();
@@ -71,6 +73,8 @@ public:
void EndUseItem();
UFUNCTION(BlueprintCallable, Category = "Mood")
void CheckingUpset();
UFUNCTION(BlueprintCallable, Category = "Dta")
void SetIsGoToBed(bool goes);
// ===================Variable===================================
UPROPERTY() // variable for timer