Files
XCEngine/managed/GameScripts/LifecycleProbe.cs

173 lines
5.4 KiB
C#
Raw Normal View History

2026-03-26 22:10:43 +08:00
using XCEngine;
namespace Gameplay
{
public abstract class AbstractLifecycleProbe : MonoBehaviour
{
}
public sealed class UnsupportedManagedComponent : Component
{
private UnsupportedManagedComponent(ulong gameObjectUUID)
: base(gameObjectUUID)
{
}
}
2026-03-26 22:10:43 +08:00
public sealed class LifecycleProbe : MonoBehaviour
{
public int AwakeCount;
public int EnableCount;
public int StartCount;
public int FixedUpdateCount;
public int UpdateCount;
public int LateUpdateCount;
public int DisableCount;
public int DestroyCount;
public float Speed;
public float ObservedFixedDeltaTime;
public float ObservedUpdateDeltaTime;
public float ObservedLateDeltaTime;
2026-03-26 22:10:43 +08:00
public string Label = string.Empty;
public string ObservedGameObjectName = string.Empty;
public string ObservedTargetName = string.Empty;
2026-03-26 22:10:43 +08:00
public bool WasAwakened;
public bool WarningLogged;
public bool ErrorLogged;
public bool HasTransform;
public bool TransformLookupSucceeded;
public bool HasUnsupportedComponent;
public bool UnsupportedComponentLookupReturnedNull;
public bool TargetResolved;
public bool RotationAccessed;
public bool ScaleAccessed;
public bool TransformAccessed;
public bool ObservedEnabled;
public bool ObservedActiveSelf;
public bool ObservedActiveInHierarchy;
public bool ObservedIsActiveAndEnabled;
public bool DisableSelfOnFirstUpdate;
public bool DeactivateGameObjectOnFirstUpdate;
public GameObject Target;
public GameObject SelfReference;
public Vector4 ObservedLocalRotation;
public Vector3 ObservedLocalPosition;
public Vector3 ObservedLocalScale;
2026-03-26 22:10:43 +08:00
public Vector3 SpawnPoint;
public void Awake()
{
AwakeCount += 1;
WasAwakened = true;
gameObject.name = gameObject.name + "_Managed";
ObservedGameObjectName = gameObject.name;
Debug.Log(ObservedGameObjectName);
Debug.LogWarning(ObservedGameObjectName);
WarningLogged = true;
Debug.LogError(ObservedGameObjectName);
ErrorLogged = true;
2026-03-26 22:10:43 +08:00
Label = Label + "|Awake";
}
public void OnEnable()
{
EnableCount += 1;
}
public void Start()
{
StartCount += 1;
HasTransform = HasComponent<Transform>();
HasUnsupportedComponent = HasComponent<UnsupportedManagedComponent>();
SelfReference = gameObject;
TargetResolved = Target != null;
if (Target != null)
{
ObservedTargetName = Target.name;
}
TransformLookupSucceeded = TryGetComponent(out Transform resolvedTransform);
UnsupportedComponentLookupReturnedNull = !gameObject.TryGetComponent(out UnsupportedManagedComponent unsupportedComponent);
if (resolvedTransform != null)
{
resolvedTransform.localPosition = new Vector3(7.0f, 8.0f, 9.0f);
resolvedTransform.localRotation = new Quaternion(0.0f, 0.5f, 0.0f, 0.8660254f);
resolvedTransform.localScale = new Vector3(2.0f, 3.0f, 4.0f);
}
2026-03-26 22:10:43 +08:00
}
public void FixedUpdate()
{
FixedUpdateCount += 1;
ObservedFixedDeltaTime = Time.deltaTime;
2026-03-26 22:10:43 +08:00
}
public void Update()
{
UpdateCount += 1;
Speed += 1.0f;
ObservedUpdateDeltaTime = Time.deltaTime;
ObservedLocalPosition = transform.localPosition;
Quaternion rotation = transform.localRotation;
ObservedLocalRotation = new Vector4(rotation.x, rotation.y, rotation.z, rotation.w);
ObservedLocalScale = transform.localScale;
ObservedEnabled = enabled;
ObservedActiveSelf = gameObject.activeSelf;
ObservedActiveInHierarchy = gameObject.activeInHierarchy;
ObservedIsActiveAndEnabled = isActiveAndEnabled;
RotationAccessed = true;
ScaleAccessed = true;
TransformAccessed = true;
if (UpdateCount == 1)
{
if (DisableSelfOnFirstUpdate)
{
enabled = false;
}
if (DeactivateGameObjectOnFirstUpdate)
{
gameObject.SetActive(false);
}
}
2026-03-26 22:10:43 +08:00
}
public void LateUpdate()
{
LateUpdateCount += 1;
ObservedLateDeltaTime = Time.deltaTime;
Vector3 position = transform.localPosition;
position.x = position.x + 1.0f;
transform.localPosition = position;
ObservedLocalPosition = transform.localPosition;
Vector3 scale = transform.localScale;
scale.x = scale.x + 1.0f;
transform.localScale = scale;
ObservedLocalScale = transform.localScale;
SpawnPoint.x = SpawnPoint.x + 1.0f;
2026-03-26 22:10:43 +08:00
}
public void OnDisable()
{
DisableCount += 1;
}
public void OnDestroy()
{
DestroyCount += 1;
}
}
public sealed class UtilityHelper
{
public int Value;
}
}