Skip to content

Commit

Permalink
Merge branch '5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlicekdominik committed Feb 21, 2023
2 parents 46fd48c + 4563c93 commit e33db63
Show file tree
Hide file tree
Showing 18 changed files with 228 additions and 64 deletions.
2 changes: 1 addition & 1 deletion ActorInteractionPlugin.uplugin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "3.0.1.1",
"VersionName": "3.0.1.2",
"FriendlyName": "Actor Interaction Plugin",
"Description": "Actor Interaction Plugin is an Open-source Mountea Framework components-based simple framework providing utilities for smart Actor Interaction with other Actors. Developed with Game Developers in mind to allow as easy as possible implementation while maintaining high scalability and diverse options to tweak everything.",
"Category": "Mountea Framework",
Expand Down
8 changes: 0 additions & 8 deletions Config/FilterPlugin.ini

This file was deleted.

4 changes: 2 additions & 2 deletions Source/ActorInteractionPlugin/ActorInteractionPlugin.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class ActorInteractionPlugin : ModuleRules
public ActorInteractionPlugin(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
bEnforceIWYU = true;

PublicIncludePaths.AddRange(
new string[] {
Expand Down Expand Up @@ -50,15 +51,14 @@ public ActorInteractionPlugin(ReadOnlyTargetRules Target) : base(Target)
"InputCore",

"InteractionEditorNotifications",

#if UE_4_26_OR_LATER
"DeveloperSettings",
#endif
// ... add private dependencies that you statically link with here ...
}
);


DynamicallyLoadedModuleNames.AddRange(
new string[]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,6 @@ void UActorInteractableComponent::GetLifetimeReplicatedProps(TArray<FLifetimePro
#pragma endregion Replication

#if WITH_EDITOR

void UActorInteractableComponent::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,6 @@ UActorInteractableComponentBase::UActorInteractableComponentBase()

CachedInteractionWeight = InteractionWeight;

// Setup default Data Table
if (InteractableData.IsNull())
{
const auto DefaultTable = UActorInteractionFunctionLibrary::GetInteractableDefaultDataTable();
if (DefaultTable != nullptr)
{
InteractableData.DataTable = DefaultTable;
}
}

// Setup default Widget Class
if (GetWidgetClass() == nullptr)
{
const auto DefaultWidgetClass = UActorInteractionFunctionLibrary::GetInteractableDefaultWidgetClass();
if (DefaultWidgetClass != nullptr)
{
SetWidgetClass(DefaultWidgetClass.Get());
}
}

#if WITH_EDITORONLY_DATA
bVisualizeComponent = true;
#endif
Expand Down Expand Up @@ -173,6 +153,10 @@ void UActorInteractableComponentBase::InitWidget()
void UActorInteractableComponentBase::OnRegister()
{

#if WITH_EDITOR
//FindAndSetDefaults();
#endif

#if WITH_EDITORONLY_DATA
if (bVisualizeComponent && SpriteComponent == nullptr && GetOwner() && !GetWorld()->IsGameWorld() )
{
Expand Down Expand Up @@ -481,7 +465,12 @@ void UActorInteractableComponentBase::SetState(const EInteractableStateV2 NewSta
case EInteractableStateV2::EIS_Disabled:
{
InteractableState = NewState;
CleanupComponent();

// Replacing Cleanup
StopHighlight();
OnInteractableStateChanged.Broadcast(InteractableState);
if (GetWorld()) GetWorld()->GetTimerManager().ClearAllTimersForObject(this);
OnInteractorLost.Broadcast(Interactor);

for (const auto Itr : CollisionComponents)
{
Expand All @@ -508,7 +497,12 @@ void UActorInteractableComponentBase::SetState(const EInteractableStateV2 NewSta
case EInteractableStateV2::EIS_Disabled:
{
InteractableState = NewState;
CleanupComponent();

// Replacing Cleanup
StopHighlight();
OnInteractableStateChanged.Broadcast(InteractableState);
if (GetWorld()) GetWorld()->GetTimerManager().ClearAllTimersForObject(this);
OnInteractorLost.Broadcast(Interactor);

for (const auto Itr : CollisionComponents)
{
Expand Down Expand Up @@ -553,7 +547,12 @@ void UActorInteractableComponentBase::SetState(const EInteractableStateV2 NewSta
case EInteractableStateV2::EIS_Asleep:
{
InteractableState = NewState;
CleanupComponent();

// Replacing Cleanup
StopHighlight();
OnInteractableStateChanged.Broadcast(InteractableState);
if (GetWorld()) GetWorld()->GetTimerManager().ClearAllTimersForObject(this);
OnInteractorLost.Broadcast(Interactor);

for (const auto Itr : CollisionComponents)
{
Expand Down Expand Up @@ -884,7 +883,7 @@ TArray<UPrimitiveComponent*> UActorInteractableComponentBase::GetCollisionCompon
EInteractableLifecycle UActorInteractableComponentBase::GetLifecycleMode() const
{ return LifecycleMode;}

void UActorInteractableComponentBase::SetLifecycleMode(const EInteractableLifecycle& NewMode)
void UActorInteractableComponentBase::SetLifecycleMode(const EInteractableLifecycle NewMode)
{
LifecycleMode = NewMode;

Expand Down Expand Up @@ -1190,6 +1189,22 @@ ETimingComparison UActorInteractableComponentBase::GetComparisonMethod() const
void UActorInteractableComponentBase::SetComparisonMethod(const ETimingComparison Value)
{ ComparisonMethod = Value; }

void UActorInteractableComponentBase::SetDefaults()
{
if (const auto DefaultTable = UActorInteractionFunctionLibrary::GetInteractableDefaultDataTable())
{
InteractableData.DataTable = DefaultTable;
}

if (const auto DefaultWidgetClass = UActorInteractionFunctionLibrary::GetInteractableDefaultWidgetClass())
{
if (DefaultWidgetClass != nullptr)
{
SetWidgetClass(DefaultWidgetClass.Get());
}
}
}

void UActorInteractableComponentBase::InteractorFound(const TScriptInterface<IActorInteractorInterface>& FoundInteractor)
{
if (CanBeTriggered())
Expand Down Expand Up @@ -1959,7 +1974,7 @@ void UActorInteractableComponentBase::PostEditChangeChainProperty(FPropertyChang
(
interactableName.Append(TEXT(": UI Space changed! Component Scale has been updated. Update 'DrawSize' to match new Widget Space!"))
);
FEditorHelper::DisplayEditorNotification(ErrorMessage, SNotificationItem::CS_Fail, 5.f, 2.f, TEXT("Icons.Info"));
FEditorHelper::DisplayEditorNotification(ErrorMessage, SNotificationItem::CS_Fail, 5.f, 2.f, TEXT("NotificationList.DefaultMessage"));
}
}

Expand Down Expand Up @@ -2058,6 +2073,56 @@ EDataValidationResult UActorInteractableComponentBase::IsDataValid(TArray<FText>

return bAnyError ? EDataValidationResult::Invalid : DefaultValue;
}

bool UActorInteractableComponentBase::Modify(bool bAlwaysMarkDirty)
{
const bool bResult = Super::Modify(bAlwaysMarkDirty);

const bool bShouldNotify =
{
GetOwner() != nullptr &&
UActorInteractionFunctionLibrary::IsEditorDebugEnabled() &&
(
InteractableData.DataTable == nullptr ||
GetWidgetClass() == nullptr
)
};

if (bShouldNotify)
{
FString interactableName = GetName();
// Format Name
{
if (interactableName.Contains(TEXT("_GEN_VARIABLE")))
{
interactableName.ReplaceInline(TEXT("_GEN_VARIABLE"), TEXT(""));
}
if (interactableName.Contains(TEXT("SKEL_")))
{
interactableName.ReplaceInline(TEXT("SKEL_"), TEXT(""));
}
if(interactableName.EndsWith(TEXT("_C")) && interactableName.StartsWith(TEXT("Default__")))
{

interactableName.RightChopInline(9);
interactableName.LeftChopInline(2);
}
}

FString ownerName;
GetOwner()->GetName(ownerName);

const FText ErrorMessage = FText::FromString
(
interactableName.Append(" from ").Append(ownerName).Append(TEXT(": Interactable Data or Widget Class are not valid! Use 'SetDefaults' to avoid issues!"))
);
FEditorHelper::DisplayEditorNotification(ErrorMessage, SNotificationItem::CS_Fail, 5.f, 2.f, TEXT("NotificationList.DefaultMessage"));

}

return bResult;
}

#endif

void UActorInteractableComponentBase::DrawDebug()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void UActorInteractorComponentBase::EvaluateInteractable(const TScriptInterface<
}
}

void UActorInteractorComponentBase::StartInteraction(const float StartTime, const FKey& InputKey)
void UActorInteractorComponentBase::StartInteraction(const float StartTime, FKey InputKey)
{
if (CanInteract() && ActiveInteractable.GetInterface())
{
Expand All @@ -161,7 +161,7 @@ void UActorInteractorComponentBase::StartInteraction(const float StartTime, cons
}
}

void UActorInteractorComponentBase::StopInteraction(const float StartTime, const FKey& InputKey)
void UActorInteractorComponentBase::StopInteraction(const float StartTime, FKey InputKey)
{
if (CanInteract() && ActiveInteractable.GetInterface())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ void UActorInteractorComponentTrace::PostEditChangeChainProperty(FPropertyChange
(
InteractorName.Append(TEXT(": TraceInterval is more than 3s! This might be unintentional and cause gameplay issues."))
);
FEditorHelper::DisplayEditorNotification(ErrorMessage, SNotificationItem::CS_Fail, 5.f, 2.f, TEXT("Icons.Warning"));
FEditorHelper::DisplayEditorNotification(ErrorMessage, SNotificationItem::CS_Fail, 5.f, 2.f, TEXT("NotificationList.DefaultMessage"));
}
}

Expand All @@ -475,7 +475,7 @@ void UActorInteractorComponentTrace::PostEditChangeChainProperty(FPropertyChange
(
InteractorName.Append(TEXT(": TraceRange is more than 5000cm! This might be unintentional and cause gameplay issues."))
);
FEditorHelper::DisplayEditorNotification(ErrorMessage, SNotificationItem::CS_Fail, 5.f, 2.f, TEXT("Icons.Warning"));
FEditorHelper::DisplayEditorNotification(ErrorMessage, SNotificationItem::CS_Fail, 5.f, 2.f, TEXT("NotificationList.DefaultMessage"));
}
}

Expand All @@ -487,7 +487,7 @@ void UActorInteractorComponentTrace::PostEditChangeChainProperty(FPropertyChange
(
InteractorName.Append(TEXT(": TraceShapeHalfSize is more than 25cm! This might be unintentional and cause gameplay issues."))
);
FEditorHelper::DisplayEditorNotification(ErrorMessage, SNotificationItem::CS_Fail, 5.f, 2.f, TEXT("Icons.Warning"));
FEditorHelper::DisplayEditorNotification(ErrorMessage, SNotificationItem::CS_Fail, 5.f, 2.f, TEXT("NotificationList.DefaultMessage"));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class ACTORINTERACTIONPLUGIN_API UActorInteractableComponentBase : public UWidge
* @param NewMode New Lifecycle Mode to be used for this Interactable.
*/
UFUNCTION(BlueprintCallable, Category="Interaction")
virtual void SetLifecycleMode(const EInteractableLifecycle& NewMode) override;
virtual void SetLifecycleMode(const EInteractableLifecycle NewMode) override;


/**
Expand Down Expand Up @@ -583,6 +583,14 @@ class ACTORINTERACTIONPLUGIN_API UActorInteractableComponentBase : public UWidge
UFUNCTION(BlueprintCallable, Category="Interaction")
virtual void SetComparisonMethod(const ETimingComparison Value) override;

/**
* Finds default values from Developer settings and tries to set them for this component.
* Will override current settings!
* Will set those values only if not null.
*/
UFUNCTION(BlueprintCallable, CallInEditor, Category="Interaction", meta=(DisplayName="SetDefaults"))
virtual void SetDefaults() override;

#pragma endregion

#pragma region EventFunctions
Expand Down Expand Up @@ -1392,7 +1400,7 @@ class ACTORINTERACTIONPLUGIN_API UActorInteractableComponentBase : public UWidge
/**
* List of Interactable Classes which are ignored
*/
UPROPERTY(SaveGame, EditAnywhere, Category="Interaction|Optional", meta=(NoResetToDefault, AllowAbstract=false, MustImplement="ActorInteractorInterface", BlueprintBaseOnly))
UPROPERTY(SaveGame, EditAnywhere, Category="Interaction|Optional", meta=(NoResetToDefault, AllowAbstract=false, MustImplement="/Script/ActorInteractionPlugin.ActorInteractorInterface", BlueprintBaseOnly))
TArray<TSoftClassPtr<UObject>> IgnoredClasses;

/**
Expand Down Expand Up @@ -1579,6 +1587,7 @@ class ACTORINTERACTIONPLUGIN_API UActorInteractableComponentBase : public UWidge

virtual void PostEditChangeChainProperty(FPropertyChangedChainEvent& PropertyChangedEvent) override;
virtual EDataValidationResult IsDataValid(TArray<FText>& ValidationErrors) override;
virtual bool Modify(bool bAlwaysMarkDirty) override;

#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ class ACTORINTERACTIONPLUGIN_API UActorInteractorComponentBase : public UActorCo
* @param InputKey Optional Key. Some Interactions might require this value to perform checks.
*/
UFUNCTION(BlueprintCallable, Category="Interaction")
virtual void StartInteraction(const float StartTime, const FKey& InputKey) override;
virtual void StartInteraction(const float StartTime, FKey InputKey) override;
/**
* Function to stop interaction.
* No conditions required.
*/
UFUNCTION(BlueprintCallable, Category="Interaction")
virtual void StopInteraction(const float StartTime, const FKey& InputKey) override;
virtual void StopInteraction(const float StartTime, FKey InputKey) override;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,18 @@ class ACTORINTERACTIONPLUGIN_API UActorInteractionFunctionLibrary : public UBlue
AIntP_LOG(Error, TEXT("[GetInteractableDefaultWidgetClass] Cannot load ActorInteractionPluginSettings! Using null value."))
return nullptr;
}

UFUNCTION(BlueprintCallable, BlueprintPure, Category="Mountea|Interaction", meta=(CompactNodeTitle="Default Interactable Data"))
static bool IsEditorDebugEnabled()
{
const UActorInteractionPluginSettings* Settings = GetMutableDefault<UActorInteractionPluginSettings>();

if (Settings)
{
return Settings->IsEditorDebugEnabled();
}

AIntP_LOG(Error, TEXT("[GetInteractableDefaultWidgetClass] Cannot load ActorInteractionPluginSettings! Using null value."))
return false;
}
};
Loading

0 comments on commit e33db63

Please sign in to comment.