Added namespaces

This commit is contained in:
Pascal Serrarens 2024-01-16 11:57:58 +01:00
parent 83ab3a6dbe
commit ea9deb82fb
9 changed files with 186 additions and 159 deletions

View File

@ -236,7 +236,7 @@ namespace Passer.Humanoid {
if (bones[i] == null || bones[i].bone == null || bones[i].bone.transform == null) if (bones[i] == null || bones[i].bone == null || bones[i].bone.transform == null)
continue; continue;
Handles.FreeMoveHandle(bones[i].bone.transform.position, bones[i].bone.transform.rotation, 0.002F, Vector3.zero, DotHandleCapSaveID); var fmh_239_74_638409995538839071 = bones[i].bone.transform.rotation; Handles.FreeMoveHandle(bones[i].bone.transform.position, 0.002F, Vector3.zero, DotHandleCapSaveID);
controlIds[i] = lastControlID; controlIds[i] = lastControlID;
boneIds[i] = bones[i].boneId; boneIds[i] = bones[i].boneId;
} }

View File

@ -1,33 +1,36 @@
using System.Collections; using System.Collections;
using UnityEngine; using UnityEngine;
public class FlashLight : MonoBehaviour { namespace Passer {
protected Light thisLight; public class FlashLight : MonoBehaviour {
public float duration = 0.1F; protected Light thisLight;
protected virtual void Awake() { public float duration = 0.1F;
thisLight = GetComponent<Light>();
protected virtual void Awake() {
thisLight = GetComponent<Light>();
}
public void Flash() {
Flash(duration);
}
public void Flash(float duration) {
if (thisLight == null)
return;
StartCoroutine(FlashRoutine(thisLight, duration));
}
protected IEnumerator FlashRoutine(Light light, float duration) {
if (light == null)
yield return null;
light.enabled = true;
yield return new WaitForSeconds(duration);
light.enabled = false;
}
} }
}
public void Flash() {
Flash(duration);
}
public void Flash(float duration) {
if (thisLight == null)
return;
StartCoroutine(FlashRoutine(thisLight, duration));
}
protected IEnumerator FlashRoutine(Light light, float duration) {
if (light == null)
yield return null;
light.enabled = true;
yield return new WaitForSeconds(duration);
light.enabled = false;
}
}

View File

@ -1,8 +1,12 @@
using UnityEngine; using UnityEngine;
public class Hit : MonoBehaviour { namespace Passer {
public void HitMe() { public class Hit : MonoBehaviour {
Debug.Log("AU!");
public void HitMe() {
Debug.Log("AU!");
}
} }
}
}

View File

@ -1,39 +1,43 @@
using UnityEngine; using UnityEngine;
public class Redrop : MonoBehaviour { namespace Passer {
// Script which is to be replaced by CollisionEventHandler public class Redrop : MonoBehaviour {
public Collider groundCollider; // Script which is to be replaced by CollisionEventHandler
private Rigidbody thisRigidbody; public Collider groundCollider;
private Vector3 startPosition;
private Quaternion startRotation;
void Start() { private Rigidbody thisRigidbody;
startPosition = transform.position; private Vector3 startPosition;
startRotation = transform.rotation; private Quaternion startRotation;
}
void Update() { void Start() {
if (groundCollider == null && transform.position.y < 0) { startPosition = transform.position;
MoveToStart(); startRotation = transform.rotation;
}
void Update() {
if (groundCollider == null && transform.position.y < 0) {
MoveToStart();
}
}
private void OnCollisionEnter(Collision collision) {
if (collision.collider == groundCollider) {
MoveToStart();
}
}
private void MoveToStart() {
thisRigidbody = transform.GetComponent<Rigidbody>();
if (thisRigidbody != null) {
thisRigidbody.MovePosition(new Vector3(startPosition.x, startPosition.y + 0.1F, startPosition.z));
thisRigidbody.MoveRotation(startRotation);
thisRigidbody.velocity = Vector3.zero;
thisRigidbody.angularVelocity = Vector3.zero;
}
} }
} }
private void OnCollisionEnter(Collision collision) { }
if (collision.collider == groundCollider) {
MoveToStart();
}
}
private void MoveToStart() {
thisRigidbody = transform.GetComponent<Rigidbody>();
if (thisRigidbody != null) {
thisRigidbody.MovePosition(new Vector3(startPosition.x, startPosition.y + 0.1F, startPosition.z));
thisRigidbody.MoveRotation(startRotation);
thisRigidbody.velocity = Vector3.zero;
thisRigidbody.angularVelocity = Vector3.zero;
}
}
}

View File

@ -4,31 +4,42 @@ using UnityEngine.SceneManagement;
using UnityEditor; using UnityEditor;
using UnityEditor.SceneManagement; using UnityEditor.SceneManagement;
namespace Passer {
[InitializeOnLoad] [InitializeOnLoad]
public class SceneLoader { public class SceneLoader {
static SceneLoader() { static SceneLoader() {
EditorSceneManager.sceneOpened += SceneOpened; EditorSceneManager.sceneOpened += SceneOpened;
}
private static void SceneOpened(Scene scene, OpenSceneMode mode) {
if ((scene.name == "ObjectTable Pawn" ||
scene.name == "ObjectTable Pawn VR" ||
scene.name == "ObjectTable Humanoid") &&
EditorSceneManager.loadedSceneCount == 1) {
//Debug.Log("Additive opening ObjectTable scene");
EditorSceneManager.OpenScene("Assets/PawnControl/Demo/Environments/ObjectTable.unity", OpenSceneMode.Additive);
}
else if ((scene.name == "ShootingRange Pawn" ||
scene.name == "ShootingRange Pawn VR" ||
scene.name == "ShootingRange Humanoid") &&
EditorSceneManager.loadedSceneCount == 1) {
//Debug.Log("Additive opening ShootingRange scene");
EditorSceneManager.OpenScene("Assets/PawnControl/Demo/Environments/ShootingRange.unity", OpenSceneMode.Additive);
} }
private static void SceneOpened(Scene scene, OpenSceneMode mode) {
if ((scene.name == "ObjectTable Pawn" ||
scene.name == "ObjectTable Pawn VR" ||
scene.name == "ObjectTable Humanoid")
#if UNITY_2022_2_OR_NEWER
&& UnityEngine.SceneManagement.SceneManager.loadedSceneCount == 1
#else
&& EditorSceneManager.loadedSceneCount == 1
#endif
) {
//Debug.Log("Additive opening ObjectTable scene");
EditorSceneManager.OpenScene("Assets/PawnControl/Demo/Environments/ObjectTable.unity", OpenSceneMode.Additive);
}
else if ((scene.name == "ShootingRange Pawn" ||
scene.name == "ShootingRange Pawn VR" ||
scene.name == "ShootingRange Humanoid")
#if UNITY_2022_2_OR_NEWER
&& UnityEngine.SceneManagement.SceneManager.loadedSceneCount == 1
#else
&& EditorSceneManager.loadedSceneCount == 1
#endif
) {
//Debug.Log("Additive opening ShootingRange scene");
EditorSceneManager.OpenScene("Assets/PawnControl/Demo/Environments/ShootingRange.unity", OpenSceneMode.Additive);
}
}
} }
} }
#endif #endif

View File

@ -1,6 +1,6 @@
using UnityEngine; using UnityEngine;
//namespace Passer { namespace Passer {
public static class RigidbodyTools { public static class RigidbodyTools {
public static void DestroyGameObject(this Rigidbody rigidbody) { public static void DestroyGameObject(this Rigidbody rigidbody) {
@ -8,4 +8,4 @@
} }
} }
//} }

View File

@ -1,66 +1,68 @@
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
using Passer; namespace Passer {
public class ControllerDebugger : MonoBehaviour { public class ControllerDebugger : MonoBehaviour {
[System.Serializable] [System.Serializable]
public struct ControllerSideDebugger { public struct ControllerSideDebugger {
public float stickHorizontal; public float stickHorizontal;
public float stickVertical; public float stickVertical;
public bool stickButton; public bool stickButton;
public bool stickTouch; public bool stickTouch;
public float touchpadHorizontal; public float touchpadHorizontal;
public float touchpadVertical; public float touchpadVertical;
public bool touchpadButton; public bool touchpadButton;
public bool touchpadTouch; public bool touchpadTouch;
public bool[] buttons; public bool[] buttons;
public float bumper; public float bumper;
public float trigger; public float trigger;
public bool option; public bool option;
}
public ControllerSideDebugger left;
public ControllerSideDebugger right;
private Controller controller;
private void Start() {
controller = Controllers.GetController(0);
left.buttons = new bool[4];
right.buttons = new bool[4];
}
private void Update() {
UpdateSide(ref left, controller.left);
UpdateSide(ref right, controller.right);
}
void UpdateSide(ref ControllerSideDebugger sideDebugger, ControllerSide controllerSide) {
sideDebugger.stickHorizontal = controllerSide.stickHorizontal;
sideDebugger.stickVertical = controllerSide.stickVertical;
sideDebugger.stickButton = controllerSide.stickButton;
sideDebugger.stickTouch = controllerSide.stickTouch;
sideDebugger.touchpadHorizontal = controllerSide.touchpadHorizontal;
sideDebugger.touchpadVertical = controllerSide.touchpadVertical;
sideDebugger.touchpadButton = controllerSide.touchpadPress;
sideDebugger.touchpadTouch = controllerSide.touchpadTouch;
sideDebugger.buttons[0] = controllerSide.buttons[0];
sideDebugger.buttons[1] = controllerSide.buttons[1];
sideDebugger.buttons[2] = controllerSide.buttons[2];
sideDebugger.buttons[3] = controllerSide.buttons[3];
sideDebugger.bumper = controllerSide.trigger1;
sideDebugger.trigger = controllerSide.trigger2;
sideDebugger.option = controllerSide.option;
}
} }
public ControllerSideDebugger left; }
public ControllerSideDebugger right;
private Controller controller;
private void Start () {
controller = Controllers.GetController(0);
left.buttons = new bool[4];
right.buttons = new bool[4];
}
private void Update () {
UpdateSide(ref left, controller.left);
UpdateSide(ref right, controller.right);
}
void UpdateSide(ref ControllerSideDebugger sideDebugger, ControllerSide controllerSide) {
sideDebugger.stickHorizontal = controllerSide.stickHorizontal;
sideDebugger.stickVertical = controllerSide.stickVertical;
sideDebugger.stickButton = controllerSide.stickButton;
sideDebugger.stickTouch = controllerSide.stickTouch;
sideDebugger.touchpadHorizontal = controllerSide.touchpadHorizontal;
sideDebugger.touchpadVertical = controllerSide.touchpadVertical;
sideDebugger.touchpadButton = controllerSide.touchpadPress;
sideDebugger.touchpadTouch = controllerSide.touchpadTouch;
sideDebugger.buttons[0] = controllerSide.buttons[0];
sideDebugger.buttons[1] = controllerSide.buttons[1];
sideDebugger.buttons[2] = controllerSide.buttons[2];
sideDebugger.buttons[3] = controllerSide.buttons[3];
sideDebugger.bumper = controllerSide.trigger1;
sideDebugger.trigger = controllerSide.trigger2;
sideDebugger.option = controllerSide.option;
}
}

View File

@ -1,18 +1,17 @@
using System.Collections; using UnityEngine;
using System.Collections.Generic;
using UnityEngine;
public class ShowVisitorName : MonoBehaviour namespace Passer {
{
// Start is called before the first frame update public class ShowVisitorName : MonoBehaviour {
void Start() // Start is called before the first frame update
{ void Start() {
}
// Update is called once per frame
void Update() {
}
} }
// Update is called once per frame }
void Update()
{
}
}

View File

@ -1,8 +1,12 @@
using UnityEngine; using UnityEngine;
public class ToggleActive : MonoBehaviour { namespace Passer {
// Temporary helper script to implement toggling the gameobject active state
public void Toggle() { public class ToggleActive : MonoBehaviour {
this.gameObject.SetActive(!this.gameObject.activeSelf); // Temporary helper script to implement toggling the gameobject active state
public void Toggle() {
this.gameObject.SetActive(!this.gameObject.activeSelf);
}
} }
}
}