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)
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;
boneIds[i] = bones[i].boneId;
}

View File

@ -1,33 +1,36 @@
using System.Collections;
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() {
thisLight = GetComponent<Light>();
public float duration = 0.1F;
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;
public class Hit : MonoBehaviour {
namespace Passer {
public void HitMe() {
Debug.Log("AU!");
public class Hit : MonoBehaviour {
public void HitMe() {
Debug.Log("AU!");
}
}
}
}

View File

@ -1,39 +1,43 @@
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;
private Vector3 startPosition;
private Quaternion startRotation;
public Collider groundCollider;
void Start() {
startPosition = transform.position;
startRotation = transform.rotation;
}
private Rigidbody thisRigidbody;
private Vector3 startPosition;
private Quaternion startRotation;
void Update() {
if (groundCollider == null && transform.position.y < 0) {
MoveToStart();
void Start() {
startPosition = transform.position;
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.SceneManagement;
namespace Passer {
[InitializeOnLoad]
public class SceneLoader {
static SceneLoader() {
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);
[InitializeOnLoad]
public class SceneLoader {
static SceneLoader() {
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")
#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

View File

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

View File

@ -1,66 +1,68 @@
using UnityEngine;
using System.Collections;
using Passer;
namespace Passer {
public class ControllerDebugger : MonoBehaviour {
public class ControllerDebugger : MonoBehaviour {
[System.Serializable]
public struct ControllerSideDebugger {
public float stickHorizontal;
public float stickVertical;
public bool stickButton;
public bool stickTouch;
[System.Serializable]
public struct ControllerSideDebugger {
public float stickHorizontal;
public float stickVertical;
public bool stickButton;
public bool stickTouch;
public float touchpadHorizontal;
public float touchpadVertical;
public bool touchpadButton;
public bool touchpadTouch;
public float touchpadHorizontal;
public float touchpadVertical;
public bool touchpadButton;
public bool touchpadTouch;
public bool[] buttons;
public bool[] buttons;
public float bumper;
public float trigger;
public float bumper;
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 System.Collections.Generic;
using UnityEngine;
using UnityEngine;
public class ShowVisitorName : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
namespace Passer {
public class ShowVisitorName : MonoBehaviour {
// 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;
public class ToggleActive : MonoBehaviour {
// Temporary helper script to implement toggling the gameobject active state
public void Toggle() {
this.gameObject.SetActive(!this.gameObject.activeSelf);
namespace Passer {
public class ToggleActive : MonoBehaviour {
// Temporary helper script to implement toggling the gameobject active state
public void Toggle() {
this.gameObject.SetActive(!this.gameObject.activeSelf);
}
}
}
}