コード例 #1
0
        public override void FindOutputs(Solver solver)
        {
            if (string.IsNullOrEmpty(outputASelector.name) || string.IsNullOrEmpty(outputBSelector.name))
            {
                return;
            }

            PowertrainComponent oa = solver.GetComponent(outputASelector.name);

            if (oa == null)
            {
                Debug.LogError($"Unknown component '{outputASelector.name}'");
                return;
            }

            outputA = oa;

            PowertrainComponent ob = solver.GetComponent(outputBSelector.name);

            if (ob == null)
            {
                Debug.LogError($"Unknown component '{outputBSelector.name}'");
                return;
            }

            outputB = ob;
        }
コード例 #2
0
        public void SetOutput(PowertrainComponent outputComponent)
        {
            if (string.IsNullOrEmpty(outputComponent.name))
            {
                Debug.LogWarning("Trying to set powertrain component output to a nameless component. " +
                                 "Output will be set to [none]");
            }

            SetOutput(outputComponent.name);
        }
コード例 #3
0
        /// <summary>
        ///     Retrieves and sets output powertrain components.
        /// </summary>
        /// <param name="solver"></param>
        public virtual void FindOutputs(Solver solver)
        {
            if (string.IsNullOrEmpty(outputASelector.name))
            {
                return;
            }

            PowertrainComponent output = solver.GetComponent(outputASelector.name);

            if (output == null)
            {
                Debug.LogError($"Unknown component '{outputASelector.name}'");
                return;
            }

            outputA = output;
        }
コード例 #4
0
        /// <summary>
        ///     Finds which powertrain component has its output set to this component.
        /// </summary>
        public virtual void FindInput(Solver solver)
        {
            List <PowertrainComponent> outputs = new List <PowertrainComponent>();

            foreach (PowertrainComponent component in solver.Components)
            {
                component.GetAllOutputs(ref outputs);
                foreach (PowertrainComponent output in outputs)
                {
                    if (output != null && output == this)
                    {
                        input        = component;
                        _inputIsNull = false;
                        return;
                    }
                }
            }

            input        = null;
            _inputIsNull = true;
        }
コード例 #5
0
 public void RemoveComponent(PowertrainComponent i)
 {
     _components.Remove(i);
 }
コード例 #6
0
 public void AddComponent(PowertrainComponent i)
 {
     _components.Add(i);
 }
コード例 #7
0
 public DifferentialComponent(string name, PowertrainComponent outputA, PowertrainComponent outputB)
 {
     this.name    = name;
     this.outputA = outputA;
     this.outputB = outputB;
 }