コード例 #1
0
        public override void Initialize()
        {
            _prefabIdentifier = GetComponent <PrefabIdentifier>().Id ?? GetComponentInParent <PrefabIdentifier>().Id;
            _spinTitle        = Animator.StringToHash("SpinTitle");

            var target = gameObject.FindChild("targetPos");

            if (target == null)
            {
                QuickLogger.Error("Cant find trigger targetPos");
                return;
            }

            if (_buildable == null)
            {
                _buildable = GetComponentInParent <Constructable>() ?? GetComponent <Constructable>();
            }

            if (ColorManager == null)
            {
                ColorManager = new ColorManager();
            }

            ColorManager.Initialize(gameObject, QuantumTeleporterBuildable.BodyMaterial);

            TeleportManager.Initialize();

            if (NameController == null)
            {
                NameController = gameObject.EnsureComponent <NameController>();
            }


            if (AnimationManager == null)
            {
                AnimationManager = gameObject.GetComponent <AnimationManager>();
            }

            if (DisplayManager == null)
            {
                DisplayManager = gameObject.GetComponent <QTDisplayManager>();
            }

            if (SubRoot == null)
            {
                SubRoot = GetComponentInParent <SubRoot>();
            }

            if (Manager == null)
            {
                Manager = BaseManager.FindManager(SubRoot);
            }

            if (AudioManager == null)
            {
                AudioManager = new AudioManager(gameObject.GetComponent <FMOD_CustomLoopingEmitter>());
            }

            AudioManager.LoadFModAssets("/env/use_teleporter_use_loop", "use_teleporter_use_loop");

            if (PowerManager == null)
            {
                PowerManager = new QTPowerManager(this);
            }

            //var pingInstance = gameObject.GetComponent<PingInstance>() ??
            //                   gameObject.GetComponentInChildren<PingInstance>();

            //if (QTPingManager == null)
            //    QTPingManager = new QTPingManager();

            //QTPingManager.Initialize(pingInstance);

            DisplayManager.Setup(this);

            NameController.Initialize(QuantumTeleporterBuildable.Submit(), Mod.FriendlyName);
            NameController.SetCurrentName(GetNewName(), DisplayManager.GetNameTextBox());
            NameController.OnLabelChanged += OnLabelChanged;
            Manager.OnBaseUnitsChanged    += OnBaseUnitsChanged;
            AddToManager();

            AnimationManager.SetBoolHash(_spinTitle, true);

            if (QTDoorManager == null)
            {
                QTDoorManager = gameObject.FindChild("model").FindChild("anims").FindChild("door").AddComponent <QTDoorManager>();
            }
            QTDoorManager.Initalize(this);

            var trigger = target.AddComponent <QTTriggerBoxManager>();

            trigger.OnPlayerExit += QTDoorManager.OnPlayerExit;
            _target = target.transform;

            IsInitialized = true;
        }