Added nuake wren modules path detection, removed project stuff

This commit is contained in:
Antoine Pilote
2021-07-03 16:00:13 -04:00
parent 2fff0594b0
commit f5bcb12f61
23 changed files with 37 additions and 533 deletions

View File

@@ -1,90 +0,0 @@
import "Scripts/ScriptableEntity" for ScriptableEntity
import "Scripts/Engine" for Engine
import "Scripts/Scene" for Scene
import "Scripts/Math" for Vector3, Math
import "Scripts/Input" for Input
class CamScript is ScriptableEntity {
construct new() {
_Pitch = 0
_Yaw = 0
_mouseLastX = 0
_mouseLastY = 0
_BobHeight = 0.1
_BobSpeed = 5.0
_CamHeight = 0.5
_deltaTime = 0
Input.HideMouse()
}
init() {}
update(ts) {
_deltaTime = _deltaTime + ts
var x = Input.GetMouseX()
var my = Input.GetMouseY()
var diffx = x - _mouseLastX
var diffy = _mouseLastY - my
_mouseLastX = x
_mouseLastY = my
var sens = 0.1
diffx = diffx * sens
diffy = diffy * sens
_Yaw = _Yaw + diffx
_Pitch = _Pitch + diffy
if(_Pitch > 89) _Pitch = 89
if(_Pitch < -89) _Pitch = -89
var cam = this.GetComponent("Camera")
var rad_yaw = Math.Radians(_Yaw)
var rad_pitch = Math.Radians(_Pitch)
var camX = Math.Cos(rad_yaw) * Math.Cos(rad_pitch)
var camY = Math.Sin(rad_pitch)
var camZ = Math.Sin(rad_yaw) * Math.Cos(rad_pitch)
var newDir = Vector3.new(camX, camY, camZ)
var player = Scene.GetEntity("Player")
var camTransform = this.GetComponent("Transform")
var camPoss = camTransform.GetTranslation()
var camYz = camPoss.y
var playerScript = player.GetComponent("Script")
var velocity = playerScript.Velocity.Duplicate()
velocity.y = 0 // Dont count gravity in bob.
velocity = velocity.Sqrt()
var amount = (Math.Sin(_deltaTime * (velocity * 0.01)) / 2 + 1) * _BobHeight
//Engine.Log("BobAmount: %(amount)")
var pTransform = player.GetComponent("Transform")
var pPos = pTransform.GetTranslation()
if(amount < 1 && amount > -1) amount = 0
var newY = camYz + 0.08 * ((pPos.y + _CamHeight) - camYz)
var transform = this.GetComponent("Transform")
var newPos = Vector3.new(pPos.x, newY, pPos.z)
transform.SetTranslation(newPos)
cam.SetDirection(newDir)
}
fixedUpdate(ts) {
}
exit() {}
}

View File

@@ -1,4 +1,4 @@
import "Scripts/Math" for Vector3
import "Nuake:Math" for Vector3
class Engine {
foreign static Log(msg)

View File

@@ -1,5 +1,5 @@
import "Scripts/Math" for Vector3
import "Scripts/Engine" for Engine
import "Nuake:Math" for Vector3
import "Nuake:Engine" for Engine
class Input {
foreign static GetMouseX()
foreign static GetMouseY()

View File

@@ -1,4 +1,4 @@
import "Scripts/Math" for Vector3
import "Nuake:Math" for Vector3
class CollisionResult {

View File

@@ -1,106 +0,0 @@
import "Scripts/ScriptableEntity" for ScriptableEntity
import "Scripts/Engine" for Engine
import "Scripts/Scene" for Scene
import "Scripts/Math" for Vector3
import "Scripts/Input" for Input
import "Scripts/Physics" for Physics, CollisionResult
class PlayerScript is ScriptableEntity {
Velocity {_Velocity}
construct new() {
_InputDir = Vector3.new(0, 0, 0)
_Velocity = Vector3.new(0, 0, 0)
_Accel = 150
_Deccel = 0.85
_AirDeccel = 0.7
_Gravity = 20
_MaxSpeed = 20
_Jump = 400
//Input.HideMouse()
}
init() {
Engine.Log("Player init")
}
update(ts) {
}
fixedUpdate(ts) {
this.CheckInput()
var camEntity = Scene.GetEntity("Camera")
var cam = camEntity.GetComponent("Camera")
var dir = cam.GetDirection()
dir.y = 0
dir = dir.Normalize()
var right = cam.GetRight()
right.y = 0
right = right.Normalize()
var move = _InputDir
var new_Velocity = (dir * move.z) + (right * move.x)
var controller = this.GetComponent("CharacterController")
var transform = this.GetComponent("Transform")
var from = transform.GetTranslation()
var to = from - Vector3.new(0, 1, 0)
var normal = Physics.Raycast(from, to).Normal
if(!controller.IsOnGround()) {
_Velocity.y = _Velocity.y -_Gravity
//_Velocity.x = _Velocity.x * _AirDeccel
//_Velocity.z = _Velocity.z * _AirDeccel
} else {
_Velocity.y = -10
if(Input.IsKeyPressed(32)) _Velocity.y = _Jump
_Velocity.x = _Velocity.x + new_Velocity.x * _Accel
_Velocity.z = _Velocity.z + new_Velocity.z * _Accel
_Velocity.x = _Velocity.x * _Deccel
_Velocity.z = _Velocity.z * _Deccel
}
controller.MoveAndSlide(_Velocity * ts)
}
CheckInput() {
/*
87 = W
65 = A
83 = S
68 = D
32 = SPACE
*/
if(Input.IsKeyDown(87)) {
_InputDir.z = 1
} else if(Input.IsKeyDown(83)) {
_InputDir.z = -1
} else {
_InputDir.z = 0
}
if(Input.IsKeyDown(65)) {
_InputDir.x = 1
} else if(Input.IsKeyDown(68)) {
_InputDir.x = -1
} else {
_InputDir.x = 0
}
}
exit() {
Engine.Log("Player exit")
}
}

View File

@@ -1,5 +1,5 @@
import "Scripts/Engine" for Engine
import "Scripts/Math" for Vector3
import "Nuake:Engine" for Engine
import "Nuake:Math" for Vector3
class Scene {
foreign static GetEntityID(name)

View File

@@ -1,4 +1,4 @@
import "Scripts/Scene" for Scene
import "Nuake:Scene" for Scene
class ScriptableEntity {
SetEntityId(id) {

View File

@@ -1,46 +0,0 @@
import "Scripts/ScriptableEntity" for ScriptableEntity
import "Scripts/Engine" for Engine
import "Scripts/Scene" for Scene, Trigger
import "Scripts/Math" for Vector3
import "Scripts/Input" for Input
import "Scripts/Physics" for Physics, CollisionResult
class TriggerScript is ScriptableEntity {
construct new() {
_Activated = false
}
init() {
}
update(ts) {
}
fixedUpdate(ts) {
var trigger = this.GetComponent("Trigger")
if(trigger.GetOverlappingBodyCount() > 0) {
var bodies = trigger.GetOverlappingBodies()
var brush = this.GetComponent("Brush")
var isPlayer = bodies[0].HasComponent("CharacterController")
if(isPlayer) {
_Activated = true
}
}
if(_Activated) {
var brush = this.GetComponent("Brush")
for(t in brush.GetTargets()) {
var transform = t.GetComponent("Transform")
var pos = transform.GetTranslation()
pos.x = pos.x + 1.0 * ts
transform.SetTranslation(pos)
}
}
}
exit() {
}
}

View File

@@ -1,27 +0,0 @@
import "Scripts/Engine" for Engine
import "Scripts/ScriptableEntity" for ScriptableEntity
class TestScript is ScriptableEntity {
construct new() {
_deltaTime = 0
}
init() {
Engine.Log("Hello init")
}
update(ts) {
_deltaTime = _deltaTime + ts
}
fixedUpdate(ts) {
}
exit() {
Engine.Log("Hello exit")
}
}

View File

@@ -1,23 +0,0 @@
import "Scripts/Engine" for Engine
import "Scripts/Scene" for Scene, Entity
class Test {
construct new() {}
init() {
System.print("hello init")
}
// Gets called on the click event.
static hello() {
// Get the entity named Light
var entity = Scene.GetEntity("Light")
// Get the component light
var light = entity.GetComponent("Light")
//light.SetIntensity(222.0) // Change intensity
var currentIntensity = light.GetIntensity() // Get new intensity
Engine.Log("Current intensity %(currentIntensity)")
}
}