2024-02-25 14:46:47 +00:00
|
|
|
#pragma once
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
#include "StarItem.hpp"
|
|
|
|
#include "StarFireableItem.hpp"
|
|
|
|
#include "StarBeamItem.hpp"
|
|
|
|
#include "StarEntityRendering.hpp"
|
2023-08-19 10:47:58 +00:00
|
|
|
#include "StarPreviewTileTool.hpp"
|
|
|
|
#include "StarRenderableItem.hpp"
|
2023-08-20 08:56:50 +00:00
|
|
|
#include "StarPreviewableItem.hpp"
|
2023-08-19 10:47:58 +00:00
|
|
|
#include "StarCollisionBlock.hpp"
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
namespace Star {
|
|
|
|
|
|
|
|
STAR_CLASS(MaterialItem);
|
2023-08-20 08:56:50 +00:00
|
|
|
STAR_CLASS(Player);
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2023-08-20 08:56:50 +00:00
|
|
|
class MaterialItem : public Item, public FireableItem, public PreviewTileTool, public RenderableItem, public PreviewableItem, public BeamItem {
|
2023-06-20 04:33:09 +00:00
|
|
|
public:
|
|
|
|
MaterialItem(Json const& config, String const& directory, Json const& settings);
|
|
|
|
virtual ~MaterialItem() {}
|
|
|
|
|
|
|
|
ItemPtr clone() const override;
|
|
|
|
|
|
|
|
void init(ToolUserEntity* owner, ToolHand hand) override;
|
2023-07-31 06:41:12 +00:00
|
|
|
void uninit() override;
|
2023-07-20 14:58:49 +00:00
|
|
|
void update(float dt, FireMode fireMode, bool shifting, HashSet<MoveControlType> const& moves) override;
|
2023-08-19 10:47:58 +00:00
|
|
|
void render(RenderCallback* renderCallback, EntityRenderLayer renderLayer) override;
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2023-08-20 08:56:50 +00:00
|
|
|
virtual List<Drawable> preview(PlayerPtr const& viewer = {}) const override;
|
|
|
|
virtual List<Drawable> dropDrawables() const override;
|
2023-06-20 04:33:09 +00:00
|
|
|
List<Drawable> nonRotatedDrawables() const override;
|
|
|
|
|
|
|
|
void fire(FireMode mode, bool shifting, bool edgeTriggered) override;
|
2023-07-31 06:00:19 +00:00
|
|
|
void endFire(FireMode mode, bool shifting) override;
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
MaterialId materialId() const;
|
|
|
|
MaterialHue materialHueShift() const;
|
|
|
|
|
|
|
|
bool canPlace(bool shifting) const;
|
|
|
|
bool multiplaceEnabled() const;
|
|
|
|
|
2023-08-19 10:47:58 +00:00
|
|
|
float& blockRadius();
|
|
|
|
float& altBlockRadius();
|
|
|
|
TileCollisionOverride& collisionOverride();
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2023-08-20 08:56:50 +00:00
|
|
|
List<PreviewTile> previewTiles(bool shifting) const override;
|
|
|
|
List<Drawable> const& generatedPreview(Vec2I position = {}) const;
|
2023-06-20 04:33:09 +00:00
|
|
|
private:
|
2023-08-21 11:22:25 +00:00
|
|
|
void updatePropertiesFromPlayer(Player* player);
|
2023-08-19 10:47:58 +00:00
|
|
|
float calcRadius(bool shifting) const;
|
2023-08-19 11:35:56 +00:00
|
|
|
List<Vec2I>& tileArea(float radius, Vec2F const& position) const;
|
2023-06-20 04:33:09 +00:00
|
|
|
MaterialHue placementHueShift(Vec2I const& position) const;
|
|
|
|
|
|
|
|
MaterialId m_material;
|
|
|
|
MaterialHue m_materialHueShift;
|
|
|
|
|
|
|
|
float m_blockRadius;
|
|
|
|
float m_altBlockRadius;
|
|
|
|
bool m_shifting;
|
|
|
|
bool m_multiplace;
|
2023-08-18 13:14:53 +00:00
|
|
|
StringList m_placeSounds;
|
2023-07-31 06:00:19 +00:00
|
|
|
Maybe<Vec2F> m_lastAimPosition;
|
2023-08-19 10:47:58 +00:00
|
|
|
TileCollisionOverride m_collisionOverride;
|
|
|
|
|
2023-08-19 11:35:56 +00:00
|
|
|
mutable Vec2F m_lastTileAreaOriginCache;
|
2023-08-19 10:47:58 +00:00
|
|
|
mutable float m_lastTileAreaRadiusCache;
|
|
|
|
mutable List<Vec2I> m_tileAreasCache;
|
2023-08-20 08:56:50 +00:00
|
|
|
|
|
|
|
mutable Maybe<List<Drawable>> m_generatedPreviewCache;
|
2023-06-20 04:33:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|