////////////////////////////////////////////////////////////////////////////////
//    Scorched3D (c) 2000-2011, 2025, 2026
//
//    This file is part of Scorched3D.
//
//    Scorched3D 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 2 of the License, or
//    (at your option) any later version.
//
//    Scorched3D 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, write to the Free Software Foundation, Inc.,
//    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
////////////////////////////////////////////////////////////////////////////////

#ifndef __INCLUDE_WeaponRoller_hpp_INCLUDE__
#define __INCLUDE_WeaponRoller_hpp_INCLUDE__

#include <weapons/Weapon.hpp>
#include <common/ModelID.hpp>
#include <engine/ObjectGroupEntryDefinition.hpp>

class ScorchedContext;

class WeaponRoller : public Weapon
{
public:
	WeaponRoller();
	virtual ~WeaponRoller();

	virtual bool parseXML( AccessoryCreateContext& context, XMLNode* accessoryNode );

	// clang-format off
	// uncrustify off
	Weapon*  getCollisionAction()                            { return collisionAction_; }
	ModelID& getRollerModelID()                              { return rollerModelId_; }
	bool     getRoll()                                       { return roll_; }
	bool     getStickyShields()                              { return stickyShields_; }
	bool     getNoCameraTrack()                              { return noCameraTrack_; }
	bool     getLandscapeCollision()                         { return landscapeCollision_; }
	bool     getShieldCollision()                            { return shieldCollision_; }
	bool     getTankCollision()                              { return tankCollision_; }
	bool     getTargetCollision()                            { return targetCollision_; }
	fixed    getShieldHurtFactor( ScorchedContext& context ) { return shieldHurtFactorExp_.getValue( context ); }
	fixed    getTime( ScorchedContext& context )             { return timeExp_.getValue( context ); }
	fixed    getWindFactor( ScorchedContext& context )       { return windFactorExp_.getValue( context ); }
	fixed    getGravityFactor( ScorchedContext& context )    { return gravityFactorExp_.getValue( context ); }
	fixed    getStepSize()                                   { return stepSize_; }
	fixed    getScale( ScorchedContext& context )            { return scale_.getValue( context ); }
	fixed    getTimeout( ScorchedContext& context )          { return timeout_.getValue( context ); }

	ObjectGroupEntryDefinition& getLocalGroups()  { return localGroups_; }
	ObjectGroupEntryDefinition& getGlobalGroups() { return globalGroups_; }
	// uncrustify on
	// clang-format on

	// Inherited from Weapon
	virtual void fireWeapon(
		ScorchedContext&   context,
		WeaponFireContext& weaponContext,
		FixedVector&       position,
		FixedVector&       velocity
	);

	REGISTER_ACCESSORY_HEADER( WeaponRoller, AccessoryPart::AccessoryWeapon );

protected:
	Weapon*                    collisionAction_;
	ModelID                    rollerModelId_;
	ObjectGroupEntryDefinition localGroups_;
	ObjectGroupEntryDefinition globalGroups_;
	NumberParser               shieldHurtFactorExp_;
	NumberParser               windFactorExp_;
	NumberParser               gravityFactorExp_;
	NumberParser               dampenVelocityExp_;
	NumberParser               timeout_;
	NumberParser               scale_;
	NumberParser               timeExp_;
	NumberParser               numberRollers_;
	fixed                      stepSize_;
	bool                       maintainVelocity_;
	bool                       roll_;
	bool                       stickyShields_;
	bool                       landscapeCollision_;
	bool                       shieldCollision_;
	bool                       tankCollision_;
	bool                       targetCollision_;
	bool                       noCameraTrack_;

	void addRoller(
		ScorchedContext&   context,
		WeaponFireContext& weaponContext,
		FixedVector&       position,
		FixedVector&       velocity
	);
};

#endif  // __INCLUDE_WeaponRoller_hpp_INCLUDE__
