Fix particles finally
This commit is contained in:
parent
ec9a138e1a
commit
d5d474c673
@ -43,7 +43,7 @@ void Animation::setAngle(float angle) {
|
||||
m_angle = angle;
|
||||
}
|
||||
|
||||
void Animation::setProcessing(Directives processing) {
|
||||
void Animation::setProcessing(DirectivesGroup processing) {
|
||||
m_processing = move(processing);
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ Drawable Animation::drawable(float pixelSize) const {
|
||||
baseFrame += ":" + toString(m_frame);
|
||||
|
||||
Drawable drawable = Drawable::makeImage(move(baseFrame), pixelSize, m_centered, m_offset);
|
||||
drawable.imagePart().addDirectives(m_processing);
|
||||
drawable.imagePart().addDirectivesGroup(m_processing);
|
||||
drawable.rotate(m_angle);
|
||||
drawable.color = m_color;
|
||||
return drawable;
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
|
||||
void setAngle(float angle);
|
||||
|
||||
void setProcessing(Directives processing);
|
||||
void setProcessing(DirectivesGroup processing);
|
||||
|
||||
void setColor(Color color);
|
||||
|
||||
@ -43,7 +43,7 @@ private:
|
||||
float m_angle;
|
||||
Vec2F m_offset;
|
||||
bool m_centered;
|
||||
Directives m_processing;
|
||||
DirectivesGroup m_processing;
|
||||
Color m_color;
|
||||
int m_variantOffset;
|
||||
|
||||
|
@ -66,14 +66,16 @@ Particle::Particle(Json const& config, String const& path) {
|
||||
if (type == Type::Textured || type == Type::Animated)
|
||||
string = AssetPath::relativeTo(path, string);
|
||||
|
||||
if (type == Type::Animated)
|
||||
initializeAnimation();
|
||||
image = string;
|
||||
|
||||
auto pathEnd = string.find('?');
|
||||
if (pathEnd == NPos)
|
||||
directives = "";
|
||||
else
|
||||
directives.parse(string.substr(pathEnd));
|
||||
if (type == Type::Animated) {
|
||||
auto pathEnd = string.find('?');
|
||||
if (pathEnd == NPos)
|
||||
directives.clear();
|
||||
else
|
||||
directives = string.substr(pathEnd);
|
||||
initializeAnimation();
|
||||
}
|
||||
|
||||
if (config.contains("color"))
|
||||
color = jsonToColor(config.get("color"));
|
||||
|
@ -77,7 +77,7 @@ struct Particle {
|
||||
// Used differently depending on the type of the particle.
|
||||
String string;
|
||||
AssetPath image;
|
||||
Directives directives;
|
||||
DirectivesGroup directives;
|
||||
|
||||
Color color;
|
||||
Color light;
|
||||
|
@ -773,8 +773,10 @@ void Plant::render(RenderCallback* renderCallback) {
|
||||
continue;
|
||||
auto particle = Root::singleton().particleDatabase()->particle(config);
|
||||
particle.color.hueShift(hueshift);
|
||||
if (!particle.string.empty())
|
||||
if (!particle.string.empty()) {
|
||||
particle.string = strf("%s?hueshift=%s", particle.string, hueshift);
|
||||
particle.image = particle.string;
|
||||
}
|
||||
particle.position = {m_tileDamageX + Random::randf(), m_tileDamageY + Random::randf()};
|
||||
particle.translate(position());
|
||||
renderCallback->addParticle(move(particle));
|
||||
|
@ -279,8 +279,8 @@ void PlantDrop::particleForPlantPart(PlantDropPiece const& piece, String const&
|
||||
|
||||
particle = Root::singleton().particleDatabase()->particle(config);
|
||||
particle.color.hueShift(mainConfig.getFloat("hueshift", 0) / 360.0f);
|
||||
if (!particle.string.empty())
|
||||
particle.string += AssetPath::getDirectives(piece.image);
|
||||
for (Directives const& directives : piece.image.directives.list())
|
||||
particle.directives.append(directives);
|
||||
|
||||
density--;
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "StarNetElementSystem.hpp"
|
||||
#include "StarMovementController.hpp"
|
||||
#include "StarPlant.hpp"
|
||||
#include "StarAssetPath.hpp"
|
||||
|
||||
namespace Star {
|
||||
|
||||
@ -50,7 +51,7 @@ public:
|
||||
private:
|
||||
struct PlantDropPiece {
|
||||
PlantDropPiece();
|
||||
String image;
|
||||
AssetPath image;
|
||||
Vec2F offset;
|
||||
int segmentIdx;
|
||||
Plant::PlantPieceKind kind;
|
||||
|
@ -401,7 +401,7 @@ void WorldClient::render(WorldRenderData& renderData, unsigned bufferTiles) {
|
||||
if (directives) {
|
||||
int directiveIndex = unsigned(entity->entityId()) % directives->size();
|
||||
for (auto& p : renderCallback.particles)
|
||||
p.directives = directives->get(directiveIndex);
|
||||
p.directives.append(directives->get(directiveIndex));
|
||||
}
|
||||
|
||||
m_particles->addParticles(move(renderCallback.particles));
|
||||
@ -1273,7 +1273,7 @@ void WorldClient::handleDamageNotifications() {
|
||||
if (directives) {
|
||||
int directiveIndex = unsigned(damageNotification.targetEntityId) % directives->size();
|
||||
for (auto& p : hitParticles)
|
||||
p.directives = directives->get(directiveIndex);
|
||||
p.directives.append(directives->get(directiveIndex));
|
||||
}
|
||||
|
||||
m_particles->addParticles(hitParticles);
|
||||
@ -1343,7 +1343,7 @@ void WorldClient::removeEntity(EntityId entityId, bool andDie) {
|
||||
if (directives) {
|
||||
int directiveIndex = unsigned(entity->entityId()) % directives->size();
|
||||
for (auto& p : renderCallback.particles)
|
||||
p.directives = directives->get(directiveIndex);
|
||||
p.directives.append(directives->get(directiveIndex));
|
||||
}
|
||||
|
||||
m_particles->addParticles(move(renderCallback.particles));
|
||||
|
@ -189,7 +189,7 @@ void WorldPainter::renderParticles(WorldRenderData& renderData, Particle::Layer
|
||||
if (particle.flip && particle.flippable)
|
||||
drawable.scale(Vec2F(-1, 1));
|
||||
if (drawable.isImage())
|
||||
drawable.imagePart().addDirectives(particle.directives, true);
|
||||
drawable.imagePart().addDirectivesGroup(particle.directives, true);
|
||||
drawable.fullbright = particle.fullbright;
|
||||
drawable.color = particle.color;
|
||||
drawable.rotate(particle.rotation);
|
||||
|
Loading…
Reference in New Issue
Block a user