Exemplo n.º 1
0
        /// <summary>
        ///     First function that gets called on all components.
        ///     VehicleController reference will be null before this function is called.
        /// </summary>
        public virtual void Awake(VehicleController vc)
        {
            this.vc      = vc;
            initialized  = false;
            wasEnabled   = false;
            fullTypeName = GetType().FullName;

            if (state == null)
            {
                state = new StateDefinition();
            }

            state.fullName = fullTypeName;
            LoadStateFromDefinitionsFile(fullTypeName, ref state);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Loads state settings from StateSettings ScriptableObject.
        /// </summary>
        public void LoadStateFromDefinitionsFile(string fullTypeName, ref StateDefinition state)
        {
            if (vc.stateSettings == null)
            {
                return;
            }

            StateDefinition loadedState = vc.stateSettings.GetDefinition(fullTypeName);

            if (loadedState != null)
            {
                state.isOn      = loadedState.isOn;
                state.isEnabled = loadedState.isEnabled;
                state.lodIndex  = loadedState.lodIndex;
                state.fullName  = fullTypeName;
            }
            else
            {
                Debug.LogWarning(
                    $"State definition {fullTypeName} could not be loaded. Click on 'Refresh' button under Settings > State Settings.");
            }
        }