Пример #1
0
        public override void Start() //TODO register into a list for AI and stuff
        {
            base.Start();

            //TODO may remove some warnings, TODO change to Debug.Log

            if (AnimationComponent == null)
            {
                AnimationComponent = GetComponent <ActorAnimationComponentBase>();
            }
            if (AnimationComponent == null)
            {
                CDebug.LogEx(name + " couldn't find AnimationComponent", LogLevel.Warning, this);
            }

            if (MovementComponent == null)
            {
                MovementComponent = GetComponent <ActorMovementComponentBase>();
            }
            if (MovementComponent == null)
            {
                CDebug.LogEx(name + " couldn't find MovementComponent", LogLevel.Error, this);
            }

            if (AttackComponent == null)
            {
                AttackComponent = GetComponent <ActorAttackComponent>();
            }
            if (AttackComponent == null)
            {
                CDebug.LogEx(name + " couldn't find AttackComponent", LogLevel.Warning, this);
            }

            if (InteractionComponent == null)
            {
                InteractionComponent = GetComponent <ActorInteractionComponent>();
            }
            if (InteractionComponent == null)
            {
                CDebug.LogEx(name + " couldn't find InteractionComponent", LogLevel.Warning, this);
            }

            if (AudioComponent == null)
            {
                AudioComponent = GetComponentInChildren <ActorAudioComponent>();
            }
            if (AudioComponent == null)
            {
                CDebug.LogEx(name + " couldn't find AudioComponent", LogLevel.Verbose, this);
            }

            InitialPosition = transform.position;

            MovementComponent.Init();

            if (InteractComponent == null)
            {
                InteractComponent = GetComponent <ActorInteractableComponent>();
            }

            if (InteractComponent == null)
            {
                InteractComponent = GetComponentInChildren <ActorInteractableComponent>();
            }

            InteractionComponent.Ref()?.Init();

            if (InteractComponent != null && InteractionComponent != null)
            {
                InteractComponent.ControllerOnInteractDelegate = InteractionComponent.OnInteract;
                InteractComponent.Tooltip = InteractionComponent.Tooltip;
                //TODO may move this to ActorInteractionComponent
            }
            else
            {
                CDebug.LogEx(name + " couldn't find ActorInteractableComponent", LogLevel.Error, this);
            }

            MaxHealth = Health;

            AnimationComponent.Init();
            EnterState(CurrentAiState);
        }