mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-05 23:28:46 +00:00
add remove ability
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
@@ -133,7 +133,7 @@ bool ACogAbilityReplicator::IsCheatActive(const AActor* EffectTarget, const FCog
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void ACogAbilityReplicator::GiveAbility(AActor* Target, TSubclassOf<UGameplayAbility> AbilityClass)
|
void ACogAbilityReplicator::GiveAbility(AActor* Target, TSubclassOf<UGameplayAbility> AbilityClass) const
|
||||||
{
|
{
|
||||||
Server_GiveAbility(Target, AbilityClass);
|
Server_GiveAbility(Target, AbilityClass);
|
||||||
}
|
}
|
||||||
@@ -148,12 +148,12 @@ void ACogAbilityReplicator::Server_GiveAbility_Implementation(AActor* TargetActo
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsValid(AbilityClass) == false)
|
if (AbilitySystem->IsOwnerActorAuthoritative() == false)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AbilitySystem->IsOwnerActorAuthoritative() == false)
|
if (IsValid(AbilityClass) == false)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -162,6 +162,35 @@ void ACogAbilityReplicator::Server_GiveAbility_Implementation(AActor* TargetActo
|
|||||||
AbilitySystem->GiveAbility(Spec);
|
AbilitySystem->GiveAbility(Spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void ACogAbilityReplicator::RemoveAbility(AActor* TargetActor, const FGameplayAbilitySpecHandle& Handle) const
|
||||||
|
{
|
||||||
|
Server_RemoveAbility(TargetActor, Handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void ACogAbilityReplicator::Server_RemoveAbility_Implementation(AActor* TargetActor, const FGameplayAbilitySpecHandle& Handle) const
|
||||||
|
{
|
||||||
|
UAbilitySystemComponent* AbilitySystem = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(TargetActor, true);
|
||||||
|
|
||||||
|
if (AbilitySystem == nullptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AbilitySystem->IsOwnerActorAuthoritative() == false)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Handle.IsValid() == false)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AbilitySystem->SetRemoveAbilityOnEnd(Handle);
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void ACogAbilityReplicator::ResetAllTweaks()
|
void ACogAbilityReplicator::ResetAllTweaks()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ void UCogAbilityWindow_Abilities::RenderOpenAbilities()
|
|||||||
bool Open = true;
|
bool Open = true;
|
||||||
if (ImGui::Begin(TCHAR_TO_ANSI(*GetAbilityName(Ability)), &Open))
|
if (ImGui::Begin(TCHAR_TO_ANSI(*GetAbilityName(Ability)), &Open))
|
||||||
{
|
{
|
||||||
RenderAbilityInfo(*Spec);
|
RenderAbilityInfo(*AbilitySystemComponent, *Spec);
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,18 +98,6 @@ void UCogAbilityWindow_Abilities::RenderContent()
|
|||||||
|
|
||||||
RenderAbiltiesMenu(Selection);
|
RenderAbiltiesMenu(Selection);
|
||||||
|
|
||||||
//TArray<FGameplayAbilitySpec>& Abilities = AbilitySystemComponent->GetActivatableAbilities();
|
|
||||||
//static int FocusedAbilityIndex = INDEX_NONE;
|
|
||||||
//if (FocusedAbilityIndex != INDEX_NONE && FocusedAbilityIndex < Abilities.Num())
|
|
||||||
//{
|
|
||||||
// RenderAbilityInfo(Abilities[FocusedAbilityIndex]);
|
|
||||||
// if (ImGui::Button("Close", ImVec2(-1, 0)))
|
|
||||||
// {
|
|
||||||
// FocusedAbilityIndex = INDEX_NONE;
|
|
||||||
// }
|
|
||||||
// ImGui::Spacing();
|
|
||||||
//}
|
|
||||||
|
|
||||||
RenderAbilitiesTable(*AbilitySystemComponent);
|
RenderAbilitiesTable(*AbilitySystemComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +203,7 @@ void UCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent&
|
|||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered())
|
||||||
{
|
{
|
||||||
FCogWindowWidgets::BeginTableTooltip();
|
FCogWindowWidgets::BeginTableTooltip();
|
||||||
RenderAbilityInfo(Spec);
|
RenderAbilityInfo(AbilitySystemComponent, Spec);
|
||||||
FCogWindowWidgets::EndTableTooltip();
|
FCogWindowWidgets::EndTableTooltip();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,11 +279,10 @@ void UCogAbilityWindow_Abilities::RenderAbilityContextMenu(UAbilitySystemCompone
|
|||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (ImGui::Button("Open Properties"))
|
if (ImGui::Button("Remove"))
|
||||||
//{
|
{
|
||||||
// GetOwner()->GetPropertyGrid()->Open(BaseAbility);
|
AbilityHandleToRemove = Spec.Handle;
|
||||||
// ImGui::CloseCurrentPopup();
|
}
|
||||||
//}
|
|
||||||
|
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
@@ -326,7 +313,7 @@ FString UCogAbilityWindow_Abilities::GetAbilityName(const UGameplayAbility* Abil
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void UCogAbilityWindow_Abilities::RenderAbilityInfo(FGameplayAbilitySpec& Spec)
|
void UCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec)
|
||||||
{
|
{
|
||||||
UGameplayAbility* Ability = Spec.GetPrimaryInstance();
|
UGameplayAbility* Ability = Spec.GetPrimaryInstance();
|
||||||
if (Ability == nullptr)
|
if (Ability == nullptr)
|
||||||
@@ -334,6 +321,11 @@ void UCogAbilityWindow_Abilities::RenderAbilityInfo(FGameplayAbilitySpec& Spec)
|
|||||||
Ability = Spec.Ability;
|
Ability = Spec.Ability;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Ability == nullptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ImGui::BeginTable("Ability", 2, ImGuiTableFlags_Borders))
|
if (ImGui::BeginTable("Ability", 2, ImGuiTableFlags_Borders))
|
||||||
{
|
{
|
||||||
const ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f);
|
const ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f);
|
||||||
@@ -377,6 +369,15 @@ void UCogAbilityWindow_Abilities::RenderAbilityInfo(FGameplayAbilitySpec& Spec)
|
|||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Text("%u", Spec.ActiveCount);
|
ImGui::Text("%u", Spec.ActiveCount);
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Cooldown
|
||||||
|
//------------------------
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::TextColored(TextColor, "Cooldown");
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
RenderAbilityCooldown(AbilitySystemComponent, *Ability);
|
||||||
|
|
||||||
//------------------------
|
//------------------------
|
||||||
// Handle
|
// Handle
|
||||||
//------------------------
|
//------------------------
|
||||||
@@ -425,6 +426,20 @@ void UCogAbilityWindow_Abilities::GameTick(float DeltaTime)
|
|||||||
ProcessAbilityActivation(AbilityHandleToActivate);
|
ProcessAbilityActivation(AbilityHandleToActivate);
|
||||||
AbilityHandleToActivate = FGameplayAbilitySpecHandle();
|
AbilityHandleToActivate = FGameplayAbilitySpecHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (AbilityHandleToRemove.IsValid())
|
||||||
|
{
|
||||||
|
if (AActor* Selection = GetSelection())
|
||||||
|
{
|
||||||
|
FCogAbilityModule& Module = FCogAbilityModule::Get();
|
||||||
|
if (ACogAbilityReplicator* Replicator = Module.GetLocalReplicator())
|
||||||
|
{
|
||||||
|
Replicator->RemoveAbility(Selection, AbilityHandleToRemove);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AbilityHandleToRemove = FGameplayAbilitySpecHandle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -295,14 +295,10 @@ FString UCogAbilityWindow_Effects::GetEffectName(const UGameplayEffect& Effect)
|
|||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void UCogAbilityWindow_Effects::RenderRemainingTime(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect)
|
void UCogAbilityWindow_Effects::RenderRemainingTime(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect)
|
||||||
{
|
{
|
||||||
float StartTime = ActiveEffect.StartWorldTime;
|
const float StartTime = ActiveEffect.StartWorldTime;
|
||||||
float Duration = ActiveEffect.GetDuration();
|
const float Duration = ActiveEffect.GetDuration();
|
||||||
|
|
||||||
if (Duration <= 0)
|
if (Duration >= 0)
|
||||||
{
|
|
||||||
ImGui::Text("NA");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
UWorld* World = AbilitySystemComponent.GetWorld();
|
UWorld* World = AbilitySystemComponent.GetWorld();
|
||||||
const float RemainingTime = StartTime + Duration - World->GetTimeSeconds();
|
const float RemainingTime = StartTime + Duration - World->GetTimeSeconds();
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ public:
|
|||||||
|
|
||||||
static bool IsCheatActive(const AActor* EffectTarget, const FCogAbilityCheat& Cheat);
|
static bool IsCheatActive(const AActor* EffectTarget, const FCogAbilityCheat& Cheat);
|
||||||
|
|
||||||
void GiveAbility(AActor* TargetActor, TSubclassOf<UGameplayAbility> AbilityClass);
|
void GiveAbility(AActor* TargetActor, TSubclassOf<UGameplayAbility> AbilityClass) const;
|
||||||
|
|
||||||
|
void RemoveAbility(AActor* TargetActor, const FGameplayAbilitySpecHandle& Handle) const;
|
||||||
|
|
||||||
void ResetAllTweaks();
|
void ResetAllTweaks();
|
||||||
|
|
||||||
@@ -50,6 +52,9 @@ private:
|
|||||||
UFUNCTION(Reliable, Server)
|
UFUNCTION(Reliable, Server)
|
||||||
void Server_GiveAbility(AActor* TargetActor, TSubclassOf<UGameplayAbility> AbilityClass) const;
|
void Server_GiveAbility(AActor* TargetActor, TSubclassOf<UGameplayAbility> AbilityClass) const;
|
||||||
|
|
||||||
|
UFUNCTION(Reliable, Server)
|
||||||
|
void Server_RemoveAbility(AActor* TargetActor, const FGameplayAbilitySpecHandle& Handle) const;
|
||||||
|
|
||||||
UFUNCTION(Reliable, Server)
|
UFUNCTION(Reliable, Server)
|
||||||
void Server_ResetAllTweaks();
|
void Server_ResetAllTweaks();
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ protected:
|
|||||||
|
|
||||||
virtual void RenderOpenAbilities();
|
virtual void RenderOpenAbilities();
|
||||||
|
|
||||||
virtual void RenderAbilityInfo(FGameplayAbilitySpec& Spec);
|
virtual void RenderAbilityInfo(const UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec);
|
||||||
|
|
||||||
virtual void ProcessAbilityActivation(FGameplayAbilitySpecHandle Handle);
|
virtual void ProcessAbilityActivation(FGameplayAbilitySpecHandle Handle);
|
||||||
|
|
||||||
@@ -57,5 +57,7 @@ private:
|
|||||||
|
|
||||||
FGameplayAbilitySpecHandle AbilityHandleToActivate;
|
FGameplayAbilitySpecHandle AbilityHandleToActivate;
|
||||||
|
|
||||||
|
FGameplayAbilitySpecHandle AbilityHandleToRemove;
|
||||||
|
|
||||||
TArray<FGameplayAbilitySpecHandle> OpenedAbilities;
|
TArray<FGameplayAbilitySpecHandle> OpenedAbilities;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
void UCogEngineWindow_DebugSettings::RenderHelp()
|
void UCogEngineWindow_DebugSettings::RenderHelp()
|
||||||
{
|
{
|
||||||
ImGui::Text(
|
ImGui::Text(
|
||||||
"This window can be used to setup how the debug display is drawn. "
|
"This window can be used to tweak how the debug display is drawn. "
|
||||||
"Check each item for more info. "
|
"Check each item for more info. "
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,32 +6,6 @@
|
|||||||
|
|
||||||
char ImGuiTextBuffer::EmptyString[1] = { 0 };
|
char ImGuiTextBuffer::EmptyString[1] = { 0 };
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
// FCogLogOutputDevice
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
UCogLogOutputDevice::UCogLogOutputDevice()
|
|
||||||
{
|
|
||||||
GLog->AddOutputDevice(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
UCogLogOutputDevice::~UCogLogOutputDevice()
|
|
||||||
{
|
|
||||||
if (GLog != nullptr)
|
|
||||||
{
|
|
||||||
GLog->RemoveOutputDevice(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
void UCogLogOutputDevice::Serialize(const TCHAR* Message, ELogVerbosity::Type Verbosity, const class FName& Category)
|
|
||||||
{
|
|
||||||
if (OutputLog != nullptr)
|
|
||||||
{
|
|
||||||
OutputLog->AddLog(Message, Verbosity, Category);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
// FCogWindow_Log
|
// FCogWindow_Log
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -302,3 +276,29 @@ void UCogEngineWindow_OutputLog::RenderContent()
|
|||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
// FCogLogOutputDevice
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
UCogLogOutputDevice::UCogLogOutputDevice()
|
||||||
|
{
|
||||||
|
GLog->AddOutputDevice(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
UCogLogOutputDevice::~UCogLogOutputDevice()
|
||||||
|
{
|
||||||
|
if (GLog != nullptr)
|
||||||
|
{
|
||||||
|
GLog->RemoveOutputDevice(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void UCogLogOutputDevice::Serialize(const TCHAR* Message, ELogVerbosity::Type Verbosity, const class FName& Category)
|
||||||
|
{
|
||||||
|
if (OutputLog != nullptr)
|
||||||
|
{
|
||||||
|
OutputLog->AddLog(Message, Verbosity, Category);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,17 @@ UCogEngineWindow_Skeleton::UCogEngineWindow_Skeleton()
|
|||||||
bHasMenu = true;
|
bHasMenu = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void UCogEngineWindow_Skeleton::RenderHelp()
|
||||||
|
{
|
||||||
|
ImGui::Text(
|
||||||
|
"This window display the bone hierarchy and the skeleton debug draw of the selected actor if it has a Skeletal Mesh. "
|
||||||
|
"Mouse over a bone to highlight it. "
|
||||||
|
"Right click a bone to access more debug display. "
|
||||||
|
"Use the [Ctrl] key to toggle the bone debug draw recursively. "
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void UCogEngineWindow_Skeleton::OnSelectionChanged(AActor* OldSelection, AActor* NewSelection)
|
void UCogEngineWindow_Skeleton::OnSelectionChanged(AActor* OldSelection, AActor* NewSelection)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,11 +31,14 @@ class COGENGINE_API UCogEngineWindow_Skeleton : public UCogWindow
|
|||||||
public:
|
public:
|
||||||
UCogEngineWindow_Skeleton();
|
UCogEngineWindow_Skeleton();
|
||||||
|
|
||||||
virtual void RenderContent() override;
|
virtual void RenderHelp() override;
|
||||||
virtual void RenderTick(float DeltaTime) override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
virtual void RenderContent() override;
|
||||||
|
|
||||||
|
virtual void RenderTick(float DeltaTime) override;
|
||||||
|
|
||||||
virtual void OnSelectionChanged(AActor* OldSelection, AActor* NewSelection) override;
|
virtual void OnSelectionChanged(AActor* OldSelection, AActor* NewSelection) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user