fun: blood

This commit is contained in:
cha0s 2019-11-06 00:25:30 -06:00
parent dd001cfdce
commit ea504785dc

View File

@ -13,7 +13,7 @@ import {DamagePacket} from './damage.packet';
export class Vulnerable extends Trait { export class Vulnerable extends Trait {
static defaultParams() { static defaultParams() {
const emitDamage = buildInvoke(['entity', 'emitDamageParticle'], [ const emitDamage = buildInvoke(['entity', 'emitDamageParticles'], [
buildTraversal(['damage']), buildTraversal(['damage']),
]); ]);
const playDamagingSound = buildInvoke(['damage', 'from', 'playSound'], [ const playDamagingSound = buildInvoke(['damage', 'from', 'playSound'], [
@ -163,7 +163,57 @@ export class Vulnerable extends Trait {
}, },
}, },
}, },
} blood: {
traits: {
emitted: {
params: {
alpha: {
start: 1,
end: 0.4,
},
force: [0, 4],
velocity: {
min: [-0.5, -1.25],
max: [0.5, -0.75],
},
scale: {
start: 1,
end: 1.25,
},
transient: false,
ttl: 0.5,
},
},
existent: {},
layered: {},
listed: {},
perishable: {
params: {
ttl: 10,
},
},
positioned: {},
primitive: {
params: {
primitives: [
{
type: 'circle',
radius: 0.5,
line: {
rgba: [255, 0, 0],
},
fill: {
rgba: [255, 0, 0],
},
},
],
},
},
roomed: {},
visible: {},
},
},
};
}, },
@ -190,7 +240,7 @@ export class Vulnerable extends Trait {
methods() { methods() {
return { return {
emitDamageParticle: (damage) => { emitDamageParticles: (damage) => {
const {amount, isDamage} = damage; const {amount, isDamage} = damage;
const fill = isDamage ? '#FF0000' : '#00FF77'; const fill = isDamage ? '#FF0000' : '#00FF77';
this.entity.emitParticle('damage', { this.entity.emitParticle('damage', {
@ -208,6 +258,10 @@ export class Vulnerable extends Trait {
}, },
}, },
}); });
this.entity.emitParticle('blood', {
rate: 0.0125,
count: 10,
});
}, },
takeDamageFrom: (entity) => { takeDamageFrom: (entity) => {