Skip to content

Commit 4680fd5

Browse files
Merge branch '5.1_dev' into 5.1
2 parents 27deafd + 0b72561 commit 4680fd5

14 files changed

+194
-47
lines changed

ActorInteractionPlugin.uplugin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"FileVersion": 3,
33
"Version": 1,
4-
"VersionName": "3.0.1.1",
4+
"VersionName": "3.0.1.2",
55
"FriendlyName": "Actor Interaction Plugin",
66
"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.",
77
"Category": "Mountea Framework",

Config/FilterPlugin.ini

Lines changed: 0 additions & 8 deletions
This file was deleted.

Source/ActorInteractionPlugin/ActorInteractionPlugin.Build.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class ActorInteractionPlugin : ModuleRules
88
public ActorInteractionPlugin(ReadOnlyTargetRules Target) : base(Target)
99
{
1010
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
11+
bEnforceIWYU = true;
1112

1213
PublicIncludePaths.AddRange(
1314
new string[] {
@@ -50,15 +51,14 @@ public ActorInteractionPlugin(ReadOnlyTargetRules Target) : base(Target)
5051
"InputCore",
5152

5253
"InteractionEditorNotifications",
53-
54+
5455
#if UE_4_26_OR_LATER
5556
"DeveloperSettings",
5657
#endif
5758
// ... add private dependencies that you statically link with here ...
5859
}
5960
);
6061

61-
6262
DynamicallyLoadedModuleNames.AddRange(
6363
new string[]
6464
{

Source/ActorInteractionPlugin/Private/Components/ActorInteractableComponent.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,6 @@ void UActorInteractableComponent::GetLifetimeReplicatedProps(TArray<FLifetimePro
727727
#pragma endregion Replication
728728

729729
#if WITH_EDITOR
730-
731730
void UActorInteractableComponent::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
732731
{
733732
Super::PostEditChangeProperty(PropertyChangedEvent);

Source/ActorInteractionPlugin/Private/Components/ActorInteractableComponentBase.cpp

Lines changed: 89 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -67,26 +67,6 @@ UActorInteractableComponentBase::UActorInteractableComponentBase()
6767

6868
CachedInteractionWeight = InteractionWeight;
6969

70-
// Setup default Data Table
71-
if (InteractableData.IsNull())
72-
{
73-
const auto DefaultTable = UActorInteractionFunctionLibrary::GetInteractableDefaultDataTable();
74-
if (DefaultTable != nullptr)
75-
{
76-
InteractableData.DataTable = DefaultTable;
77-
}
78-
}
79-
80-
// Setup default Widget Class
81-
if (GetWidgetClass() == nullptr)
82-
{
83-
const auto DefaultWidgetClass = UActorInteractionFunctionLibrary::GetInteractableDefaultWidgetClass();
84-
if (DefaultWidgetClass != nullptr)
85-
{
86-
SetWidgetClass(DefaultWidgetClass.Get());
87-
}
88-
}
89-
9070
#if WITH_EDITORONLY_DATA
9171
bVisualizeComponent = true;
9272
#endif
@@ -173,6 +153,10 @@ void UActorInteractableComponentBase::InitWidget()
173153
void UActorInteractableComponentBase::OnRegister()
174154
{
175155

156+
#if WITH_EDITOR
157+
//FindAndSetDefaults();
158+
#endif
159+
176160
#if WITH_EDITORONLY_DATA
177161
if (bVisualizeComponent && SpriteComponent == nullptr && GetOwner() && !GetWorld()->IsGameWorld() )
178162
{
@@ -481,7 +465,12 @@ void UActorInteractableComponentBase::SetState(const EInteractableStateV2 NewSta
481465
case EInteractableStateV2::EIS_Disabled:
482466
{
483467
InteractableState = NewState;
484-
CleanupComponent();
468+
469+
// Replacing Cleanup
470+
StopHighlight();
471+
OnInteractableStateChanged.Broadcast(InteractableState);
472+
if (GetWorld()) GetWorld()->GetTimerManager().ClearAllTimersForObject(this);
473+
OnInteractorLost.Broadcast(Interactor);
485474

486475
for (const auto Itr : CollisionComponents)
487476
{
@@ -508,7 +497,12 @@ void UActorInteractableComponentBase::SetState(const EInteractableStateV2 NewSta
508497
case EInteractableStateV2::EIS_Disabled:
509498
{
510499
InteractableState = NewState;
511-
CleanupComponent();
500+
501+
// Replacing Cleanup
502+
StopHighlight();
503+
OnInteractableStateChanged.Broadcast(InteractableState);
504+
if (GetWorld()) GetWorld()->GetTimerManager().ClearAllTimersForObject(this);
505+
OnInteractorLost.Broadcast(Interactor);
512506

513507
for (const auto Itr : CollisionComponents)
514508
{
@@ -553,7 +547,12 @@ void UActorInteractableComponentBase::SetState(const EInteractableStateV2 NewSta
553547
case EInteractableStateV2::EIS_Asleep:
554548
{
555549
InteractableState = NewState;
556-
CleanupComponent();
550+
551+
// Replacing Cleanup
552+
StopHighlight();
553+
OnInteractableStateChanged.Broadcast(InteractableState);
554+
if (GetWorld()) GetWorld()->GetTimerManager().ClearAllTimersForObject(this);
555+
OnInteractorLost.Broadcast(Interactor);
557556

558557
for (const auto Itr : CollisionComponents)
559558
{
@@ -884,7 +883,7 @@ TArray<UPrimitiveComponent*> UActorInteractableComponentBase::GetCollisionCompon
884883
EInteractableLifecycle UActorInteractableComponentBase::GetLifecycleMode() const
885884
{ return LifecycleMode;}
886885

887-
void UActorInteractableComponentBase::SetLifecycleMode(const EInteractableLifecycle& NewMode)
886+
void UActorInteractableComponentBase::SetLifecycleMode(const EInteractableLifecycle NewMode)
888887
{
889888
LifecycleMode = NewMode;
890889

@@ -1190,6 +1189,22 @@ ETimingComparison UActorInteractableComponentBase::GetComparisonMethod() const
11901189
void UActorInteractableComponentBase::SetComparisonMethod(const ETimingComparison Value)
11911190
{ ComparisonMethod = Value; }
11921191

1192+
void UActorInteractableComponentBase::SetDefaults()
1193+
{
1194+
if (const auto DefaultTable = UActorInteractionFunctionLibrary::GetInteractableDefaultDataTable())
1195+
{
1196+
InteractableData.DataTable = DefaultTable;
1197+
}
1198+
1199+
if (const auto DefaultWidgetClass = UActorInteractionFunctionLibrary::GetInteractableDefaultWidgetClass())
1200+
{
1201+
if (DefaultWidgetClass != nullptr)
1202+
{
1203+
SetWidgetClass(DefaultWidgetClass.Get());
1204+
}
1205+
}
1206+
}
1207+
11931208
void UActorInteractableComponentBase::InteractorFound(const TScriptInterface<IActorInteractorInterface>& FoundInteractor)
11941209
{
11951210
if (CanBeTriggered())
@@ -2058,6 +2073,56 @@ EDataValidationResult UActorInteractableComponentBase::IsDataValid(TArray<FText>
20582073

20592074
return bAnyError ? EDataValidationResult::Invalid : DefaultValue;
20602075
}
2076+
2077+
bool UActorInteractableComponentBase::Modify(bool bAlwaysMarkDirty)
2078+
{
2079+
const bool bResult = Super::Modify(bAlwaysMarkDirty);
2080+
2081+
const bool bShouldNotify =
2082+
{
2083+
GetOwner() != nullptr &&
2084+
UActorInteractionFunctionLibrary::IsEditorDebugEnabled() &&
2085+
(
2086+
InteractableData.DataTable == nullptr ||
2087+
GetWidgetClass() == nullptr
2088+
)
2089+
};
2090+
2091+
if (bShouldNotify)
2092+
{
2093+
FString interactableName = GetName();
2094+
// Format Name
2095+
{
2096+
if (interactableName.Contains(TEXT("_GEN_VARIABLE")))
2097+
{
2098+
interactableName.ReplaceInline(TEXT("_GEN_VARIABLE"), TEXT(""));
2099+
}
2100+
if (interactableName.Contains(TEXT("SKEL_")))
2101+
{
2102+
interactableName.ReplaceInline(TEXT("SKEL_"), TEXT(""));
2103+
}
2104+
if(interactableName.EndsWith(TEXT("_C")) && interactableName.StartsWith(TEXT("Default__")))
2105+
{
2106+
2107+
interactableName.RightChopInline(9);
2108+
interactableName.LeftChopInline(2);
2109+
}
2110+
}
2111+
2112+
FString ownerName;
2113+
GetOwner()->GetName(ownerName);
2114+
2115+
const FText ErrorMessage = FText::FromString
2116+
(
2117+
interactableName.Append(" from ").Append(ownerName).Append(TEXT(": Interactable Data or Widget Class are not valid! Use 'SetDefaults' to avoid issues!"))
2118+
);
2119+
FEditorHelper::DisplayEditorNotification(ErrorMessage, SNotificationItem::CS_Fail, 5.f, 2.f, TEXT("Icons.Info"));
2120+
2121+
}
2122+
2123+
return bResult;
2124+
}
2125+
20612126
#endif
20622127

20632128
void UActorInteractableComponentBase::DrawDebug()

Source/ActorInteractionPlugin/Public/Components/ActorInteractableComponentBase.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ class ACTORINTERACTIONPLUGIN_API UActorInteractableComponentBase : public UWidge
338338
* @param NewMode New Lifecycle Mode to be used for this Interactable.
339339
*/
340340
UFUNCTION(BlueprintCallable, Category="Interaction")
341-
virtual void SetLifecycleMode(const EInteractableLifecycle& NewMode) override;
341+
virtual void SetLifecycleMode(const EInteractableLifecycle NewMode) override;
342342

343343

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

586+
/**
587+
* Finds default values from Developer settings and tries to set them for this component.
588+
* Will override current settings!
589+
* Will set those values only if not null.
590+
*/
591+
UFUNCTION(BlueprintCallable, CallInEditor, Category="Interaction", meta=(DisplayName="SetDefaults"))
592+
virtual void SetDefaults() override;
593+
586594
#pragma endregion
587595

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

13981406
/**
@@ -1579,6 +1587,7 @@ class ACTORINTERACTIONPLUGIN_API UActorInteractableComponentBase : public UWidge
15791587

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

15831592
#endif
15841593

Source/ActorInteractionPlugin/Public/Helpers/ActorInteractionFunctionLibrary.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,18 @@ class ACTORINTERACTIONPLUGIN_API UActorInteractionFunctionLibrary : public UBlue
7171
AIntP_LOG(Error, TEXT("[GetInteractableDefaultWidgetClass] Cannot load ActorInteractionPluginSettings! Using null value."))
7272
return nullptr;
7373
}
74+
75+
UFUNCTION(BlueprintCallable, BlueprintPure, Category="Mountea|Interaction", meta=(CompactNodeTitle="Default Interactable Data"))
76+
static bool IsEditorDebugEnabled()
77+
{
78+
const UActorInteractionPluginSettings* Settings = GetMutableDefault<UActorInteractionPluginSettings>();
79+
80+
if (Settings)
81+
{
82+
return Settings->IsEditorDebugEnabled();
83+
}
84+
85+
AIntP_LOG(Error, TEXT("[GetInteractableDefaultWidgetClass] Cannot load ActorInteractionPluginSettings! Using null value."))
86+
return false;
87+
}
7488
};

Source/ActorInteractionPlugin/Public/Helpers/ActorInteractionPluginSettings.h

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,44 @@ class ACTORINTERACTIONPLUGIN_API UActorInteractionPluginSettings : public UDevel
2424
SectionName = TEXT("Interaction");
2525
}
2626

27+
/* Defines whether in-editor debug is enabled. */
28+
UPROPERTY(config, EditAnywhere, Category="Editor")
29+
uint8 bEditorDebugEnabled : 1;
30+
2731
/* Defines how often is the Interaction widget updated per second.*/
28-
UPROPERTY(config, EditAnywhere, Category = "Widgets", meta=(Units="s", UIMin=0.001, ClampMin=0.001))
32+
UPROPERTY(config, EditAnywhere, Category = "Widgets", meta=(Units="s", UIMin=0.001, ClampMin=0.001, ConfigRestartRequired = true))
2933
float WidgetUpdateFrequency = 0.05f;
3034

3135
/* Defines default Interactable Widget class.*/
32-
UPROPERTY(config, EditAnywhere, Category = "Widgets", meta=(AllowedClasses="UserWidget", MustImplement="ActorInteractionWidget"))
36+
UPROPERTY(config, EditAnywhere, Category = "Widgets", meta=(AllowedClasses="UserWidget", MustImplement="/Script/ActorInteractionPlugin.ActorInteractionWidget", ConfigRestartRequired = true))
3337
TSoftClassPtr<UUserWidget>InteractableDefaultWidgetClass;
3438

3539
/* Defines default DataTable which contains Interactable data values.*/
36-
UPROPERTY(config, EditAnywhere, Category = "Interaction Data", meta=(AllowedClasses = "DataTable"))
40+
UPROPERTY(config, EditAnywhere, Category = "Interaction Data", meta=(AllowedClasses = "DataTable", ConfigRestartRequired = true))
3741
TSoftObjectPtr<UDataTable> InteractableDefaultDataTable;
3842

39-
43+
#if WITH_EDITOR
44+
virtual FText GetSectionText() const override
45+
{
46+
return NSLOCTEXT("ActorInteractionPlugin", "MounteaSettingsDescription", "Actor Interaction Plugin");
47+
}
48+
49+
virtual FText GetSectionDescription() const override
50+
{
51+
return NSLOCTEXT("ActorInteractionPlugin", "MounteaSettingsDescription", "Default values for Mountea Plugins.");
52+
}
53+
4054
virtual FName GetContainerName() const override
4155
{
4256
return "Project";
4357
}
58+
#endif
4459

4560
public:
4661

62+
bool IsEditorDebugEnabled() const
63+
{ return bEditorDebugEnabled; };
64+
4765
float GetWidgetUpdateFrequency() const
4866
{ return WidgetUpdateFrequency; }
4967

@@ -53,3 +71,4 @@ class ACTORINTERACTIONPLUGIN_API UActorInteractionPluginSettings : public UDevel
5371
TSoftClassPtr<UUserWidget> GetInteractableDefaultWidgetClass() const
5472
{ return InteractableDefaultWidgetClass; };
5573
};
74+

Source/ActorInteractionPlugin/Public/Interfaces/ActorInteractableInterface.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ class ACTORINTERACTIONPLUGIN_API IActorInteractableInterface
278278
virtual void SetCollisionChannel(const ECollisionChannel& NewChannel) = 0;
279279

280280
virtual EInteractableLifecycle GetLifecycleMode() const = 0;
281-
virtual void SetLifecycleMode(const EInteractableLifecycle& NewMode) = 0;
281+
virtual void SetLifecycleMode(const EInteractableLifecycle NewMode) = 0;
282282

283283
virtual int32 GetLifecycleCount() const = 0;
284284
virtual void SetLifecycleCount(const int32 NewLifecycleCount) = 0;
@@ -359,6 +359,8 @@ class ACTORINTERACTIONPLUGIN_API IActorInteractableInterface
359359

360360
virtual void InteractableDependencyStartedCallback(const TScriptInterface<IActorInteractableInterface>& NewMaster) = 0;
361361
virtual void InteractableDependencyStoppedCallback(const TScriptInterface<IActorInteractableInterface>& FormerMaster) = 0;
362+
363+
virtual void SetDefaults() = 0;
362364

363365
virtual FOnInteractableSelected& GetOnInteractableSelectedHandle() = 0;
364366
virtual FInteractorFound& GetOnInteractorFoundHandle() = 0;

Source/ActorInteractionPluginEditor/ActorInteractionPluginEditor.Build.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ public ActorInteractionPluginEditor(ReadOnlyTargetRules Target) : base(Target)
99
{
1010
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
1111
bEnforceIWYU = true;
12+
13+
PrecompileForTargets = PrecompileTargetsType.None;
14+
bPrecompile = false;
15+
bUsePrecompiled = false;
1216

1317
PublicDependencyModuleNames.AddRange
1418
(
@@ -50,7 +54,9 @@ public ActorInteractionPluginEditor(ReadOnlyTargetRules Target) : base(Target)
5054

5155
"MainFrame",
5256
"ToolMenus",
53-
"InputCore"
57+
"InputCore",
58+
59+
"UMG"
5460
}
5561
);
5662

0 commit comments

Comments
 (0)