Basic entity scripting

This commit is contained in:
Simon Lübeß
2023-03-29 13:33:34 +02:00
parent 5e5134a607
commit e60d74fccd
23 changed files with 1193 additions and 89 deletions
+59
View File
@@ -0,0 +1,59 @@
using System;
using GlitchyEngine.Math;
namespace GlitchyEngine;
class MyTestEntity : Entity
{
//Rigidbody2D _rigidBody;
/// <summary>
/// Called after the script component was created. (The entity might not be fully created yet)
/// </summary>
void OnCreate()
{
Log.Info($"Create! {UUID}");
//_rigidBody = GetComponent<Rigidbody2D>();
}
///// <summary>
///// Called after the entity was created completely.
///// </summary>
//void OnInstantiate()
//{
// Log.Warning($"Instantiated!");
//}
/// <summary>
/// Called every frame.
/// </summary>
/// <param name="deltaTime"></param>
void OnUpdate(float deltaTime)
{
if (Input.IsKeyPressed(Key.A))
{
Log.Info($"HALLO!");
Vector3 translation = Translation;
translation.Y += 1.0f * deltaTime;
Translation = translation;
//_rigidBody.ApplyImpulse(new Vector2(0, 10));
}
if (Input.IsMouseButtonReleasing(MouseButton.LeftButton))
{
Log.Info("Ouha!");
}
}
/// <summary>
/// Called before the component is being destroyed.
/// </summary>
void OnDestroy()
{
Log.Trace("Destroy");
}
}