Beispiel #1
0
    protected override void implementation_setSimulationFromLogic(
        ISimulatableLogic inLogicToSetFrom)
    {
        CarPhysicsLogic theLogicToSetFrom = inLogicToSetFrom as CarPhysicsLogic;

        if (!theLogicToSetFrom)
        {
            //TODO: Make universal though for incorrect type casts
            throw new Exception("Simulation object has no compitable simulatable logic");
        }
        GameObject theGameObjectToSetFrom = theLogicToSetFrom.gameObject;

        //Set rigid body
        var theRigidBodyToSetFrom = theGameObjectToSetFrom.GetComponent <Rigidbody2D>();

        _rigidBody.angularVelocity = theRigidBodyToSetFrom.angularVelocity;
        _rigidBody.velocity        = theRigidBodyToSetFrom.velocity;

        //Set logic state
        _gasValue = theLogicToSetFrom._gasValue;
        _isGasWasChangedOnUpdate = theLogicToSetFrom._isGasWasChangedOnUpdate;

        _steeringWheelValue = theLogicToSetFrom._steeringWheelValue;
        _isSteeringWheelWasRotatedOnUpdate = theLogicToSetFrom._isSteeringWheelWasRotatedOnUpdate;
    }
Beispiel #2
0
 protected void implementation_initialize_state()
 {
     _gasValue           = new LimitedFloat(GasValueSettings);
     _steeringWheelValue = new LimitedFloatAngle(SteeringWheelValueSettings);
 }