/*
    Open1560 - An Open Source Re-Implementation of Midtown Madness 1 Beta
    Copyright (C) 2020 Brick

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "arts7/node.h"

class mmCarSim;

class mmTransmission final : public asNode
{
public:
    // ??0mmTransmission@@QAE@XZ
    ARTS_IMPORT mmTransmission();

    // ??1mmTransmission@@UAE@XZ | inline
    ARTS_EXPORT ~mmTransmission() override = default;

#ifdef ARTS_DEV_BUILD
    // ?AddWidgets@mmTransmission@@UAEXPAVBank@@@Z
    ARTS_IMPORT void AddWidgets(Bank* arg1) override;
#endif

    // ?Automatic@mmTransmission@@QAEXH@Z
    ARTS_IMPORT void Automatic(i32 arg1);

    // ?CopyTrans@mmTransmission@@QAEXXZ
    ARTS_IMPORT void CopyTrans();

    // ?Downshift@mmTransmission@@QAEHXZ
    ARTS_IMPORT i32 Downshift();

    // ?GetClass@mmTransmission@@UAEPAVMetaClass@@XZ
    ARTS_IMPORT MetaClass* GetClass() override;

    // ?GetCurrentGear@mmTransmission@@QAEHXZ
    ARTS_IMPORT i32 GetCurrentGear();

    // ?Init@mmTransmission@@QAEXPAVmmCarSim@@@Z
    ARTS_IMPORT void Init(mmCarSim* arg1);

    // ?Reset@mmTransmission@@UAEXXZ
    ARTS_IMPORT void Reset() override;

    // ?SetCurrentGear@mmTransmission@@QAEHH@Z
    ARTS_IMPORT i32 SetCurrentGear(i32 arg1);

    // ?SetDrive@mmTransmission@@QAEXXZ
    ARTS_IMPORT void SetDrive();

    // ?SetReverse@mmTransmission@@QAEXXZ
    ARTS_IMPORT void SetReverse();

    // ?Update@mmTransmission@@UAEXXZ
    ARTS_IMPORT void Update() override;

    // ?Upshift@mmTransmission@@QAEHXZ
    ARTS_IMPORT i32 Upshift();

    // ?DeclareFields@mmTransmission@@SAXXZ
    ARTS_IMPORT static void DeclareFields();

    bool IsReverse() const
    {
        return CurrentGear == 0;
    }

    bool IsNeutral() const
    {
        return CurrentGear == 1;
    }

    bool IsForward() const
    {
        return CurrentGear >= 2;
    }

    mmCarSim* CarSim;
    b32 IsAutomatic;
    f32 Clutch;
    f32 UpshiftThreshold;
    f32 DownshiftThreshold;
    i32 NumGears;
    f32 GearRatios[8];
    f32 UpshiftRPM[8];
    f32 DownshiftRPM[8];
    f32 ManualGearRatios[8];
    i32 ManualNumGears;
    f32 DownshiftBias;
    b32 GearChanged;
    b32 InPark;
    i32 CurrentGear;
    f32 TimeInGear;
    f32 GearChangeDelay;
};

check_size(mmTransmission, 0xD4);

// ?ArrayOf@@YAPAUMetaType@@PAU1@H@Z | inline
// ARTS_IMPORT MetaType* ArrayOf(MetaType* arg1, i32 arg2);
