Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(campfire): add particle effects for campfire #40

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion assets/prefabs/blocks/CampFire.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"paragraphText": [
"The camp fire lights up a bigger area than just a torch."
]
}
},
"Campfire": {}
}
27 changes: 27 additions & 0 deletions assets/prefabs/particles/flames.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"location": {},
"particleDataSprite": {
"texture": "ManualLabor:fx_flame"
},
"energyRangeGenerator": {
"minEnergy": 0.5,
"maxEnergy": 2
},
"scaleRangeGenerator": {
"minScale": [0.01, 0.01, 0.01],
"maxScale": [0.5, 0.5, 0.5]
},
"velocityRangeGenerator": {
"minVelocity": [0, 0.5, 0],
"maxVelocity": [0.4, 2, 0.4]
},
"velocityAffector": {},
"particleEmitter": {
"spawnRateMax": 20,
"spawnRateMin": 10,
"maxParticles": 100,
"particleCollision": false,
"destroyEntityWhenDead": true
},
"network": {}
}
27 changes: 27 additions & 0 deletions assets/prefabs/particles/smoke.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"location": {},
"particleDataSprite": {
"texture": "ManualLabor:fx_smoke"
},
"energyRangeGenerator": {
"minEnergy": 0.5,
"maxEnergy": 4
},
"scaleRangeGenerator": {
"minScale": [0.01, 0.01, 0.01],
"maxScale": [0.5, 0.5, 0.5]
},
"velocityRangeGenerator": {
"minVelocity": [0, 0.3, 0],
"maxVelocity": [0.4, 1, 0.4]
},
"velocityAffector": {},
"particleEmitter": {
"spawnRateMax": 20,
"spawnRateMin": 10,
"maxParticles": 100,
"particleCollision": false,
"destroyEntityWhenDead": true
},
"network": {}
}
Binary file added assets/textures/particles/fx_flame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/particles/fx_smoke.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

package org.terasology.manualLabor.particles;

import org.terasology.entitySystem.Component;

Check warning on line 6 in src/main/java/org/terasology/manualLabor/particles/CampfireComponent.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: package org.terasology.entitySystem does not exist
import org.terasology.entitySystem.Owns;

Check warning on line 7 in src/main/java/org/terasology/manualLabor/particles/CampfireComponent.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: package org.terasology.entitySystem does not exist
import org.terasology.entitySystem.entity.EntityRef;

Check warning on line 8 in src/main/java/org/terasology/manualLabor/particles/CampfireComponent.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: package org.terasology.entitySystem.entity does not exist

public class CampfireComponent implements Component {

Check warning on line 10 in src/main/java/org/terasology/manualLabor/particles/CampfireComponent.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: cannot find symbol
@Owns
EntityRef flameEmitter = EntityRef.NULL;

Check warning on line 12 in src/main/java/org/terasology/manualLabor/particles/CampfireComponent.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: cannot find symbol
@Owns
EntityRef smokeEmitter = EntityRef.NULL;

Check warning on line 14 in src/main/java/org/terasology/manualLabor/particles/CampfireComponent.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: cannot find symbol
@Owns
EntityRef lightEmitter = EntityRef.NULL;

Check warning on line 16 in src/main/java/org/terasology/manualLabor/particles/CampfireComponent.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: cannot find symbol

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

package org.terasology.manualLabor.particles;

import org.joml.Vector3f;
import org.terasology.entitySystem.entity.EntityBuilder;

Check warning on line 7 in src/main/java/org/terasology/manualLabor/particles/CampfireParticleSystem.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: package org.terasology.entitySystem.entity does not exist
import org.terasology.entitySystem.entity.EntityManager;

Check warning on line 8 in src/main/java/org/terasology/manualLabor/particles/CampfireParticleSystem.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: package org.terasology.entitySystem.entity does not exist
import org.terasology.entitySystem.entity.EntityRef;

Check warning on line 9 in src/main/java/org/terasology/manualLabor/particles/CampfireParticleSystem.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: package org.terasology.entitySystem.entity does not exist
import org.terasology.entitySystem.entity.lifecycleEvents.BeforeDeactivateComponent;

Check warning on line 10 in src/main/java/org/terasology/manualLabor/particles/CampfireParticleSystem.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: package org.terasology.entitySystem.entity.lifecycleEvents does not exist
import org.terasology.entitySystem.entity.lifecycleEvents.OnAddedComponent;

Check warning on line 11 in src/main/java/org/terasology/manualLabor/particles/CampfireParticleSystem.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: package org.terasology.entitySystem.entity.lifecycleEvents does not exist
import org.terasology.entitySystem.event.ReceiveEvent;

Check warning on line 12 in src/main/java/org/terasology/manualLabor/particles/CampfireParticleSystem.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: package org.terasology.entitySystem.event does not exist
import org.terasology.entitySystem.systems.BaseComponentSystem;

Check warning on line 13 in src/main/java/org/terasology/manualLabor/particles/CampfireParticleSystem.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: package org.terasology.entitySystem.systems does not exist
import org.terasology.entitySystem.systems.RegisterMode;

Check warning on line 14 in src/main/java/org/terasology/manualLabor/particles/CampfireParticleSystem.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: package org.terasology.entitySystem.systems does not exist
import org.terasology.entitySystem.systems.RegisterSystem;

Check warning on line 15 in src/main/java/org/terasology/manualLabor/particles/CampfireParticleSystem.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: package org.terasology.entitySystem.systems does not exist
import org.terasology.logic.location.LocationComponent;

Check warning on line 16 in src/main/java/org/terasology/manualLabor/particles/CampfireParticleSystem.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: package org.terasology.logic.location does not exist
import org.terasology.particles.components.ParticleEmitterComponent;

Check warning on line 17 in src/main/java/org/terasology/manualLabor/particles/CampfireParticleSystem.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: package org.terasology.particles.components does not exist
import org.terasology.registry.In;

Check warning on line 18 in src/main/java/org/terasology/manualLabor/particles/CampfireParticleSystem.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: package org.terasology.registry does not exist
import org.terasology.world.block.BlockComponent;

Check warning on line 19 in src/main/java/org/terasology/manualLabor/particles/CampfireParticleSystem.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: package org.terasology.world.block does not exist

@RegisterSystem(RegisterMode.ALWAYS)

Check warning on line 21 in src/main/java/org/terasology/manualLabor/particles/CampfireParticleSystem.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: cannot find symbol
public class CampfireParticleSystem extends BaseComponentSystem {

Check warning on line 22 in src/main/java/org/terasology/manualLabor/particles/CampfireParticleSystem.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: cannot find symbol

@In
EntityManager entityManager;

Check warning on line 25 in src/main/java/org/terasology/manualLabor/particles/CampfireParticleSystem.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: cannot find symbol

@ReceiveEvent(components = {BlockComponent.class})
public void onActivate(OnAddedComponent event, EntityRef entity, LocationComponent location,

Check warning on line 28 in src/main/java/org/terasology/manualLabor/particles/CampfireParticleSystem.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: cannot find symbol
CampfireComponent campfire) {
Vector3f loc = location.getWorldPosition(new Vector3f());
campfire.flameEmitter = createEmitter(entity, loc, "ManualLabor:flames");
loc.add(0, 1, 0);
campfire.smokeEmitter = createEmitter(entity, loc, "ManualLabor:smoke");
entity.saveComponent(campfire);
}

@ReceiveEvent
public void onDestroy(BeforeDeactivateComponent event, EntityRef entity, CampfireComponent campfire) {

Check warning on line 38 in src/main/java/org/terasology/manualLabor/particles/CampfireParticleSystem.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: cannot find symbol
campfire.smokeEmitter.destroy();
campfire.flameEmitter.destroy();
campfire.lightEmitter.destroy();
}

private EntityRef createEmitter(EntityRef entity, Vector3f location, String prefabName) {

Check warning on line 44 in src/main/java/org/terasology/manualLabor/particles/CampfireParticleSystem.java

View check run for this annotation

Terasology Jenkins.io / Java Compiler

ERROR: cannot find symbol
EntityBuilder builder = entityManager.newBuilder(prefabName);
builder.updateComponent(LocationComponent.class, l -> {
l.setWorldPosition(new Vector3f(location));
return l;
});
builder.updateComponent(ParticleEmitterComponent.class, emitter -> {
emitter.ownerEntity = entity;
return emitter;
});
builder.setOwner(entity);
return builder.build();
}
}
Loading