7#include "Internationalization/Regex.h"
8#include "ArticyObject.h"
9#include "ArticyDatabase.h"
11#include "ArticyExpressoScripts.generated.h"
40 Undefined, Bool, Int, Float, String
48 virtual bool& GetBool();
55 virtual const bool& GetBool()
const;
62 virtual int64& GetInt();
69 virtual const int64& GetInt()
const;
76 virtual double& GetFloat();
83 virtual const double& GetFloat()
const;
90 virtual FString& GetString();
97 virtual const FString& GetString()
const;
104 virtual FString ToString()
const;
277 explicit operator bool()
const;
286 explicit operator int64()
const;
295 explicit operator int8()
const;
304 explicit operator uint8()
const;
313 explicit operator int16()
const;
322 explicit operator uint16()
const;
331 explicit operator int32()
const;
340 explicit operator uint32()
const;
349 explicit operator uint64()
const;
358 explicit operator double()
const;
367 explicit operator float()
const;
376 explicit operator FString()
const;
385 explicit operator FText()
const;
394 explicit operator FName()
const;
661 if (Object && Property)
663 T* ptr = Property->ContainerPtrToValuePtr<T>(Object);
673 if (!Object || !Property)
676 T* ptr = Property->ContainerPtrToValuePtr<T>(Object);
693FORCEINLINE
int operator+(
const int& Lhs,
const ExpressoType& Rhs)
695 return Lhs + (int)Rhs;
707FORCEINLINE
int operator-(
const int& Lhs,
const ExpressoType& Rhs)
709 return Lhs - (int)Rhs;
721FORCEINLINE
int operator*(
const int& Lhs,
const ExpressoType& Rhs)
723 return Lhs * (int)Rhs;
735FORCEINLINE
int operator/(
const int& Lhs,
const ExpressoType& Rhs)
737 return Lhs / (int)Rhs;
749FORCEINLINE
int operator%(
const int& Lhs,
const ExpressoType& Rhs)
751 return Lhs % (int)Rhs;
763FORCEINLINE
float operator+(
const float& Lhs,
const ExpressoType& Rhs)
765 return Lhs + (float)Rhs;
777FORCEINLINE
float operator-(
const float& Lhs,
const ExpressoType& Rhs)
779 return Lhs - (float)Rhs;
791FORCEINLINE
float operator*(
const float& Lhs,
const ExpressoType& Rhs)
793 return Lhs * (float)Rhs;
805FORCEINLINE
float operator/(
const float& Lhs,
const ExpressoType& Rhs)
807 return Lhs / (float)Rhs;
830 Conditions.Add(GetTypeHash(FString{
"" }), [&] {
return true; });
831 Instructions.Add(GetTypeHash(FString{
"" }), [&] {
return; });
891 bool Evaluate(
const int& ConditionFragmentHash,
UArticyGlobalVariables* GV, UObject* MethodProvider)
const;
904 bool Execute(
const int& InstructionFragmentHash,
UArticyGlobalVariables* GV, UObject* MethodProvider)
const;
914 void SetDefaultUserMethodsProvider(UObject* MethodProvider);
923 UObject* GetDefaultUserMethodsProvider()
const;
932 UObject* GetUserMethodsProviderObject()
const;
1049 int random(
int Min,
int Max);
1070 float random(
float Min,
float Max);
1157 static bool isInRange(
float valueToTest,
float lowerBound,
float upperBound);
1195 static bool isInRange(
const FString& valueToTest,
const FString& lowerBound,
const FString& upperBound);
1221 bool isPropInRange(
const ExpressoType& Id_CloneId,
const FString& Property,
const FString& lowerBound,
const FString& upperBound)
const;
1280 int setSeenCounter(
const FString& NameOrId,
const int Value = 1);
1300 bool fallback(
const FString& NameOrId);
1320 template<
typename ...ArgTypes>
1321 static void print(
const FString& Msg, ArgTypes... Args);
1332 template<
typename ...ArgTypes>
1408 static void PrintInternal(
const FString& msg);
1420template <
typename ... ArgTypes>
1425 auto arr = TArray<ExpressoType>{ Args... };
1426 for (
int i = 0; i < arr.Num(); ++i)
1427 msg = msg.Replace(*FString::Printf(TEXT(
"{%d}"), i), *FString{ arr[i] });
Definition ArticyBaseObject.h:25
Definition ArticyGlobalVariables.h:320
Definition ArticyDatabase.h:172
The UArticyExpressoScripts class manages script conditions and instructions.
Definition ArticyExpressoScripts.h:819
static ExpressoType getProp(UArticyBaseObject *Object, const FString &Property)
Retrieves the value of a property on an Articy object.
Definition ArticyExpressoScripts.cpp:1262
bool fallback(UArticyBaseObject *Object)
Performs a fallback operation for an Articy object.
Definition ArticyExpressoScripts.cpp:1660
static void setProp(UArticyBaseObject *Object, const FString &Property, const ExpressoType &Value)
Sets the value of a property on an Articy object.
Definition ArticyExpressoScripts.cpp:1233
virtual UArticyGlobalVariables * GetGV()
Retrieves the active global variables instance.
Definition ArticyExpressoScripts.h:942
UArticyObject * getObj(const FString &NameOrId, const uint32 &CloneId=0) const
Retrieves an Articy object by name or ID.
Definition ArticyExpressoScripts.cpp:1137
static void print(const FString &Msg, ArgTypes... Args)
Prints a formatted message to the log.
Definition ArticyExpressoScripts.h:1421
int setSeenCounter(const int Value=1)
Sets the seen counter for the current object.
Definition ArticyExpressoScripts.cpp:1595
UObject * UserMethodsProvider
Cache of the current methods provider set during evaluation.
Definition ArticyExpressoScripts.h:1372
UArticyPrimitive * self
The current object for script evaluation.
Definition ArticyExpressoScripts.h:962
static void incrementProp(UArticyBaseObject *Object, const FString &Property, const float Value=1)
Increments the value of a property on an Articy object.
Definition ArticyExpressoScripts.cpp:1397
UArticyObject * speaker
The speaker for dialog fragments.
Definition ArticyExpressoScripts.h:969
static const bool & ConditionOrTrue(const bool &Condition)
Script conditions that are not empty return the condition value.
Definition ArticyExpressoScripts.h:1346
int random(int Min, int Max)
Generates a random integer between Min and Max.
Definition ArticyExpressoScripts.cpp:1290
static void print(const ExpressoType &Msg, ArgTypes... Args)
Prints a formatted message to the log.
Definition ArticyExpressoScripts.h:1333
UArticyExpressoScripts()
Default constructor for UArticyExpressoScripts.
Definition ArticyExpressoScripts.h:827
TWeakObjectPtr< UObject > DefaultUserMethodsProvider
Default methods provider for script evaluation.
Definition ArticyExpressoScripts.h:1380
void SetSpeaker(UArticyObject *Speaker)
Sets the speaker for dialog fragments.
Definition ArticyExpressoScripts.h:878
virtual void Init(UArticyDatabase *DB)
Initializes the expresso scripts with the specified database.
Definition ArticyExpressoScripts.h:850
static bool isInRange(float valueToTest, float lowerBound, float upperBound)
Checks if a value is within a range.
Definition ArticyExpressoScripts.cpp:1460
TMap< uint32, TFunction< void()> > Instructions
Map of instruction fragments.
Definition ArticyExpressoScripts.h:983
TMap< uint32, TFunction< bool()> > Conditions
Map of condition fragments.
Definition ArticyExpressoScripts.h:976
virtual void SetGV(UArticyGlobalVariables *GV) const
Sets the global variables instance for script execution.
Definition ArticyExpressoScripts.h:953
static bool isPropInRange(UArticyBaseObject *Object, const FString &Property, float lowerBound, float upperBound)
Checks if a property value is within a range.
Definition ArticyExpressoScripts.cpp:1476
int getSeenCounter(UArticyBaseObject *Object=nullptr)
Retrieves the seen counter for an Articy object.
Definition ArticyExpressoScripts.cpp:1571
static void decrementProp(UArticyBaseObject *Object, const FString &Property, const float Value=1)
Decrements the value of a property on an Articy object.
Definition ArticyExpressoScripts.cpp:1428
void SetCurrentObject(UArticyPrimitive *Object)
Sets the current object for script evaluation.
Definition ArticyExpressoScripts.h:869
void resetAllSeenCounters()
Resets all seen counters in the global variables.
Definition ArticyExpressoScripts.cpp:1554
UArticyDatabase * GetDb() const
Retrieves the Articy database.
Definition ArticyExpressoScripts.h:859
static bool ConditionOrTrue(void)
Script conditions that are empty or only contain a comment always return true.
Definition ArticyExpressoScripts.h:1365
virtual UClass * GetUserMethodsProviderInterface()
Retrieves the user methods provider interface.
Definition ArticyExpressoScripts.h:841
static const bool ConditionOrTrue(const int &Condition)
Script conditions that should evaluate to bool, but conditions evaluates to int.
Definition ArticyExpressoScripts.h:1356
Definition ArticyGlobalVariables.h:479
Definition ArticyGlobalVariables.h:168
Definition ArticyObject.h:19
Definition ArticyPrimitive.h:17
Definition ArticyGlobalVariables.h:359
The Definition struct represents a type definition for ExpressoType.
Definition ArticyExpressoScripts.h:634
TFunction< void(UArticyBaseObject *, FProperty *, const ExpressoType &)> Setter
Setter function to set a property from an ExpressoType value.
Definition ArticyExpressoScripts.h:643
TFunction< ExpressoType(UArticyBaseObject *, FProperty *)> Factory
Factory function to create an ExpressoType from a property.
Definition ArticyExpressoScripts.h:638
The ExpressoType struct represents a flexible data type used in the Articy runtime.
Definition ArticyExpressoScripts.h:26
static TMap< FName, Definition > Definitions
Map of type definitions for ExpressoType.
Definition ArticyExpressoScripts.h:580
EType
Enumeration for the type of the ExpressoType.
Definition ArticyExpressoScripts.h:39
int64 IntValue
Integer value of the ExpressoType.
Definition ArticyExpressoScripts.h:30
ExpressoType()
Default constructor for ExpressoType.
Definition ArticyExpressoScripts.cpp:12
static void AddDefinition(const FName &CppType)
Adds a type definition for ExpressoType.
Definition ArticyExpressoScripts.h:655
static UArticyBaseObject * TryFeatureReroute(UArticyBaseObject *Object, FString &Property)
Attempts to reroute a property to a feature object.
Definition ArticyExpressoScripts.cpp:802
virtual FString ToString() const
Converts the ExpressoType instance to a string representation.
Definition ArticyExpressoScripts.cpp:254
FString StringValue
String value of the ExpressoType.
Definition ArticyExpressoScripts.h:33
bool BoolValue
Boolean value of the ExpressoType.
Definition ArticyExpressoScripts.h:29
double FloatValue
Float value of the ExpressoType.
Definition ArticyExpressoScripts.h:31
const Definition & GetDefinition(const FName &CppType) const
Retrieves the definition of the specified C++ type.
Definition ArticyExpressoScripts.cpp:722
void SetValue(UArticyBaseObject *Object, FString Property) const
Sets the value of a property on an object.
Definition ArticyExpressoScripts.cpp:769
Definition ArticyBaseTypes.h:18