1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#pragma once
#include "StarNetElementSystem.hpp"
#include "StarMovementController.hpp"
#include "StarPlant.hpp"
#include "StarAssetPath.hpp"
namespace Star {
STAR_CLASS(RenderCallback);
STAR_CLASS(PlantDrop);
class PlantDrop : public virtual Entity {
public:
PlantDrop(List<Plant::PlantPiece> pieces, Vec2F const& position, Vec2F const& strikeVector, String const& description,
bool upsideDown, Json stemConfig, Json foliageConfig, Json saplingConfig,
bool master, float random);
PlantDrop(ByteArray const& netStore, NetCompatibilityRules rules = {});
ByteArray netStore(NetCompatibilityRules rules = {});
EntityType entityType() const override;
void init(World* world, EntityId entityId, EntityMode mode) override;
void uninit() override;
String description() const override;
pair<ByteArray, uint64_t> writeNetState(uint64_t fromVersion = 0, NetCompatibilityRules rules = {}) override;
void readNetState(ByteArray data, float interpolationTime = 0.0f, NetCompatibilityRules rules = {}) override;
void enableInterpolation(float extrapolationHint = 0.0f) override;
void disableInterpolation() override;
Vec2F position() const override;
RectF metaBoundBox() const override;
bool shouldDestroy() const override;
void destroy(RenderCallback* renderCallback) override;
void setPosition();
void setVelocity(Vec2F const& position);
RectF collisionRect() const;
void update(float dt, uint64_t currentStep) override;
void render(RenderCallback* renderCallback) override;
private:
struct PlantDropPiece {
PlantDropPiece();
AssetPath image;
Vec2F offset;
int segmentIdx;
Plant::PlantPieceKind kind;
bool flip;
};
void particleForPlantPart(PlantDropPiece const& piece, String const& mode, Json const& mainConfig, RenderCallback* renderCallback);
NetElementTopGroup m_netGroup;
String m_description;
float m_time;
MovementController m_movementController;
RectF m_collisionRect;
RectF m_boundingBox;
float m_rotationRate;
float m_rotationFallThreshold;
float m_rotationCap;
List<PlantDropPiece> m_pieces;
Json m_stemConfig;
Json m_foliageConfig;
Json m_saplingConfig;
bool m_master;
bool m_firstTick;
NetElementBool m_spawnedDrops;
bool m_spawnedDropEffects;
};
}
|