//--Internal private void setSimulationFromLogic_internal(ISimulatableLogic inLogicToSetFrom) { //if (!isSimulation()) { // throw new Exception("Try to setup object as simulation"); //} implementation_setSimulationFromLogic(inLogicToSetFrom); }
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; }
protected abstract void implementation_setSimulationFromLogic(ISimulatableLogic inLogicToSetFrom);
public void setSimulationFrom(ISimulatableLogic inLogicToSetFrom) { setSimulationFromLogic_internal(inLogicToSetFrom); }
void Start() { _simulatableLogic = gameObject.GetComponent <ISimulatableLogic>(); _simulatableLogic.initialize(); }