Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
ComponentParameter Struct Reference

#include <ComponentDefinition.h>

+ Collaboration diagram for ComponentParameter:

Public Types

enum class  Type : uint8_t {
  Unknown = 0 , Bool , Int , Float ,
  String , Vector2 , Vector3 , Color ,
  Array , EntityRef
}
 

Public Member Functions

bool AsBool () const
 
int AsInt () const
 
float AsFloat () const
 
std::string AsString () const
 
Vector AsVector () const
 
SDL_Color AsColor () const
 
EntityID AsEntityRef () const
 
const nlohmann::jsonAsArray () const
 

Static Public Member Functions

static ComponentParameter FromBool (bool value)
 
static ComponentParameter FromInt (int value)
 
static ComponentParameter FromFloat (float value)
 
static ComponentParameter FromString (const std::string &value)
 
static ComponentParameter FromVector2 (float x, float y)
 
static ComponentParameter FromVector3 (float x, float y, float z)
 
static ComponentParameter FromColor (uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
 
static ComponentParameter FromEntityRef (EntityID entityId)
 
static ComponentParameter FromArray (const nlohmann::json &arrayData)
 

Public Attributes

Type type = Type::Unknown
 
bool boolValue = false
 
int intValue = 0
 
float floatValue = 0.0f
 
std::string stringValue
 
Vector vectorValue
 
SDL_Color colorValue = { 255, 255, 255, 255 }
 
EntityID entityRefValue = INVALID_ENTITY_ID
 
std::shared_ptr< nlohmann::jsonarrayValue
 

Detailed Description

Definition at line 26 of file ComponentDefinition.h.

Member Enumeration Documentation

◆ Type

Enumerator
Unknown 
Bool 
Int 
Float 
String 
Vector2 
Vector3 
Color 
Array 
EntityRef 

Definition at line 28 of file ComponentDefinition.h.

Member Function Documentation

◆ AsArray()

const nlohmann::json & ComponentParameter::AsArray ( ) const

Definition at line 378 of file ComponentDefinition.cpp.

References Array, arrayValue, GetComponentTypeID_Static(), and type.

+ Here is the call graph for this function:

◆ AsBool()

bool ComponentParameter::AsBool ( ) const

Definition at line 126 of file ComponentDefinition.cpp.

References Bool, boolValue, EntityRef, entityRefValue, Float, floatValue, GetComponentTypeID_Static(), Int, intValue, INVALID_ENTITY_ID, String, stringValue, and type.

+ Here is the call graph for this function:

◆ AsColor()

SDL_Color ComponentParameter::AsColor ( ) const

Definition at line 283 of file ComponentDefinition.cpp.

References ClampColorValue(), Color, colorValue, GetComponentTypeID_Static(), String, stringValue, SYSTEM_LOG, and type.

+ Here is the call graph for this function:

◆ AsEntityRef()

EntityID ComponentParameter::AsEntityRef ( ) const

◆ AsFloat()

float ComponentParameter::AsFloat ( ) const

Definition at line 174 of file ComponentDefinition.cpp.

References Bool, boolValue, Float, floatValue, Int, intValue, String, stringValue, and type.

◆ AsInt()

int ComponentParameter::AsInt ( ) const

◆ AsString()

std::string ComponentParameter::AsString ( ) const

◆ AsVector()

Vector ComponentParameter::AsVector ( ) const

Definition at line 240 of file ComponentDefinition.cpp.

References GetComponentTypeID_Static(), String, stringValue, type, Vector2, Vector3, and vectorValue.

+ Here is the call graph for this function:

◆ FromArray()

ComponentParameter ComponentParameter::FromArray ( const nlohmann::json arrayData)
static

Definition at line 113 of file ComponentDefinition.cpp.

References Array, GetComponentTypeID_Static(), and type.

Referenced by anonymous_namespace{World.cpp}::JsonValueToComponentParameter(), and ParseParameterWithSchema().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FromBool()

ComponentParameter ComponentParameter::FromBool ( bool  value)
static

◆ FromColor()

ComponentParameter ComponentParameter::FromColor ( uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  a = 255 
)
static

Definition at line 97 of file ComponentDefinition.cpp.

References Color, GetComponentTypeID_Static(), and type.

Referenced by ParameterResolver::ConvertLevelProperty(), ParameterSchemaRegistry::InitializeBuiltInSchemas(), ParameterSchemaRegistry::ParseDefaultValue(), and ParseParameterWithSchema().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FromEntityRef()

ComponentParameter ComponentParameter::FromEntityRef ( EntityID  entityId)
static

Definition at line 105 of file ComponentDefinition.cpp.

References EntityRef, GetComponentTypeID_Static(), and type.

Referenced by ParameterResolver::ConvertLevelProperty(), and ParseParameterWithSchema().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FromFloat()

ComponentParameter ComponentParameter::FromFloat ( float  value)
static

◆ FromInt()

ComponentParameter ComponentParameter::FromInt ( int  value)
static

◆ FromString()

ComponentParameter ComponentParameter::FromString ( const std::string &  value)
static

◆ FromVector2()

ComponentParameter ComponentParameter::FromVector2 ( float  x,
float  y 
)
static

Definition at line 81 of file ComponentDefinition.cpp.

References GetComponentTypeID_Static(), type, and Vector2.

Referenced by ParameterSchemaRegistry::InitializeBuiltInSchemas(), and ParseParameterWithSchema().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FromVector3()

ComponentParameter ComponentParameter::FromVector3 ( float  x,
float  y,
float  z 
)
static

Member Data Documentation

◆ arrayValue

std::shared_ptr<nlohmann::json> ComponentParameter::arrayValue

Definition at line 55 of file ComponentDefinition.h.

Referenced by AsArray(), and AsString().

◆ boolValue

bool ComponentParameter::boolValue = false

Definition at line 45 of file ComponentDefinition.h.

Referenced by AsBool(), AsFloat(), AsInt(), and AsString().

◆ colorValue

SDL_Color ComponentParameter::colorValue = { 255, 255, 255, 255 }

Definition at line 50 of file ComponentDefinition.h.

Referenced by AsColor(), and AsString().

◆ entityRefValue

EntityID ComponentParameter::entityRefValue = INVALID_ENTITY_ID

Definition at line 51 of file ComponentDefinition.h.

Referenced by AsBool(), AsEntityRef(), AsInt(), and AsString().

◆ floatValue

float ComponentParameter::floatValue = 0.0f

Definition at line 47 of file ComponentDefinition.h.

Referenced by AsBool(), AsFloat(), AsInt(), and AsString().

◆ intValue

int ComponentParameter::intValue = 0

Definition at line 46 of file ComponentDefinition.h.

Referenced by AsBool(), AsEntityRef(), AsFloat(), AsInt(), and AsString().

◆ stringValue

std::string ComponentParameter::stringValue

Definition at line 48 of file ComponentDefinition.h.

Referenced by AsBool(), AsColor(), AsEntityRef(), AsFloat(), AsInt(), AsString(), and AsVector().

◆ type

Type ComponentParameter::type = Type::Unknown

◆ vectorValue

Vector ComponentParameter::vectorValue

Definition at line 49 of file ComponentDefinition.h.

Referenced by AsString(), and AsVector().


The documentation for this struct was generated from the following files: