Skip to content

Commit

Permalink
Finished clash stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
BigDub committed Jan 25, 2018
1 parent 3678a45 commit 7b671e1
Show file tree
Hide file tree
Showing 17 changed files with 129 additions and 70 deletions.
Binary file not shown.
Binary file not shown.
Binary file modified Content/Assets/Character/Marth/MarthAnimBP.uasset
Binary file not shown.
Binary file modified Content/BPs/Characters/Marth2.uasset
Binary file not shown.
Binary file modified Content/BPs/Characters/MarthCharacter.uasset
Binary file not shown.
Binary file modified Content/BPs/Characters/MyFighterCharacter.uasset
Binary file not shown.
Binary file modified Content/BPs/MyBBGameMode.uasset
Binary file not shown.
Binary file modified Content/Maps/SimpleMap.umap
Binary file not shown.
Binary file modified Content/Maps/SimpleMap_BuiltData.uasset
Binary file not shown.
9 changes: 9 additions & 0 deletions Source/BeatBoxers/BeatBoxersStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ static FORCEINLINE FString GetEnumValueToString(const FString& Name, TEnum Value
return enumPtr->GetNameByValue((int64)Value).ToString();
}

UENUM(BlueprintType)
enum class EWindowStage : uint8
{
WE_Windup UMETA(DisplayName = "Wind up")
, WE_Duration UMETA(DisplayName = "Duration")
, WE_Winddown UMETA(DisplayName = "Wind down")
, WE_None UMETA(DisplayName = "None")
};

UENUM(BlueprintType)
enum class EFilter : uint8
{
Expand Down
25 changes: 25 additions & 0 deletions Source/BeatBoxers/Implementation/BBGameMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,11 +1141,36 @@ void ABBGameMode::OnClash(TWeakObjectPtr<AActor> FighterA, TWeakObjectPtr<AActor
// Passes the fighters themselves as the source so the clash impact will be relative to their facing.
ApplyImpact(FighterA, GetClashImpact(mFighterA == winner), false, nullptr, FighterA);
ApplyImpact(FighterB, GetClashImpact(mFighterB == winner), false, nullptr, FighterB);

mFighterA->Clash();
mFighterB->Clash();

FTransform ImpactTransform = FTransform::Identity;
ImpactTransform.SetTranslation((FighterA.Get()->GetActorLocation() + FighterB.Get()->GetActorLocation()) / 2.f);
FTransform RelativeTransform = DefaultClashImpact.SFX.RelativeTransform * ImpactTransform;
if (DefaultClashImpact.SFX.ParticleSystem != nullptr)
{
UGameplayStatics::SpawnEmitterAtLocation(
GetWorld(),
DefaultClashImpact.SFX.ParticleSystem,
RelativeTransform
);
}
if (DefaultClashImpact.SFX.SoundCue != nullptr)
{
UGameplayStatics::SpawnSoundAtLocation(
GetWorld(),
DefaultClashImpact.SFX.SoundCue,
RelativeTransform.GetLocation(),
RelativeTransform.GetRotation().Rotator()
);
}
}
else
{
UE_LOG(LogClashing, Warning, TEXT("ABBGameMode::OnClash given a nullptr for a Fighter."));
}

}

IFighter* ABBGameMode::DetermineClashWinner(IFighter* FighterA, IFighter* FighterB)
Expand Down
15 changes: 14 additions & 1 deletion Source/BeatBoxers/Implementation/Character/FighterCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,11 @@ FLandEvent& AFighterCharacter::GetOnLandEvent()
return LandEvent;
}

FClashEvent& AFighterCharacter::GetOnClashEvent()
{
return ClashEvent;
}

void AFighterCharacter::SetOpponent(TWeakObjectPtr<AActor> NewOpponent)
{
if (NewOpponent.IsValid())
Expand Down Expand Up @@ -767,6 +772,14 @@ FMoveHitbox AFighterCharacter::GetFighterHitbox()
bool AFighterCharacter::CanClash()
{
if (MyFighterState != nullptr)
return MyFighterState->HasActiveMoveWindow() && !MyFighterState->IsInWinddown();
return MyFighterState->DoesWindowUseHitbox() && MyFighterState->GetWindowStage() != EWindowStage::WE_Winddown;
return false;
}

void AFighterCharacter::Clash()
{
if (ClashEvent.IsBound())
{
ClashEvent.Broadcast();
}
}
5 changes: 5 additions & 0 deletions Source/BeatBoxers/Implementation/Character/FighterCharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ class BEATBOXERS_API AFighterCharacter : public ACharacter, public IFighter
UPROPERTY(BlueprintAssignable)
FLandEvent LandEvent;

UPROPERTY(BlueprintAssignable)
FClashEvent ClashEvent;

UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
FEffects DefaultHitEffects;

Expand Down Expand Up @@ -128,6 +131,7 @@ class BEATBOXERS_API AFighterCharacter : public ACharacter, public IFighter
virtual void Jump() override;
virtual FStartJumpEvent& GetOnStartJumpEvent() override;
virtual FLandEvent& GetOnLandEvent() override;
virtual FClashEvent& GetOnClashEvent() override;
virtual void OnInputReceived() override;
virtual FDataTableRowHandle GetDefaultMoveState() override { return DefaultMoveState; }
virtual void HitOnBeatLogic() override;
Expand All @@ -142,6 +146,7 @@ class BEATBOXERS_API AFighterCharacter : public ACharacter, public IFighter
virtual float GetFighterCurrentWindowAccuracy() override;
virtual FMoveHitbox GetFighterHitbox() override;
virtual bool CanClash() override;
virtual void Clash() override;
/** End IFighter implementation */

UFUNCTION(BlueprintPure, meta=(DisplayName="Is Jumping"))
Expand Down
109 changes: 56 additions & 53 deletions Source/BeatBoxers/Implementation/Character/FighterStateComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ UFighterStateComponent::UFighterStateComponent(const class FObjectInitializer& O
PrimaryComponentTick.bCanEverTick = true;

ActorsToIgnore = TArray<TWeakObjectPtr<AActor>>();
bIsWindowActive = false;
CurrentWindowStage = EWindowStage::WE_None;
bIsHitboxActive = false;
}

Expand All @@ -45,7 +45,7 @@ void UFighterStateComponent::TickComponent(float DeltaTime, ELevelTick TickType,
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

bool action = false;
if (bIsWindowActive && CurrentWindow.IsHitboxActive && bIsHitboxActive)
if (IsMidMove() && CurrentWindow.IsHitboxActive && bIsHitboxActive)
{
action = true;
PerformHitboxScan();
Expand Down Expand Up @@ -232,7 +232,7 @@ bool UFighterStateComponent::IsInvulnerable() const

bool UFighterStateComponent::IsMidMove() const
{
return bIsWindowActive;
return CurrentWindowStage != EWindowStage::WE_None;
}

void UFighterStateComponent::StartMoveWindow(FMoveWindow& Window, float Accuracy)
Expand Down Expand Up @@ -260,45 +260,14 @@ void UFighterStateComponent::StartMoveWindow(FMoveWindow& Window, float Accuracy
}
else
{
if (CurrentWindow.AttackerMovement.IsValid())
{
if (MyFighterWorld != nullptr)
{
MyFighterWorld->ApplyMovementToActor(GetOwner(), GetOwner(), GetOwnerController(), CurrentWindow.AttackerMovement);
}
}
if (Window.AnimMontage != nullptr && MyFighter != nullptr)
{
ACharacter *Character = Cast<ACharacter>(MyFighter);
if (Character != nullptr)
{
float Duration = Character->PlayAnimMontage(Window.AnimMontage);
if (Duration == 0.f)
{
UE_LOG(LogBBAnimation, Warning, TEXT("%s::StartMoveWindow PlayAnimMontage(%s) returned 0 as duration."), *GetNameSafe(this), *GetNameSafe(Window.AnimMontage));
}
else
{
UE_LOG(LogBBAnimation, Verbose, TEXT("%s::StartMoveWindow PlayAnimMontage(%s) duration %f."), *GetNameSafe(this), *GetNameSafe(Window.AnimMontage), Duration);
}
}
else
{
UE_LOG(LogBBAnimation, Warning, TEXT("%s::StartMoveWindow unable to cast fighter to character."), *GetNameSafe(this));
}
}
if (CurrentWindow.IgnoreCollisions)
{
MyFighter->SetFighterCollisions(false);
}
StartCurrentWindowWindup();
}
}

void UFighterStateComponent::StartStun(float Duration, bool WasBlocked)
{
bIsCurrentStunBlock = WasBlocked;
if (bIsWindowActive && CurrentWindow.AnimMontage != nullptr && MyFighter != nullptr)
if (IsMidMove() && CurrentWindow.AnimMontage != nullptr && MyFighter != nullptr)
{
ACharacter *Character = Cast<ACharacter>(MyFighter);
if (Character != nullptr)
Expand Down Expand Up @@ -417,7 +386,7 @@ void UFighterStateComponent::StopBlock()

void UFighterStateComponent::OnLand()
{
if (bIsWindowActive)
if (IsMidMove())
{
if (CurrentWindow.LandingInterrupts)
{
Expand All @@ -444,10 +413,42 @@ void UFighterStateComponent::OnLand()

void UFighterStateComponent::StartCurrentWindowWindup()
{
bIsWindowActive = true;
CurrentWindowStage = EWindowStage::WE_Windup;
ActorsToIgnore.Empty();
ActorsToIgnore.Add(GetOwner());

if (CurrentWindow.AttackerMovement.IsValid())
{
if (MyFighterWorld != nullptr)
{
MyFighterWorld->ApplyMovementToActor(GetOwner(), GetOwner(), GetOwnerController(), CurrentWindow.AttackerMovement);
}
}
if (CurrentWindow.AnimMontage != nullptr && MyFighter != nullptr)
{
ACharacter *Character = Cast<ACharacter>(MyFighter);
if (Character != nullptr)
{
float Duration = Character->PlayAnimMontage(CurrentWindow.AnimMontage);
if (Duration == 0.f)
{
UE_LOG(LogBBAnimation, Warning, TEXT("%s::StartCurrentWindowWindup PlayAnimMontage(%s) returned 0 as duration."), *GetNameSafe(this), *GetNameSafe(CurrentWindow.AnimMontage));
}
else
{
UE_LOG(LogBBAnimation, Verbose, TEXT("%s::StartCurrentWindowWindup PlayAnimMontage(%s) duration %f."), *GetNameSafe(this), *GetNameSafe(CurrentWindow.AnimMontage), Duration);
}
}
else
{
UE_LOG(LogBBAnimation, Warning, TEXT("%s::StartCurrentWindowWindup unable to cast fighter to character."), *GetNameSafe(this));
}
}
if (CurrentWindow.IgnoreCollisions)
{
MyFighter->SetFighterCollisions(false);
}

if (CurrentWindow.Windup <= 0)
{
// No windup, proceed.
Expand All @@ -472,6 +473,7 @@ void UFighterStateComponent::OnCurrentWindowWindupFinished()

void UFighterStateComponent::StartCurrentWindowDuration()
{
CurrentWindowStage = EWindowStage::WE_Duration;
PlayerAttackerEffects(CurrentWindow.SFX);
if (CurrentWindow.Duration <= 0)
{
Expand Down Expand Up @@ -534,6 +536,7 @@ void UFighterStateComponent::AdjustGravity(float Amount)

void UFighterStateComponent::StartCurrentWindowWinddown()
{
CurrentWindowStage = EWindowStage::WE_Winddown;
bHasMoveWindowHit = false;
if (CurrentWindow.Winddown <= 0)
{
Expand Down Expand Up @@ -568,9 +571,9 @@ void UFighterStateComponent::OnCurrentWindowWinddownFinished()

void UFighterStateComponent::EndWindow(EWindowEnd WindowEnd)
{
if (bIsWindowActive)
if (IsMidMove())
{
bIsWindowActive = false;
CurrentWindowStage = EWindowStage::WE_None;
if (GetOwner()->GetWorldTimerManager().IsTimerActive(TimerHandle_Window))
{
GetOwner()->GetWorldTimerManager().ClearTimer(TimerHandle_Window);
Expand Down Expand Up @@ -773,7 +776,7 @@ void UFighterStateComponent::PlayerAttackerEffects(FEffects& Effects)

void UFighterStateComponent::TryDisableTick()
{
if ((!bIsWindowActive || !CurrentWindow.IsHitboxActive || !bIsHitboxActive) && !bIsBeingMoved)
if ((!IsMidMove() || !CurrentWindow.IsHitboxActive || !bIsHitboxActive) && !bIsBeingMoved)
{
SetComponentTickEnabled(false);
}
Expand Down Expand Up @@ -918,35 +921,35 @@ void UFighterStateComponent::OnInvulnerableTimer()
}
}

bool UFighterStateComponent::IsIgnoringCollision()
bool UFighterStateComponent::IsIgnoringCollision() const
{
return bIsWindowActive && CurrentWindow.IgnoreCollisions;
return IsMidMove() && CurrentWindow.IgnoreCollisions;
}

float UFighterStateComponent::GetCurrentWindowAccuracy()
float UFighterStateComponent::GetCurrentWindowAccuracy() const
{
if (bIsWindowActive)
if (IsMidMove())
{
return CurrentWindowAccuracy;
}
return -1;
}

FMoveHitbox UFighterStateComponent::GetHitbox()
bool UFighterStateComponent::DoesWindowUseHitbox() const
{
if (bIsWindowActive)
return IsMidMove() && CurrentWindow.IsHitboxActive;
}

FMoveHitbox UFighterStateComponent::GetHitbox() const
{
if (DoesWindowUseHitbox())
{
return CurrentWindow.Hitbox;
}
return FMoveHitbox();
}

bool UFighterStateComponent::HasActiveMoveWindow()
EWindowStage UFighterStateComponent::GetWindowStage() const
{
return bIsWindowActive;
return CurrentWindowStage;
}

bool UFighterStateComponent::IsInWinddown()
{
return bIsInWinddown;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class BEATBOXERS_API UFighterStateComponent : public UActorComponent, public IFi
IInputParser *MyInputParser;
IFighterPlayerState *MyFighterPlayerState;

uint32 bIsWindowActive : 1;
uint32 bIsHitboxActive : 1;
uint32 bHasMoveWindowHit : 1;
uint32 bIsBeingMoved : 1;
Expand All @@ -38,9 +37,8 @@ class BEATBOXERS_API UFighterStateComponent : public UActorComponent, public IFi
uint32 bIsFrozenForSolo : 1;
uint32 bWantsToCharge: 1;
uint32 bIsKnockedDown : 1;
uint32 bIsInWinddown : 1;


EWindowStage CurrentWindowStage;
EWindowEnd CurrentWindowEnd;
FMovement CurrentMovement;
FMoveWindow CurrentWindow;
Expand Down Expand Up @@ -147,11 +145,11 @@ class BEATBOXERS_API UFighterStateComponent : public UActorComponent, public IFi
virtual void EndSolo() override;
virtual void Knockdown() override;
virtual void KnockdownRecovery(float Duration) override;
virtual bool IsIgnoringCollision() override;
virtual float GetCurrentWindowAccuracy() override;
virtual FMoveHitbox GetHitbox() override;
virtual bool HasActiveMoveWindow() override;
virtual bool IsInWinddown() override;
virtual bool IsIgnoringCollision() const override;
virtual float GetCurrentWindowAccuracy() const override;
virtual bool DoesWindowUseHitbox() const override;
virtual FMoveHitbox GetHitbox() const override;
virtual EWindowStage GetWindowStage() const override;
/** End IFighterState implmementation */

AController* GetOwnerController() const;
Expand Down
6 changes: 6 additions & 0 deletions Source/BeatBoxers/Interfaces/IFighter.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FStartJumpEvent);
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FLandEvent);
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FClashEvent);

// This class does not need to be modified.
UINTERFACE(MinimalAPI, meta=(CannotImplementInterfaceInBlueprint))
Expand Down Expand Up @@ -68,6 +69,8 @@ class BEATBOXERS_API IFighter

virtual FLandEvent& GetOnLandEvent() = 0;

virtual FClashEvent& GetOnClashEvent() = 0;

/** Used to expose event to blueprints, fires when the moveset component recieves input from the input parser. */
virtual void OnInputReceived() = 0;

Expand Down Expand Up @@ -108,4 +111,7 @@ class BEATBOXERS_API IFighter

/** Returns true if there is a current window active and not in the winddown state. */
virtual bool CanClash() = 0;

/** Trigger a clash on this fighter (should then broadcast it's clash event). */
virtual void Clash() = 0;
};
Loading

0 comments on commit 7b671e1

Please sign in to comment.