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