Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/game/StarParticleDatabase.hpp
blob: 81c38e7f87077c788ba9c1253041273799f002eb (plain)
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
#pragma once

#include "StarJson.hpp"
#include "StarThread.hpp"
#include "StarParticle.hpp"

namespace Star {

STAR_CLASS(ParticleConfig);
STAR_CLASS(ParticleDatabase);

class ParticleConfig {
public:
  ParticleConfig(Json const& config);

  String const& kind();
  Particle instance();

private:
  String m_kind;
  Particle m_particle;
  Particle m_variance;
};

class ParticleDatabase {
public:
  ParticleDatabase();

  ParticleConfigPtr config(String const& kind) const;

  // If the given variant is a string, loads the particle of that kind,
  // otherwise loads the given config directly.  If the config is given
  // directly it is assumed to optionally contain the variance config in-line.
  ParticleVariantCreator particleCreator(Json const& kindOrConfig, String const& relativePath = "") const;

  // Like particleCreator except just returns a single particle.  Probably not
  // what you want if you want to support particle variance.
  Particle particle(Json const& kindOrConfig, String const& relativePath = "") const;

private:
  StringMap<ParticleConfigPtr> m_configs;
};

}