예제 #1
0
        public override async UniTask Init(CancellationToken ct)
        {
            if (AttachedObject == null)
            {
                DebugLog.ToConsole($"Error - AttachedObject is null! Type:{GetType().Name}", OWML.Common.MessageType.Error);
                return;
            }

            await UniTask.WaitUntil(() => QSBWorldSync.AllObjectsAdded, cancellationToken : ct);

            InitialParent   = AttachedObject.transform.parent;
            InitialPosition = AttachedObject.transform.localPosition;
            InitialRotation = AttachedObject.transform.localRotation;
            var initialSector = AttachedObject.GetSector();

            if (initialSector != null)
            {
                InitialSector = initialSector.GetWorldObject <QSBSector>();
            }

            if (InitialParent == null)
            {
                DebugLog.ToConsole($"Warning - InitialParent of {AttachedObject.name} is null!", OWML.Common.MessageType.Warning);
            }

            if (InitialParent?.GetComponent <OWItemSocket>() != null)
            {
                var qsbObj = InitialParent.GetComponent <OWItemSocket>().GetWorldObject <QSBItemSocket>();
                InitialSocket = qsbObj;
            }

            QSBPlayerManager.OnRemovePlayer += OnPlayerLeave;
        }