Fixed Button texture swapping. Fixed Button scripts on scene change. Added buttons to scenes. Added SHEDITOR define for Managed #341

Merged
maverickdgg merged 17 commits from SP3-20-UI-System into main 2023-02-04 00:32:29 +08:00
56 changed files with 2943 additions and 333 deletions
Showing only changes of commit 7ded7a0706 - Show all commits

View File

@ -1,16 +1,16 @@
0 1 3
1 2 65535
2 3 65534
3 4 65534
4 5 65534
5 6 65534
6 7 65534
7 8 65534
8 9 65534
9 10 65534
10 11 65534
11 12 65534
12 13 65534
13 14 65534
14 15 65534
15 16 65534
0 1 0000000000000000
1 2 0000000000000000
2 3 0000000000000000
3 4 0000000000000000
4 5 0000000000000000
5 6 0000000000000000
6 7 0000000000000000
7 8 0000000000000000
8 9 0000000000000000
9 10 0000000000000000
10 11 0000000000000000
11 12 0000000000000000
12 13 0000000000000000
13 14 0000000000000000
14 15 0000000000000000
15 16 0000000000000000

View File

@ -1,4 +1,4 @@
Start Maximized: true
Working Scene ID: 97158628
Working Scene ID: 91685359
Window Size: {x: 1920, y: 1013}
Style: 0

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@
- EID: 1
Name: Canvas
IsActive: true
NumberOfChildren: 1
NumberOfChildren: 3
Components:
Canvas Component:
Canvas Width: 1920
@ -23,7 +23,7 @@
IsActive: true
Scripts: ~
- EID: 2
Name: Default
Name: Back Ground
IsActive: true
NumberOfChildren: 0
Components:
@ -37,6 +37,51 @@
Material: 123313564
IsActive: true
Scripts: ~
- EID: 5
Name: Main Menu Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 75, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 65788519
Hovered Texture: 55999018
Clicked Texture: 66382894
IsActive: true
Scripts:
- Type: ChangeSceneButton
Enabled: true
sceneID: 97158628
- EID: 6
Name: Quit Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: -200, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 66477839
Hovered Texture: 65045286
Clicked Texture: 58607560
IsActive: true
Scripts:
- Type: QuitButton
Enabled: true
- EID: 3
Name: Camera
IsActive: true

View File

@ -8432,7 +8432,7 @@
- EID: 20
Name: ===== Light =====
IsActive: true
NumberOfChildren: 2
NumberOfChildren: 3
Components: ~
Scripts: ~
- EID: 296
@ -8463,6 +8463,25 @@
Strength: 0.699999988
IsActive: true
Scripts: ~
- EID: 65674
Name: Light_Directional
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 2, y: 1.5, z: -5.5999999}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Light Component:
Position: {x: 2, y: 1.5, z: -5.5999999}
Type: Directional
Direction: {x: 1, y: 0, z: 0}
Color: {x: 0, y: 0, z: 0, w: 1}
Layer: 4294967295
Strength: 1
IsActive: true
Scripts: ~
- EID: 240
Name: ====ItemPool====
IsActive: true
@ -8486,7 +8505,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8533,7 +8552,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8580,7 +8599,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8627,7 +8646,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8674,7 +8693,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8721,7 +8740,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8768,7 +8787,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8815,7 +8834,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8862,7 +8881,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8909,7 +8928,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8960,7 +8979,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9007,7 +9026,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9054,7 +9073,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9101,7 +9120,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9148,7 +9167,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9195,7 +9214,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9246,7 +9265,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9287,7 +9306,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9328,7 +9347,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9369,7 +9388,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9410,9 +9429,9 @@
Scale: {x: 1, y: 1, z: 1}
IsActive: true
RigidBody Component:
Type: Static
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9449,9 +9468,9 @@
Scale: {x: 1, y: 1, z: 1}
IsActive: true
RigidBody Component:
Type: Static
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9493,10 +9512,14 @@
timer: 200
scoreText: 237
timeText: 206
multiplierText: 139
maxMultiplierDuration: 5
maxMultiplierCombo: 10
multiplierFont: 60
- EID: 199
Name: =====Text====
IsActive: true
NumberOfChildren: 2
NumberOfChildren: 3
Components: ~
Scripts: ~
- EID: 237
@ -9529,6 +9552,21 @@
Font: 176667660
IsActive: true
Scripts: ~
- EID: 139
Name: Multiplier
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -800, y: 300, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 60, y: 60, z: 60}
IsActive: true
Text Renderer Component:
Text: TEST
Font: 176667660
IsActive: true
Scripts: ~
- EID: 198
Name: ====Raccoon====
IsActive: true
@ -9551,7 +9589,7 @@
IsActive: true
RigidBody Component:
Type: Dynamic
Drag: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: false
Interpolate: true
@ -9696,7 +9734,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9741,7 +9779,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9782,7 +9820,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9823,7 +9861,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9864,7 +9902,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9905,7 +9943,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9950,7 +9988,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9991,7 +10029,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -10032,7 +10070,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -10073,7 +10111,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -10114,7 +10152,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -10159,7 +10197,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -10200,7 +10238,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -10241,7 +10279,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -10282,7 +10320,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -10406,9 +10444,9 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: false
Interpolate: true
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false

View File

@ -1,7 +1,7 @@
- EID: 0
Name: Canvas
IsActive: true
NumberOfChildren: 1
NumberOfChildren: 3
Components:
Canvas Component:
Canvas Width: 1920
@ -9,7 +9,7 @@
IsActive: true
Scripts: ~
- EID: 1
Name: Default
Name: Background
IsActive: true
NumberOfChildren: 0
Components:
@ -23,6 +23,51 @@
Material: 121834459
IsActive: true
Scripts: ~
- EID: 5
Name: Start Game Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 75, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 52901020
Hovered Texture: 62235279
Clicked Texture: 64722619
IsActive: true
Scripts:
- Type: ChangeSceneButton
Enabled: true
sceneID: 96668835
- EID: 6
Name: Quit Game Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: -200, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 66477839
Hovered Texture: 65045286
Clicked Texture: 58607560
IsActive: true
Scripts:
- Type: QuitButton
Enabled: true
- EID: 2
Name: Light
IsActive: true
@ -66,4 +111,5 @@
Components: ~
Scripts:
- Type: MainMenu
Enabled: true
Enabled: true
sceneID: 96668835

View File

@ -13,7 +13,7 @@
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: false
Interpolate: true
Interpolate: false
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
@ -25,7 +25,7 @@
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 1
Collision Tag: 2
Type: Box
Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006
@ -52,7 +52,7 @@
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 1
Collision Tag: 5
Type: Box
Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006
@ -161,7 +161,7 @@
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 1
Collision Tag: 7
Type: Box
Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006

View File

@ -15,7 +15,7 @@
- EID: 1
Name: Canvas
IsActive: true
NumberOfChildren: 1
NumberOfChildren: 3
Components:
Canvas Component:
Canvas Width: 1920
@ -23,7 +23,7 @@
IsActive: true
Scripts: ~
- EID: 2
Name: Default
Name: Background
IsActive: true
NumberOfChildren: 0
Components:
@ -37,6 +37,51 @@
Material: 129138332
IsActive: true
Scripts: ~
- EID: 5
Name: Main Menu Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 75, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 65788519
Hovered Texture: 55999018
Clicked Texture: 66382894
IsActive: true
Scripts:
- Type: ChangeSceneButton
Enabled: true
sceneID: 97158628
- EID: 6
Name: Quit Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: -200, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 66477839
Hovered Texture: 65045286
Clicked Texture: 58607560
IsActive: true
Scripts:
- Type: QuitButton
Enabled: true
- EID: 3
Name: Camera
IsActive: true

View File

@ -0,0 +1,19 @@
using System;
using SHADE;
public class FixRotation : Script
{
Transform tran;
protected override void awake()
{
tran = GetComponent<Transform>();
}
protected override void update()
{
if(tran)
tran.LocalEulerAngles = Vector3.Zero;
}
}

View File

@ -0,0 +1,3 @@
Name: FixRotation
ID: 162507316
Type: 9

View File

@ -12,7 +12,6 @@ public class Breakable : Script
private Transform trans;
public bool isBreak { get; set; }
private List<GameObject> itemPieces = new List<GameObject>();
private Random ran = new Random();
protected override void awake()
{
@ -44,7 +43,7 @@ public class Breakable : Script
if (ignoreRaccoon && info.GameObject.GetScript<PlayerController>())
return;
if (rb.LinearVelocity.GetSqrMagnitude() > threshHold)
if (rb.LinearVelocity.GetSqrMagnitude() > threshHold && !info.GameObject.GetScript<PlayerController>())
{
isBreak = true;
if(GameObject.GetScript<Item>())

View File

@ -200,25 +200,36 @@ public class PickAndThrow : Script
{
if (pc != null)
{
Vector3 dirNor = pc.tranform.Forward;
Vector3 playerRayPos = pc.tranform.GlobalPosition;
playerRayPos.y += 0.05f;
dirNor.Normalise();
List<RaycastHit> rayList1 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(22.5f))), rayDistance, false, (ushort)65535);
List<RaycastHit> rayList2 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(-22.5f))), rayDistance, false, (ushort)65535);
List<RaycastHit> rayList3 = Physics.Raycast(new Ray(playerRayPos, dirNor), rayDistance * 0.75f, false, (ushort)65535);
Vector3 dirNor = pc.tranform.Forward;
Vector3 playerRayPos = pc.tranform.GlobalPosition;
playerRayPos.y += 0.05f;
dirNor.Normalise();
List<RaycastHit> rayList1 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(22.5f))), rayDistance, false, (ushort)65535);
List<RaycastHit> rayList2 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(-22.5f))), rayDistance, false, (ushort)65535);
List<RaycastHit> rayList3 = Physics.Raycast(new Ray(playerRayPos, dirNor), rayDistance * 0.75f, false, (ushort)65535);
if (rayList1.Count > 0 && rayList2.Count > 0 && rayList3.Count > 0)
{
RaycastHit ray1 = rayList1[0];
RaycastHit ray2 = rayList2[0];
RaycastHit ray3 = rayList3[0];
inRange = CheckForItem(ray1) || CheckForItem(ray2) || CheckForItem(ray3);
}
else
{
inRange = false;
}
if (rayList1.Count > 0)
{
RaycastHit ray1 = rayList1[0];
inRange = CheckForItem(ray1);
return;
}
else if (rayList2.Count > 0)
{
RaycastHit ray2 = rayList2[0];
inRange = CheckForItem(ray2);
return;
}
else if (rayList3.Count > 0)
{
RaycastHit ray3 = rayList3[0];
inRange = CheckForItem(ray3);
return;
}
else
{
inRange = false;
}
}
}

View File

@ -371,7 +371,7 @@ public class PlayerController : Script
stateMachine.SetState(typeof(PlayerIdleState));
tranform.LocalPosition = respawnPoint.GetComponent<Transform>().LocalPosition;
if (pat && pat.item.GetScript<Item>())
if (pat && pat.item)
{
holdItem = false;
isAiming = false;

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
public class GameManager : Script
{
public enum GameState
{
{
START,
WIN,
LOSE
@ -26,6 +26,16 @@ public class GameManager : Script
public GameObject scoreText;
public GameObject timeText;
//mulitpler info
public GameObject multiplierText;
public float maxMultiplierDuration = 5.0f;
public float currMultiplierDuration { get; set; }
public int maxMultiplierCombo = 10;
public bool itemScored {get;set;}
public int currMultiplierCombo { get; set;}
public float multiplierFont = 60.0f;
private Vector3 fontScalar;
public static GameManager Instance { get; private set; }
protected override void awake()
@ -40,12 +50,15 @@ public class GameManager : Script
totalItemCount = 0;
Score = 0;
currGameState = GameState.START;
itemScored = false;
currMultiplierCombo = 1;
currMultiplierDuration = 0;
fontScalar = new Vector3(multiplierFont / maxMultiplierDuration, multiplierFont / maxMultiplierDuration , multiplierFont / maxMultiplierDuration);
}
protected override void update()
{
Cheats();
if (currGameState == GameState.START)
{
timer -= Time.DeltaTimeF;
@ -54,6 +67,25 @@ public class GameManager : Script
if(timeText)
timeText.GetComponent<TextRenderable>().Text = $"Time Left: {timer.ToString("0.00")}";
if (itemScored)
{
multiplierText.GetComponent<TextRenderable>().Text = $"X {currMultiplierCombo}";
multiplierText.GetComponent<Transform>().LocalScale -= fontScalar * Time.DeltaTimeF;
currMultiplierDuration += Time.DeltaTimeF;
if (currMultiplierDuration >= maxMultiplierDuration)
{
itemScored = false;
currMultiplierCombo = 1;
currMultiplierDuration = 0;
}
}
else
{
multiplierText.GetComponent<Transform>().LocalScale = Vector3.Zero;
}
if ((timer > 0 && totalItemCount < 0) || Input.GetKeyDown(Input.KeyCode.F1))
{
currGameState = GameState.WIN;
@ -85,5 +117,15 @@ public class GameManager : Script
SceneManager.ChangeScene(97158628);
}
}
public void ItemScored()
{
totalItemCount -= 1;
itemScored = true;
currMultiplierDuration = 0;
multiplierText.GetComponent<Transform>().LocalScale = new Vector3(multiplierFont, multiplierFont, multiplierFont);
if (currMultiplierCombo < maxMultiplierCombo)
currMultiplierCombo += 1;
}
}

View File

@ -12,8 +12,8 @@ public class ScoringZone : Script
if (GameManager.Instance && info.GameObject.GetScript<Item>())
{
Audio.PlaySFXOnce2D("event:/Music/stingers/item_scored");
GameManager.Instance.Score += info.GameObject.GetScript<Item>().Score;
GameManager.Instance.totalItemCount -= 1;
GameManager.Instance.ItemScored();
GameManager.Instance.Score += info.GameObject.GetScript<Item>().Score * GameManager.Instance.currMultiplierCombo;
info.GameObject.SetActive(false);
}
}

View File

@ -82,7 +82,7 @@ public class PhysicsTestObj : Script
{
Ray colliderRay = new Ray();
colliderRay.Direction = Vector3.Right;
Physics.ColliderRaycast(collider.Owner, colliderRay, false, 8);
Physics.ColliderRaycast(collider.Owner, colliderRay, false, (ushort)64);
for (int i = 0; i < 6; ++i)
{

View File

@ -0,0 +1,28 @@
using System;
using SHADE;
public class ChangeSceneButton : Script
{
public uint sceneID = 0;
protected override void start()
{
UIElement ui = GetComponent<UIElement>();
ui.OnClick.RegisterAction(() =>
{
if(sceneID != 0)
{
Audio.PlaySFXOnce2D("event:/UI/success");
SceneManager.ChangeScene(sceneID);
Audio.StopAllSounds();
}
});
}
protected override void update()
{
}
}

View File

@ -0,0 +1,3 @@
Name: SC_ChangeSceneButton
ID: 155329160
Type: 9

View File

@ -3,6 +3,7 @@ using SHADE;
public class MainMenu : Script
{
public uint sceneID;
protected override void awake()
{
Audio.PlayBGMOnce2D("event:/Music/main_menu");
@ -17,7 +18,7 @@ public class MainMenu : Script
if (Input.GetKeyUp(Input.KeyCode.Space))
{
Audio.PlaySFXOnce2D("event:/UI/success");
SceneManager.ChangeScene(86098106);
SceneManager.ChangeScene(sceneID);
Audio.StopAllSounds();
}

View File

@ -0,0 +1,21 @@
using System;
using SHADE;
public class QuitButton : Script
{
protected override void start()
{
UIElement ui = GetComponent<UIElement>();
ui.OnClick.RegisterAction(() =>
{
Audio.StopAllSounds();
Application.Quit();
});
}
protected override void update()
{
}
}

View File

@ -0,0 +1,3 @@
Name: SC_QuitButton
ID: 163136401
Type: 9

View File

@ -60,7 +60,7 @@ float CalcShadowValue (sampler2D shadowMap, vec4 worldSpaceFragPos, mat4 lightPV
if (fragPosLightPOV.z > sampledDepth && fragPosLightPOV.w > 0.0f)
{
return 0.0f;
return 0.7f;
}
else
return 1.0f;

View File

@ -0,0 +1,10 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
#extension GL_EXT_nonuniform_qualifier : require
void main()
{
}

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: ShadowMap_FS
ID: 45925790
Type: 2

View File

@ -39,5 +39,10 @@ layout(location = 1) out uint outEntityID;
void main()
{
fragColor = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv);
if (fragColor.a < 0.01f)
{
discard;
}
outEntityID = In2.eid;
}

Binary file not shown.

View File

@ -5,6 +5,7 @@
//#define SHEDITOR
#ifdef SHEDITOR
#include "Editor/SHEditor.h"
#include "Physics/System/SHPhysicsDebugDrawSystem.h"
//#include "Scenes/SBEditorScene.h"
#endif // SHEDITOR
@ -31,7 +32,6 @@
#include "Input/SHInputManager.h"
#include "Math/Transform/SHTransformSystem.h"
#include "Physics/System/SHPhysicsSystem.h"
#include "Physics/System/SHPhysicsDebugDrawSystem.h"
#include "Scripting/SHScriptEngine.h"
#include "UI/SHUISystem.h"
#include "Animation/SHAnimationSystem.h"
@ -74,12 +74,15 @@ namespace Sandbox
#endif
window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow, wndData);
SHAssetManager::Load();
// Create Systems
SHSystemManager::CreateSystem<SHScriptEngine>();
SHSystemManager::CreateSystem<SHTransformSystem>();
SHSystemManager::CreateSystem<SHPhysicsSystem>();
#ifndef _PUBLISH
#ifdef SHEDITOR
SHSystemManager::CreateSystem<SHPhysicsDebugDrawSystem>();
#endif
@ -122,7 +125,7 @@ namespace Sandbox
SHSystemManager::RegisterRoutine<SHPhysicsSystem, SHPhysicsSystem::PhysicsUpdate>();
SHSystemManager::RegisterRoutine<SHPhysicsSystem, SHPhysicsSystem::PhysicsPostUpdate>();
#ifndef _PUBLISH
#ifdef SHEDITOR
SHSystemManager::RegisterRoutine<SHPhysicsDebugDrawSystem, SHPhysicsDebugDrawSystem::PhysicsDebugDraw>();
#endif
@ -155,7 +158,6 @@ namespace Sandbox
SHComponentManager::CreateComponentSparseSet<SHAnimatorComponent>();
//SHComponentManager::CreateComponentSparseSet<SHCameraComponent>();
SHAssetManager::Load();
//auto font = SHAssetManager::GetData<SHFontAsset>(176667660);
SHSystemManager::RegisterRoutine<SHAudioSystem, SHAudioSystem::AudioRoutine>();

View File

@ -200,7 +200,9 @@ namespace SHADE
void SHAudioSystem::ErrorCheck() const
{
if (result != FMOD_OK)
std::cerr << "Audio system error: " << FMOD_ErrorString(result) << std::endl;
{
SHLOG_ERROR( "Audio system error: {}", FMOD_ErrorString(result))
}
}
void SHAudioSystem::PlayEventOnce(const char* path, bool isSFX, EntityID eid, bool spatial)
@ -319,6 +321,15 @@ namespace SHADE
if (channel->isPlaying(&isPlaying) == FMOD_OK && isPlaying)
channel->stop();
}
auto [begin, end] = audioClipLibrary.GetDenseAccess();
for (auto it = begin; it != end; ++it)
{
if (it->instance)
{
it->instance->stop(FMOD_STUDIO_STOP_MODE::FMOD_STUDIO_STOP_IMMEDIATE);
it->instance->release();
}
}
masterGroup->stop();
}
@ -349,6 +360,10 @@ namespace SHADE
audioClipHandle = audioClipLibrary.Create();
it->second->createInstance(&audioClipHandle->instance);
}
else
{
SHLOG_ERROR("FMOD: Failed to find event path: {}", path)
}
return audioClipHandle;
}
@ -487,10 +502,12 @@ namespace SHADE
}
void SHAudioSystem::SetBgmVolume(float const bgmvol)
{
bgmVolume = bgmvol;
bgmChannelGroup->setVolume(bgmvol);
}
void SHAudioSystem::SetSfxVolume(float const sfxvol)
{
sfxVolume = sfxvol;
sfxChannelGroup->setVolume(sfxvol);
}
void SHAudioSystem::SetMasterVolume(float const mastervol)
@ -506,15 +523,12 @@ namespace SHADE
{
channel->setPaused(paused);
}
for (auto const& event : eventMap)
auto [begin, end] = audioClipLibrary.GetDenseAccess();
for (auto it = begin; it != end; ++it)
{
int instanceCount = 0;
event.second->getInstanceCount(&instanceCount);
std::vector<FMOD::Studio::EventInstance*> instances(instanceCount);
event.second->getInstanceList(instances.data(), static_cast<int>(instances.size()), &instanceCount);
for (auto const& instance : instances)
if (it->instance)
{
instance->setPaused(pause);
it->SetPause(pause);
}
}
}
@ -546,6 +560,7 @@ namespace SHADE
bank->loadSampleData();
int numOfEvents;
bank->getEventCount(&numOfEvents);
if (numOfEvents > 0)
{
std::vector<FMOD::Studio::EventDescription*> events(numOfEvents);
@ -560,11 +575,71 @@ namespace SHADE
}
}
float SHAudioSystem::GetVCAVolume(const char* path)
{
FMOD::Studio::VCA* vca = nullptr;
result = fmodStudioSystem->getVCA(path, &vca);
float volume = 0.0f;
if (result != FMOD_OK)
{
ErrorCheck();
return volume;
}
result = vca->getVolume(&volume);
if (result != FMOD_OK)
{
ErrorCheck();
return volume;
}
return volume;
}
void SHAudioSystem::SetVCAVolume(const char* path, float value)
{
FMOD::Studio::VCA* vca = nullptr;
result = fmodStudioSystem->getVCA(path, &vca);
if (result != FMOD_OK)
{
ErrorCheck();
return;
}
result = vca->setVolume(std::clamp(value, 0.0f, 1.0f));
if (result != FMOD_OK)
{
ErrorCheck();
return;
}
}
float SHAudioSystem::GetParameterValue(const char* path)
{
float value = {};
result = fmodStudioSystem->getParameterByName(path, &value);
if(result != FMOD_OK)
{
ErrorCheck();
}
return value;
}
void SHAudioSystem::SetParameter(const char* path, float value)
{
result = fmodStudioSystem->setParameterByName(path, value);
if (result != FMOD_OK)
{
ErrorCheck();
}
}
void AudioClip::Play()
{
if(!instance)
return;
instance->start();
FMOD_RESULT result = instance->start();
if (result != FMOD_OK)
{
SHLOG_ERROR("Audio system error: {}", FMOD_ErrorString(result))
}
}
//void AudioClip::Play(bool isSfx)
@ -598,7 +673,11 @@ namespace SHADE
{
if (!instance)
return;
instance->stop(fadeOut ? FMOD_STUDIO_STOP_ALLOWFADEOUT : FMOD_STUDIO_STOP_IMMEDIATE);
FMOD_RESULT result = instance->stop(fadeOut ? FMOD_STUDIO_STOP_ALLOWFADEOUT : FMOD_STUDIO_STOP_IMMEDIATE);
if (result != FMOD_OK)
{
SHLOG_ERROR("Audio system error: {}", FMOD_ErrorString(result))
}
}
void AudioClip::SetPause(bool pause)
@ -623,7 +702,11 @@ namespace SHADE
{
if (!instance)
return;
instance->setParameterByName(paramName, value);
FMOD_RESULT result = instance->setParameterByName(paramName, value);
if (result != FMOD_OK)
{
SHLOG_ERROR("Audio system error: {}", FMOD_ErrorString(result))
}
}
//void AudioClip::SetParameterLabel(const char* paramName, const char* label)
@ -635,13 +718,33 @@ namespace SHADE
float AudioClip::GetParameterValue(const char* paramName)
{
if (!instance)
return {};
float value{};
instance->getParameterByName(paramName, &value);
if (!instance)
return value;
auto result = instance->getParameterByName(paramName, &value);
if (result != FMOD_OK)
{
SHLOG_ERROR("Audio system error: {}", FMOD_ErrorString(result))
}
return value;
}
float AudioClip::GetVolume()
{
float volume{};
if(!instance)
return volume;
instance->getVolume(&volume);
return volume;
}
void AudioClip::SetVolume(float volume)
{
if(!instance)
return;
instance->setVolume(volume);
}
SHEventHandle SHAudioSystem::onStop(SHEventPtr onStopEvent)
{
StopAllSounds();

View File

@ -35,6 +35,8 @@ namespace SHADE
void SetParameter(const char* paramName, float value);
//void SetParameterLabel(const char* paramName, const char* label);
float GetParameterValue(const char* paramName);
float GetVolume();
void SetVolume(float volume);
friend class SHAudioSystem;
private:
FMOD::Studio::EventInstance* instance = nullptr;
@ -85,7 +87,13 @@ namespace SHADE
void SetPaused(bool pause);
bool GetPaused() const;
SHVec3 GetListenerPosition();
void LoadBank(const char* path);
float GetVCAVolume(const char* path);
void SetVCAVolume(const char* path, float value);
float GetParameterValue(const char* path);
void SetParameter(const char* path, float value);
private:
FMOD::Studio::System* fmodStudioSystem;

View File

@ -94,7 +94,7 @@ namespace SHADE
if (systemContainer.find(id) == systemContainer.end())
{
std::cout << "System Manager error: System Version " << version << " does not exit." << std::endl;
std::cout << "System Manager error: System Version " << typeid(T).name() << ", " << version << " does not exist." << std::endl;
return nullptr;
}

View File

@ -11,52 +11,60 @@ namespace SHADE
{
if (Begin())
{
DrawMenuBar();
ImGui::BeginTable("CollisionMtxTable", SHCollisionTag::NUM_LAYERS + 1, ImGuiTableRowFlags_Headers);
ImGui::TableNextRow();
ImGui::PushID("CollisionTagNames");
for (int i = SHCollisionTag::NUM_LAYERS; i >= 1; --i)
// Draw Layers
// We have 16 layers for each tag
ImGui::TableNextColumn();
for (int i = 1; i <= SHCollisionTag::NUM_LAYERS; ++i)
{
ImGui::TableNextColumn();
if(i == SHCollisionTag::NUM_LAYERS) continue;
std::string const& tagName = SHCollisionTagMatrix::GetTagName(i);
auto tag = SHCollisionTagMatrix::GetTag(i);
if (!tag)
continue;
//ImGui::Text(tagName.data());
ImGui::PushID(i);
SHEditorWidgets::InputText("##", [i]{return SHCollisionTagMatrix::GetTagName(i);}, [i](std::string const& value){SHCollisionTagMatrix::GetTag(i)->SetName(value);}, tagName.data(), ImGuiInputTextFlags_EnterReturnsTrue);
ImGui::PopID();
// Show the layer number
ImGui::Text(std::to_string(i).c_str());
}
ImGui::PopID();
// Draw the table
// Convenient how we have 16 layers & 16 tags huh?
for (int i = 0; i < SHCollisionTag::NUM_LAYERS - 1; ++i)
{
std::string tagName = SHCollisionTagMatrix::GetTagName(i);
auto tag = SHCollisionTagMatrix::GetTag(i);
if(!tag)
continue;
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text(tagName.data());
for (int j = (SHCollisionTag::NUM_LAYERS) - 1; j >= i; --j)
ImGui::PushID(i);
SHEditorWidgets::InputText("##", [i]{return SHCollisionTagMatrix::GetTagName(i);}, [i](std::string const& value){SHCollisionTagMatrix::GetTag(i)->SetName(value);}, tagName.data(), ImGuiInputTextFlags_EnterReturnsTrue);
ImGui::PopID();
// The checkboxes are just to set the layers of each tag
// Nothing else should be altered.
for (int j = 0; j < SHCollisionTag::NUM_LAYERS; ++j)
{
int idx = j;
std::string tagName2 = SHCollisionTagMatrix::GetTagName(idx);
auto tag2 = SHCollisionTagMatrix::GetTag(idx);
if(!tag2)
continue;
if(tagName.empty())
tagName = std::to_string(i);
if(tagName2.empty())
tagName2 = std::to_string(idx);
ImGui::TableNextColumn();
if(i == idx)
continue;
std::string label = std::format("##{} vs {}", tagName, tagName2);
SHEditorWidgets::CheckBox(label, [tag, &idx]{return tag->GetLayerState(idx);}, [tag, i, idx](bool const& value){tag->SetLayerState(idx, value); SHCollisionTagMatrix::GetTag(idx)->SetLayerState(i, value);}, label.substr(2));
std::string label = std::format("##{}, Layer {}", tagName, j);
if (SHEditorWidgets::CheckBox(label, [tag, &j] {return tag->GetLayerState(j); }, [tag, j](bool const& value) {tag->SetLayerState(j, value); }, label.substr(2)))
{
isDirty = true;
}
}
}
ImGui::EndTable();
@ -64,4 +72,21 @@ namespace SHADE
ImGui::End();
}
void SHColliderTagPanel::DrawMenuBar()
{
if (ImGui::BeginMenuBar())
{
ImGui::BeginDisabled(!isDirty);
if (ImGui::Button("Save"))
{
std::filesystem::path defaultCollisionTagNameFilePath{ ASSET_ROOT };
defaultCollisionTagNameFilePath.append("CollisionTags.SHConfig");
SHCollisionTagMatrix::SaveToFile(defaultCollisionTagNameFilePath);
isDirty = false;
}
ImGui::EndDisabled();
ImGui::EndMenuBar();
}
}
}

View File

@ -14,6 +14,7 @@ namespace SHADE
//void Exit();
private:
void DrawMenuBar();
bool isDirty;
};
}

View File

@ -128,6 +128,7 @@ namespace SHADE
SHFreetypeInstance::Init();
//SHAssetManager::CompileAsset("../../Assets/Shaders/DeferredComposite_CS.glsl", false);
//SHAssetManager::CompileAsset("../../Assets/Shaders/ShadowMap_FS.glsl", false);
//SHAssetManager::CompileAsset("../../Assets/Shaders/SSAO_CS.glsl", false);
//SHAssetManager::CompileAsset("../../Assets/Shaders/SSAOBlur_CS.glsl", false);
//SHAssetManager::CompileAsset("../../Assets/Shaders/PureCopy_CS.glsl", false);
@ -137,6 +138,7 @@ namespace SHADE
//SHAssetManager::CompileAsset("../../Assets/Shaders/UI_FS.glsl", false);
//SHAssetManager::CompileAsset("../../Assets/Shaders/Text_VS.glsl", false);
// Load Built In Shaders
static constexpr AssetID VS_DEFAULT = 39210065; defaultVertShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(VS_DEFAULT);
static constexpr AssetID VS_ANIM = 47911992; animtVertShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(VS_ANIM);
@ -151,7 +153,8 @@ namespace SHADE
static constexpr AssetID TEXT_FS = 38024754; textFS = SHResourceManager::LoadOrGet<SHVkShaderModule>(TEXT_FS);
static constexpr AssetID RENDER_SC_VS = 48082949; renderToSwapchainVS = SHResourceManager::LoadOrGet<SHVkShaderModule>(RENDER_SC_VS);
static constexpr AssetID RENDER_SC_FS = 36869006; renderToSwapchainFS = SHResourceManager::LoadOrGet<SHVkShaderModule>(RENDER_SC_FS);
static constexpr AssetID SHADOW_MAP_VS = 44646107; shadowMapVS = SHResourceManager::LoadOrGet<SHVkShaderModule>(SHADOW_MAP_VS);
static constexpr AssetID SHADOW_MAP_VS = 44646107; shadowMapVS = SHResourceManager::LoadOrGet<SHVkShaderModule>(SHADOW_MAP_VS);
static constexpr AssetID SHADOW_MAP_FS = 45925790; shadowMapFS = SHResourceManager::LoadOrGet<SHVkShaderModule>(SHADOW_MAP_FS);
}
@ -583,14 +586,21 @@ namespace SHADE
#endif
}
//if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::B))
//{
// auto& lightComps = SHComponentManager::GetDense<SHLightComponent>();
// for (auto& comp : lightComps)
// {
// comp.SetEnableShadow(true);
// }
//}
static bool shadowAdded = false;
if (shadowAdded == false/* && SHInputManager::GetKey(SHInputManager::SH_KEYCODE::B)*/)
{
shadowAdded = true;
auto& lightComps = SHComponentManager::GetDense<SHLightComponent>();
if (lightComps.size() > 2)
{
lightComps[2].SetEnableShadow(true);
}
//for (auto& comp : lightComps)
//{
// comp.SetEnableShadow(true);
//}
}
renderGraph->Begin(frameIndex);
auto cmdBuffer = renderGraph->GetCommandBuffer(frameIndex);
@ -809,11 +819,11 @@ namespace SHADE
tempLibrary.Init(device);
tempLibrary.CreateGraphicsPipelines
(
{ shadowMapVS, {} }, shadowMapNode->GetRenderpass(), newSubpass,
{ shadowMapVS, shadowMapFS }, shadowMapNode->GetRenderpass(), newSubpass,
SHGraphicsPredefinedData::SystemType::BATCHING,
SHGraphicsPredefinedData::GetShadowMapViState(), rasterState
);
shadowMapPipeline = tempLibrary.GetGraphicsPipeline({ shadowMapVS, {} });
shadowMapPipeline = tempLibrary.GetGraphicsPipeline({ shadowMapVS, shadowMapFS });
}
newSubpass->SetCompanionSubpass(companionSubpass, shadowMapPipeline); // set companion subpass and pipeline

View File

@ -469,6 +469,7 @@ namespace SHADE
Handle<SHVkShaderModule> renderToSwapchainVS;
Handle<SHVkShaderModule> renderToSwapchainFS;
Handle<SHVkShaderModule> shadowMapVS;
Handle<SHVkShaderModule> shadowMapFS;
// Fonts
Handle<SHFont> testFont;

View File

@ -166,7 +166,7 @@ namespace SHADE
/* Public Function Member Definitions */
/*-----------------------------------------------------------------------------------*/
void SHCollisionTagMatrix::Init(const std::filesystem::path& tagNameFilePath) noexcept
void SHCollisionTagMatrix::LoadFromFile(const std::filesystem::path& tagNameFilePath) noexcept
{
/**
* I HATE FILE IO
@ -240,21 +240,26 @@ namespace SHADE
, linesRead + 1
, tagIndex
)
collisionTags[tagIndex].SetMask(mask);
}
else
{
mask = static_cast<uint16_t>(std::stoi(maskString));
for (int i = 0; i < SHCollisionTag::NUM_LAYERS; ++i)
{
const bool LAYER_STATE = mask & 1U << i;
collisionTags[tagIndex].SetLayerState(i, LAYER_STATE);
}
}
collisionTags[tagIndex].SetMask(mask);
ss.clear();
}
collisionTagNamesFile.close();
}
void SHCollisionTagMatrix::Exit(const std::filesystem::path& tagNameFilePath) noexcept
void SHCollisionTagMatrix::SaveToFile(const std::filesystem::path& tagNameFilePath) noexcept
{
std::ofstream collisionTagNamesFile { tagNameFilePath };
@ -266,7 +271,15 @@ namespace SHADE
// Index Name Mask
for (int i = 0; i < SHCollisionTag::NUM_LAYERS; ++i)
collisionTagNamesFile << i << " " << collisionTags[i].GetName() << " " << collisionTags[i].GetMask() << std::endl;
{
collisionTagNamesFile << i << " " << collisionTags[i].GetName() << " ";
// Write 1 or 0 for each layer for improved clarity
for (int j = 0; j < SHCollisionTag::NUM_LAYERS; ++j)
collisionTagNamesFile << (collisionTags[i].GetMask() & 1U << j ? 1 : 0);
collisionTagNamesFile << std::endl;
}
collisionTagNamesFile.close();
}

View File

@ -55,8 +55,8 @@ namespace SHADE
/* Function Members */
/*---------------------------------------------------------------------------------*/
static void Init (const std::filesystem::path& tagNameFilePath) noexcept;
static void Exit (const std::filesystem::path& tagNameFilePath) noexcept;
static void LoadFromFile (const std::filesystem::path& tagNameFilePath) noexcept;
static void SaveToFile (const std::filesystem::path& tagNameFilePath) noexcept;
/**
* @brief

View File

@ -120,7 +120,10 @@ namespace SHADE
collisionTag = newCollisionTag;
if (rp3dCollider)
{
rp3dCollider->setCollisionCategoryBits(collisionTag->GetMask());
rp3dCollider->setCollideWithMaskBits(collisionTag->GetMask());
}
}
void SHCollisionShape::SetFriction(float friction) noexcept
@ -144,7 +147,12 @@ namespace SHADE
material.SetDensity(density);
if (rp3dCollider)
{
rp3dCollider->getMaterial().setMassDensity(material.GetDensity());
// Recompute the bodies' mass
dynamic_cast<rp3d::RigidBody*>(collider->collisionBody)->updateMassPropertiesFromColliders();
}
}
void SHCollisionShape::SetMaterial(const SHPhysicsMaterial& newMaterial) noexcept
@ -157,6 +165,9 @@ namespace SHADE
rp3dMaterial.setFrictionCoefficient(material.GetFriction());
rp3dMaterial.setBounciness(material.GetBounciness());
rp3dMaterial.setMassDensity(material.GetDensity());
// Recompute the bodies' mass
dynamic_cast<rp3d::RigidBody*>(collider->collisionBody)->updateMassPropertiesFromColliders();
}
}
@ -180,7 +191,13 @@ namespace SHADE
isTrigger ? flags |= FLAG_VALUE : flags &= ~FLAG_VALUE;
if (rp3dCollider)
{
rp3dCollider->setIsTrigger(isTrigger);
// Recompute the bodies' mass
dynamic_cast<rp3d::RigidBody*>(collider->collisionBody)->updateMassPropertiesFromColliders();
}
}
/*-----------------------------------------------------------------------------------*/
@ -189,8 +206,11 @@ namespace SHADE
void SHCollisionShape::UpdateCollisionTags() noexcept
{
if (collisionTag->IsDirty())
if (rp3dCollider && collisionTag->IsDirty())
{
rp3dCollider->setCollisionCategoryBits(collisionTag->GetMask());
rp3dCollider->setCollideWithMaskBits(collisionTag->GetMask());
}
}

View File

@ -210,9 +210,6 @@ namespace SHADE
{
.entityID = rigidBody->GetEID()
, .bodyType = rigidBody->type
, .interpolate = rigidBody->interpolate
, .drag = rigidBody->drag
, .angularDrag = rigidBody->angularDrag
};
rigidBodyQueue.push(RIGID_BODY_DEF);
@ -232,22 +229,8 @@ namespace SHADE
SHColliderDef::ShapeDef shapeDef
{
.type = shape->GetType()
, .posOffset = shape->GetPositionOffset()
, .rotOffset = shape->GetRotationOffset()
};
switch (shape->GetType())
{
case SHCollisionShape::Type::SPHERE:
shapeDef.size.x = dynamic_cast<const SHSphere*>(shape)->GetWorldRadius();
break;
case SHCollisionShape::Type::BOX:
shapeDef.size = dynamic_cast<const SHBox*>(shape)->GetWorldExtents();
break;
default:
break;
}
colliderDef.shapes.emplace_back(shapeDef);
}
@ -311,9 +294,9 @@ namespace SHADE
rigidBodyComponent->SetFreezeRotationY (rigidBodyComponent->GetFreezeRotationY());
rigidBodyComponent->SetFreezeRotationZ (rigidBodyComponent->GetFreezeRotationZ());
rigidBodyComponent->SetInterpolate (DEF.interpolate);
rigidBodyComponent->SetDrag (DEF.drag);
rigidBodyComponent->SetAngularDrag (DEF.angularDrag);
rigidBodyComponent->SetInterpolate (rigidBodyComponent->IsInterpolating());
rigidBodyComponent->SetDrag (rigidBodyComponent->GetDrag());
rigidBodyComponent->SetAngularDrag (rigidBodyComponent->GetAngularDrag());
rigidBodyQueue.pop();
}

View File

@ -47,9 +47,6 @@ namespace SHADE
{
EntityID entityID = MAX_EID;
SHRigidBodyComponent::Type bodyType = SHRigidBodyComponent::Type::STATIC;
bool interpolate = true;
float drag = 0.0f;
float angularDrag = 0.0f;
};
struct SHColliderDef
@ -57,9 +54,6 @@ namespace SHADE
struct ShapeDef
{
SHCollisionShape::Type type = SHCollisionShape::Type::SPHERE;
SHVec3 posOffset = SHVec3::Zero;
SHVec3 rotOffset = SHVec3::Zero;
SHVec3 size = SHVec3::Zero; // x for sphere radius, all 3 for box extents
};
EntityID entityID = MAX_EID;

View File

@ -42,6 +42,7 @@ namespace SHADE
/* Friends */
/*---------------------------------------------------------------------------------*/
friend class SHCollisionShape;
friend class SHPhysicsSystem;
friend class SHPhysicsObjectManager;

View File

@ -94,8 +94,8 @@ namespace SHADE
{
const bool CLEAR_EVENT = C_INFO.GetCollisionState() == SHCollisionInfo::State::EXIT || C_INFO.GetCollisionState() == SHCollisionInfo::State::INVALID;
const bool INACTIVE_OBJECT = !SHSceneManager::CheckNodeAndComponentsActive<SHColliderComponent>(C_INFO.GetEntityA())
|| !SHSceneManager::CheckNodeAndComponentsActive<SHColliderComponent>(C_INFO.GetEntityB());
const bool INACTIVE_OBJECT = !SHSceneManager::CheckNodeAndHasComponentsActive<SHColliderComponent>(C_INFO.GetEntityA())
|| !SHSceneManager::CheckNodeAndHasComponentsActive<SHColliderComponent>(C_INFO.GetEntityB());
if (CLEAR_EVENT || INACTIVE_OBJECT)
{

View File

@ -122,7 +122,7 @@ namespace SHADE
// Initialise collision tags
std::filesystem::path defaultCollisionTagNameFilePath { ASSET_ROOT };
defaultCollisionTagNameFilePath.append("CollisionTags.SHConfig");
SHCollisionTagMatrix::Init(defaultCollisionTagNameFilePath);
SHCollisionTagMatrix::LoadFromFile(defaultCollisionTagNameFilePath);
// Register Events
for (int i = 0; i < NUM_EVENT_FUNCTIONS; ++i)
@ -145,7 +145,7 @@ namespace SHADE
// Write collision tag names to file
std::filesystem::path defaultCollisionTagNameFilePath { ASSET_ROOT };
defaultCollisionTagNameFilePath.append("CollisionTags.SHConfig");
SHCollisionTagMatrix::Exit(defaultCollisionTagNameFilePath);
SHCollisionTagMatrix::SaveToFile(defaultCollisionTagNameFilePath);
}
const std::vector<SHPhysicsRaycastResult>& SHPhysicsSystem::Raycast(const SHRaycaster::RaycastInfo& info) noexcept
@ -155,7 +155,7 @@ namespace SHADE
// Load start and end points into the container for debug drawing
#ifdef SHEDITOR
SHVec3 endPos = info.ray.position + info.ray.direction * SHRay::MAX_RAYCAST_DIST;
SHVec3 endPos = info.ray.position + info.ray.direction * std::clamp(info.distance, 0.0f, SHRay::MAX_RAYCAST_DIST);
if (!results.empty())
endPos = results.back().position;

View File

@ -169,11 +169,8 @@ namespace SHADE
SHPhysicsObjectManager objectManager;
SHCollisionListener collisionListener;
SHRaycaster raycaster;
// For the debug drawer to draw rays
#ifdef SHEDITOR
std::vector<RaycastHit> raycastHits;
#endif
/*---------------------------------------------------------------------------------*/
/* Function Members */

View File

@ -62,9 +62,9 @@ namespace SHADE
loadFunctions();
// Generate script assembly if it hasn't been before
#ifndef _PUBLISH
#ifndef _PUBLISH
BuildScriptAssembly();
#endif
#endif
// Initialise the CSharp Engine
csEngineInit();

View File

@ -7,7 +7,7 @@ namespace SHADE
{
SHButtonComponent::SHButtonComponent()
:size(1.0f), isHovered(false), isClicked(false),
defaultTexture(0), hoveredTexture(0), clickedTexture(0)
defaultTexture(0), hoveredTexture(0), clickedTexture(0), currentTexture(0)
{
}

View File

@ -40,6 +40,8 @@ namespace SHADE
AssetID defaultTexture;
AssetID hoveredTexture;
AssetID clickedTexture;
AssetID currentTexture;
RTTR_ENABLE()

View File

@ -6,7 +6,7 @@ namespace SHADE
{
SHToggleButtonComponent::SHToggleButtonComponent()
:size(1.0f), isHovered(false), isClicked(false), value(false),
defaultTexture(0), toggledTexture(0)
defaultTexture(0), toggledTexture(0), currentTexture(0)
{
}

View File

@ -41,6 +41,8 @@ namespace SHADE
bool value;
AssetID defaultTexture;
AssetID toggledTexture;
AssetID currentTexture;

View File

@ -236,12 +236,14 @@ namespace SHADE
auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
//auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
auto material = renderable->GetModifiableMaterial();
AssetID textureID = 0;
if (!comp.isHovered && !comp.isClicked)
{
if (comp.GetDefaultTexture() != 0 && SHAssetManager::GetType(comp.GetDefaultTexture()) == AssetType::TEXTURE)
{
material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetDefaultTexture()));
textureID = comp.GetDefaultTexture();
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetDefaultTexture()));
//SHLOG_INFO("SETTING DEFAULT TEXTURE")
}
}
@ -249,7 +251,8 @@ namespace SHADE
{
if (comp.GetClickedTexture() != 0 && SHAssetManager::GetType(comp.GetClickedTexture()) == AssetType::TEXTURE)
{
material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetClickedTexture()));
textureID = comp.GetClickedTexture();
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetClickedTexture()));
//SHLOG_INFO("SETTING CLICKED TEXTURE")
}
}
@ -257,10 +260,17 @@ namespace SHADE
{
if (comp.GetHoveredTexture() != 0 && SHAssetManager::GetType(comp.GetHoveredTexture()) == AssetType::TEXTURE)
{
material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>( comp.GetHoveredTexture()));
textureID = comp.GetHoveredTexture();
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>( comp.GetHoveredTexture()));
//SHLOG_INFO("SETTING HOVERED TEXTURE")
}
}
if (textureID != 0 && textureID != comp.currentTexture)
{
auto material = renderable->GetModifiableMaterial();
comp.currentTexture = textureID;
material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(textureID));
}
@ -358,12 +368,14 @@ namespace SHADE
auto renderable = SHComponentManager::GetComponent_s<SHRenderable>(comp.GetEID());
//auto texture = SHResourceManager::Get<SHTexture>(comp.GetDefaultTexture());
auto material = renderable->GetModifiableMaterial();
//auto material = renderable->GetModifiableMaterial();
AssetID textureID = 0;
if (comp.GetValue() == false)
{
if (comp.GetDefaultTexture()!= 0 && SHAssetManager::GetType(comp.GetDefaultTexture()) == AssetType::TEXTURE)
{
material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetDefaultTexture()));
textureID = comp.GetDefaultTexture();
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetDefaultTexture()));
//SHLOG_INFO("SETTING DEFAULT TEXTURE")
}
}
@ -371,11 +383,20 @@ namespace SHADE
{
if (comp.GetToggledTexture() != 0 && SHAssetManager::GetType(comp.GetToggledTexture()) == AssetType::TEXTURE)
{
material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetToggledTexture()));
textureID = comp.GetToggledTexture();
//material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(comp.GetToggledTexture()));
//SHLOG_INFO("SETTING DEFAULT TEXTURE")
}
}
if (textureID != 0 && textureID != comp.currentTexture)
{
auto material = renderable->GetModifiableMaterial();
comp.currentTexture = textureID;
material->SetProperty("data.textureIndex", SHResourceManager::LoadOrGet<SHTexture>(textureID));
}
}
}

View File

@ -99,6 +99,31 @@ namespace SHADE
audioSys->StopAllSounds();
}
float Audio::GetVCAVolume(System::String^ path)
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
return audioSys->GetVCAVolume(Convert::ToNative(path).data());
}
void Audio::SetVCAVolume(System::String^ path, float volume)
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
audioSys->SetVCAVolume(Convert::ToNative(path).data(), volume);
}
float Audio::GetParameterValue(System::String^ path)
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
return audioSys->GetParameterValue(Convert::ToNative(path).data());
}
void Audio::SetParameter(System::String^ path, float value)
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();
audioSys->SetParameter(Convert::ToNative(path).data(), value);
}
AudioClipHandler Audio::CreateAudioClip(System::String^ path)
{
auto audioSys = SHSystemManager::GetSystem<SHAudioSystem>();

View File

@ -101,6 +101,10 @@ namespace SHADE
/// </summary>
static void StopAllSounds();
static float GetVCAVolume(System::String^ path);
static void SetVCAVolume(System::String^ path, float volume);
static float GetParameterValue(System::String^ path);
static void SetParameter(System::String^ path, float value);
//to comment ltr
static AudioClipHandler CreateAudioClip(System::String^ path);

View File

@ -84,6 +84,14 @@ namespace SHADE
return NativeObject->GetParameterValue(Convert::ToNative(paramName).data());
}
float AudioClipHandler::GetVolume()
{
return NativeObject->GetVolume();
}
void AudioClipHandler::SetVolume(float volume)
{
NativeObject->SetVolume(volume);
}
}

View File

@ -72,6 +72,8 @@ namespace SHADE
bool IsPaused();
void SetParameter(System::String^ paramName, float value);
float GetParameterValue(System::String^ paramName);
float GetVolume();
void SetVolume(float volume);
protected:
/*-----------------------------------------------------------------------------*/

View File

@ -28,25 +28,32 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/
bool Application::IsPlaying::get()
{
#ifdef SHEDITOR
auto editor = SHSystemManager::GetSystem<SHEditor>();
if (editor)
return editor->editorState == SHEditor::State::PLAY
||
editor->editorState == SHEditor::State::PAUSE;
#endif
return true;
}
bool Application::IsPaused::get()
{
#ifdef SHEDITOR
auto editor = SHSystemManager::GetSystem<SHEditor>();
if (editor)
return editor->editorState == SHEditor::State::PAUSE;
#endif
return false;
}
bool Application::IsEditor::get()
{
#ifdef SHEDITOR
return SHSystemManager::GetSystem<SHEditor>() != nullptr;
#else
return false;
#endif
}
int Application::WindowWidth::get()
{