Skip to content

Commit dfa2fc8

Browse files
Merge branch '4.26_dev' into 4.26
2 parents 93a2f0e + 730e602 commit dfa2fc8

File tree

13 files changed

+187
-41
lines changed

13 files changed

+187
-41
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,5 @@ DerivedDataCache/*
7575

7676
# Visual Studio
7777
.vscode/*
78+
.idea/*
79+
Config/UpdateConfig.ini

ActorInteractionPlugin.uplugin

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"FileVersion": 3,
3-
"Version": 1,
4-
"VersionName": "3.0.1.1",
3+
"Version": 3,
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",
88
"CreatedBy": "Dominik Pavlicek",
9-
"CreatedByURL": "https://sites.google.com/view/dominikpavlicek/home",
10-
"DocsURL": "https://sites.google.com/view/dominikpavlicek/home/documentation",
9+
"CreatedByURL": "https://github.com/Mountea-Framework",
10+
"DocsURL": "https://github.com/Mountea-Framework/ActorInteractionPlugin/wiki",
1111
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/product/ca842c00ec0d4db0b3aad17701e1637b",
1212
"SupportURL": "https://bit.ly/DominikPavlicek_SupportServer",
1313
"EngineVersion": "4.26.0",
-196 Bytes
Binary file not shown.

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@ The things you need before running this plugin.
2727
Download the plugin (either from Releases or from Marketplace). For more detailed guide take a look at Wiki page.
2828

2929
1. Download the branch release you are interested in
30-
2. Instal the plugin to your Game Project (within /Plugin folder)
31-
30+
2. Install the plugin to your Game Project (within /Plugin folder)
3231

3332
## Usage
3433

35-
A best way to describe the usage is to take a look or play the demo build.
34+
A best way to describe the usage is to take a look at video showcase or play the demo build.
3635
* Video: https://youtu.be/OCCcxqhCBkY
37-
* Build: https://drive.google.com/drive/u/1/folders/1AhKcrNtkHOD7D8MU5CzvJpjbR9l_Vi1p
36+
* Build: https://drive.google.com/file/d/1u7Ur9K5ipMTa3VuXbaYGWZ_OJSn_-fPw/
3837

3938
### Branches
4039

Source/ActorInteractionPlugin/ActorInteractionPlugin.Build.cs

Lines changed: 1 addition & 0 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[] {

Source/ActorInteractionPlugin/Private/Components/ActorInteractableComponentBase.cpp

Lines changed: 85 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,6 @@ UActorInteractableComponentBase::UActorInteractableComponentBase()
6666

6767
CachedInteractionWeight = InteractionWeight;
6868

69-
// Setup default Data Table
70-
if (InteractableData.IsNull())
71-
{
72-
const auto DefaultTable = UActorInteractionFunctionLibrary::GetInteractableDefaultDataTable();
73-
if (DefaultTable != nullptr)
74-
{
75-
InteractableData.DataTable = DefaultTable;
76-
}
77-
}
78-
79-
// Setup default Widget Class
80-
if (GetWidgetClass() == nullptr)
81-
{
82-
const auto DefaultWidgetClass = UActorInteractionFunctionLibrary::GetInteractableDefaultWidgetClass();
83-
if (DefaultWidgetClass != nullptr)
84-
{
85-
SetWidgetClass(DefaultWidgetClass.Get());
86-
}
87-
}
88-
8969
#if WITH_EDITORONLY_DATA
9070
bVisualizeComponent = true;
9171
#endif
@@ -188,7 +168,7 @@ void UActorInteractableComponentBase::OnRegister()
188168
SpriteComponent->RegisterComponent();
189169
}
190170
#endif
191-
171+
192172
Super::OnRegister();
193173
}
194174

@@ -476,7 +456,12 @@ void UActorInteractableComponentBase::SetState(const EInteractableStateV2 NewSta
476456
case EInteractableStateV2::EIS_Disabled:
477457
{
478458
InteractableState = NewState;
479-
CleanupComponent();
459+
460+
// Replacing Cleanup
461+
StopHighlight();
462+
OnInteractableStateChanged.Broadcast(InteractableState);
463+
if (GetWorld()) GetWorld()->GetTimerManager().ClearAllTimersForObject(this);
464+
OnInteractorLost.Broadcast(Interactor);
480465

481466
for (const auto Itr : CollisionComponents)
482467
{
@@ -503,7 +488,12 @@ void UActorInteractableComponentBase::SetState(const EInteractableStateV2 NewSta
503488
case EInteractableStateV2::EIS_Disabled:
504489
{
505490
InteractableState = NewState;
506-
CleanupComponent();
491+
492+
// Replacing Cleanup
493+
StopHighlight();
494+
OnInteractableStateChanged.Broadcast(InteractableState);
495+
if (GetWorld()) GetWorld()->GetTimerManager().ClearAllTimersForObject(this);
496+
OnInteractorLost.Broadcast(Interactor);
507497

508498
for (const auto Itr : CollisionComponents)
509499
{
@@ -548,7 +538,12 @@ void UActorInteractableComponentBase::SetState(const EInteractableStateV2 NewSta
548538
case EInteractableStateV2::EIS_Asleep:
549539
{
550540
InteractableState = NewState;
551-
CleanupComponent();
541+
542+
// Replacing Cleanup
543+
StopHighlight();
544+
OnInteractableStateChanged.Broadcast(InteractableState);
545+
if (GetWorld()) GetWorld()->GetTimerManager().ClearAllTimersForObject(this);
546+
OnInteractorLost.Broadcast(Interactor);
552547

553548
for (const auto Itr : CollisionComponents)
554549
{
@@ -1134,6 +1129,22 @@ ETimingComparison UActorInteractableComponentBase::GetComparisonMethod() const
11341129
void UActorInteractableComponentBase::SetComparisonMethod(const ETimingComparison Value)
11351130
{ ComparisonMethod = Value; }
11361131

1132+
void UActorInteractableComponentBase::SetDefaults()
1133+
{
1134+
if (const auto DefaultTable = UActorInteractionFunctionLibrary::GetInteractableDefaultDataTable())
1135+
{
1136+
InteractableData.DataTable = DefaultTable;
1137+
}
1138+
1139+
if (const auto DefaultWidgetClass = UActorInteractionFunctionLibrary::GetInteractableDefaultWidgetClass())
1140+
{
1141+
if (DefaultWidgetClass != nullptr)
1142+
{
1143+
SetWidgetClass(DefaultWidgetClass.Get());
1144+
}
1145+
}
1146+
}
1147+
11371148
void UActorInteractableComponentBase::InteractorFound(const TScriptInterface<IActorInteractorInterface>& FoundInteractor)
11381149
{
11391150
if (CanBeTriggered())
@@ -2001,6 +2012,56 @@ EDataValidationResult UActorInteractableComponentBase::IsDataValid(TArray<FText>
20012012

20022013
return bAnyError ? EDataValidationResult::Invalid : DefaultValue;
20032014
}
2015+
2016+
bool UActorInteractableComponentBase::Modify(bool bAlwaysMarkDirty)
2017+
{
2018+
const bool bResult = Super::Modify(bAlwaysMarkDirty);
2019+
2020+
const bool bShouldNotify =
2021+
{
2022+
GetOwner() != nullptr &&
2023+
UActorInteractionFunctionLibrary::IsEditorDebugEnabled() &&
2024+
(
2025+
InteractableData.DataTable == nullptr ||
2026+
GetWidgetClass() == nullptr
2027+
)
2028+
};
2029+
2030+
if (bShouldNotify)
2031+
{
2032+
FString interactableName = GetName();
2033+
// Format Name
2034+
{
2035+
if (interactableName.Contains(TEXT("_GEN_VARIABLE")))
2036+
{
2037+
interactableName.ReplaceInline(TEXT("_GEN_VARIABLE"), TEXT(""));
2038+
}
2039+
if (interactableName.Contains(TEXT("SKEL_")))
2040+
{
2041+
interactableName.ReplaceInline(TEXT("SKEL_"), TEXT(""));
2042+
}
2043+
if(interactableName.EndsWith(TEXT("_C")) && interactableName.StartsWith(TEXT("Default__")))
2044+
{
2045+
2046+
interactableName.RightChopInline(9);
2047+
interactableName.LeftChopInline(2);
2048+
}
2049+
}
2050+
2051+
FString ownerName;
2052+
GetOwner()->GetName(ownerName);
2053+
2054+
const FText ErrorMessage = FText::FromString
2055+
(
2056+
interactableName.Append(" from ").Append(ownerName).Append(TEXT(": Interactable Data or Widget Class are not valid! Use 'SetDefaults' to avoid issues!"))
2057+
);
2058+
FEditorHelper::DisplayEditorNotification(ErrorMessage, SNotificationItem::CS_Fail, 5.f, 2.f, TEXT("Icons.Info"));
2059+
2060+
}
2061+
2062+
return bResult;
2063+
}
2064+
20042065
#endif
20052066

20062067
void UActorInteractableComponentBase::DrawDebug()

Source/ActorInteractionPlugin/Public/Components/ActorInteractableComponentBase.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,14 @@ class ACTORINTERACTIONPLUGIN_API UActorInteractableComponentBase : public UWidge
557557
UFUNCTION(BlueprintCallable, Category="Interaction")
558558
virtual void SetComparisonMethod(const ETimingComparison Value) override;
559559

560+
/**
561+
* Finds default values from Developer settings and tries to set them for this component.
562+
* Will override current settings!
563+
* Will set those values only if not null.
564+
*/
565+
UFUNCTION(BlueprintCallable, CallInEditor, Category="Interaction", meta=(DisplayName="SetDefaults"))
566+
virtual void SetDefaults() override;
567+
560568
#pragma endregion
561569

562570
#pragma region EventFunctions
@@ -1336,7 +1344,7 @@ class ACTORINTERACTIONPLUGIN_API UActorInteractableComponentBase : public UWidge
13361344
/**
13371345
* List of Interactable Classes which are ignored
13381346
*/
1339-
UPROPERTY(SaveGame, EditAnywhere, Category="Interaction|Optional", meta=(NoResetToDefault, AllowAbstract=false, MustImplement="ActorInteractorInterface", BlueprintBaseOnly))
1347+
UPROPERTY(SaveGame, EditAnywhere, Category="Interaction|Optional", meta=(NoResetToDefault, AllowAbstract=false, MustImplement="/Script/ActorInteractionPlugin.ActorInteractorInterface", BlueprintBaseOnly))
13401348
TArray<TSoftClassPtr<UObject>> IgnoredClasses;
13411349

13421350
/**
@@ -1516,6 +1524,8 @@ class ACTORINTERACTIONPLUGIN_API UActorInteractableComponentBase : public UWidge
15161524
virtual void PostEditChangeChainProperty(FPropertyChangedChainEvent& PropertyChangedEvent) override;
15171525
virtual EDataValidationResult IsDataValid(TArray<FText>& ValidationErrors) override;
15181526

1527+
virtual bool Modify(bool bAlwaysMarkDirty) override;
1528+
15191529
#endif
15201530

15211531
virtual void DrawDebug();

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 & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,47 @@ class ACTORINTERACTIONPLUGIN_API UActorInteractionPluginSettings : public UDevel
2121
UActorInteractionPluginSettings()
2222
{
2323
CategoryName = TEXT("Mountea Framework");
24-
SectionName = TEXT("Interaction");
24+
SectionName = TEXT("Actor Interaction Plugin");
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

Source/ActorInteractionPlugin/Public/Interfaces/ActorInteractableInterface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ class ACTORINTERACTIONPLUGIN_API IActorInteractableInterface
337337

338338
virtual void InteractableDependencyStartedCallback(const TScriptInterface<IActorInteractableInterface>& NewMaster) = 0;
339339
virtual void InteractableDependencyStoppedCallback(const TScriptInterface<IActorInteractableInterface>& FormerMaster) = 0;
340+
341+
virtual void SetDefaults() = 0;
340342

341343
virtual FOnInteractableSelected& GetOnInteractableSelectedHandle() = 0;
342344
virtual FInteractorFound& GetOnInteractorFoundHandle() = 0;

0 commit comments

Comments
 (0)