Finality Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
TestScript.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <
Finality.h
>
4
#include <iostream>
5
6
namespace
FINALITY
7
{
9
struct
MaterialCompLayout
10
{
11
// without includeing glm::mat4 64 bytes
12
float
Time
;
13
};
14
16
class
TestScript
:
public
FINALITY::ScriptableComponent
17
{
18
public
:
19
TestScript
() =
default
;
20
21
private
:
22
void
Start()
override
23
{
24
FI_CLIENT_INFO
(
"TestScript Started using Push Constants!"
);
25
26
uint32_t baseOffset = 64;
27
28
if
(
HasComponent<MaterialComponent>
())
29
{
30
auto
& materialComp =
GetComponent<MaterialComponent>
();
31
if
(materialComp.MaterialInstance)
32
{
33
materialComp.MaterialInstance->RegisterUniform(
"time"
, baseOffset + offsetof(
MaterialCompLayout
, Time),
sizeof
(
float
));
34
}
35
}
36
}
37
38
void
Update(
float
dt)
override
39
{
40
m_TotalTime += dt;
41
m_HelloTimer += dt;
42
m_RotationAngle += 50.0f * dt;
43
44
if
(
HasComponent<TransformComponent>
())
45
{
46
auto
& transform =
GetComponent<TransformComponent>
();
47
transform.Rotation.x = m_RotationAngle;
48
transform.Rotation.y = m_RotationAngle * 0.5f;
49
}
50
51
if
(
HasComponent<MaterialComponent>
())
52
{
53
auto
& materialComp =
GetComponent<MaterialComponent>
();
54
if
(materialComp.MaterialInstance)
55
{
56
materialComp.MaterialInstance->SetUniform1f(
"time"
, m_TotalTime);
57
}
58
}
59
}
60
61
void
OnDestroy()
override
62
{
63
FI_CLIENT_INFO
(
"Test Script is destroyed"
);
64
}
65
66
private
:
67
float
m_HelloTimer = 0.0f;
68
float
m_FPSTimer = 0.0f;
69
float
m_RotationAngle = 0.0f;
70
float
m_TotalTime = 0.0f;
71
};
72
}
Finality.h
FI_CLIENT_INFO
#define FI_CLIENT_INFO(...)
Definition
Finality.h:55
FINALITY::ScriptableComponent
Definition
ScriptableComponent.h:96
FINALITY::ScriptableComponent::GetComponent
T & GetComponent()
FINALITY::ScriptableComponent::HasComponent
bool HasComponent() const
FINALITY::TestScript::TestScript
TestScript()=default
FINALITY
Definition
Asset.h:12
FINALITY::MaterialCompLayout
Definition
TestScript.h:10
FINALITY::MaterialCompLayout::Time
float Time
Definition
TestScript.h:12
Sandbox
src
scripts
TestScript.h
Generated by
1.18.0