Curation round 14: console and Lua API, effects, lasers, enemies, eleven bosses, the Depths and Mom, status effects, the playable characters

This commit is contained in:
shweet committed 2026-11-20 19:04:41 -05:00
1 parent 8ae02a8422
commit 6e3da161fc
138 files changed
+16754 -6825

No files matched your search

+75 -9
View File
@@ -1,9 +1,9 @@
#include "entity_effect.h"
#include "entity_effect_ambient.h"
#include "entity_effect_combat.h"
#include "entity_list.h"
#include "entity_player.h"
#include "game.h"
#include "kage_graphics.h"
#include "log.h"
#include "lua_engine.h"
#include "manager.h"
@@ -11,6 +11,7 @@
#include "sfx_manager.h"
#include <algorithm>
#include <array>
#include <cmath>
// The creep variants the players leave (holy water trail, black, red, white, holy water, green, Lemon Mishap, Lemon
// Party, 204, Black Powder, milk, Black Powder's pentagram).
@@ -41,12 +42,72 @@ constexpr int SOUND_BOOMERANG_LOOP = 837;
constexpr int SOUND_PORTAL_ENTITY_LOOP = 846;
constexpr int SOUND_CHAIN_LOOP = 503;
// The variants the behaviour tables can index, up to the last vanilla one.
constexpr int EFFECT_VARIANT_LIMIT = 256;
template <size_t N>
static bool is_listed(const std::array<int, N>& list, int value)
{
return std::find(list.begin(), list.end(), value) != list.end();
}
// The behaviour of a variant one of the groups hands out, indexed once by variant, or none.
static const EffectBehaviour* behaviour_find(int variant)
{
static const std::array<EffectBehaviour, EFFECT_VARIANT_LIMIT> TABLE = [] {
std::array<EffectBehaviour, EFFECT_VARIANT_LIMIT> table{};
for (auto group : {ambient_effect_behaviours(), hazard_effect_behaviours(), floor_effect_behaviours(),
beam_effect_behaviours()})
for (const EffectBehaviour& behaviour : group) table[behaviour.variant] = behaviour;
return table;
}();
if (variant < 0 || variant >= EFFECT_VARIANT_LIMIT || TABLE[variant].variant != variant) return nullptr;
return &TABLE[variant];
}
// 005d4b7a (Update's shared poof case) Turns the sprite by the effect's rotation and removes the effect once its
// animation ends.
EffectUpdateEnd effect_poof_update(Entity_Effect& effect)
{
effect.sprite.rotation = effect.sprite.isFlipX ? effect.rotation : -effect.rotation;
if (effect.sprite.IsFinished()) effect.Remove();
return EFFECT_UPDATE_FINISH;
}
// An angle in degrees wrapped into -180 to 180, as approach_angle wraps it.
static float angle_wrapped(float angle)
{
if (std::fabs(angle) > DEGREES_PER_TURN) angle = std::fmod(angle, DEGREES_PER_TURN);
if (angle > DEGREES_PER_TURN / 2) return angle - DEGREES_PER_TURN;
if (angle < -DEGREES_PER_TURN / 2) return angle + DEGREES_PER_TURN;
return angle;
}
// 00682a50 An angle in degrees turned toward a target by at most a step, reaching it when within the step.
float angle_approach(float current, float target, float maxStep)
{
float delta = angle_wrapped(target - current);
if (std::fabs(delta) <= maxStep) return target;
return angle_wrapped(delta > 0 ? current + maxStep : current - maxStep);
}
// 00a15640 (assert_lerp_range, always clamped here) A value's place between two inputs, carried onto two outputs.
float lerp_clamped(float value, float inFirst, float inLast, float outFirst, float outLast)
{
float t = (value - inFirst) / (inLast - inFirst);
if (t <= 0) t = 0;
if (t >= 1) t = 1;
return (outLast - outFirst) * t + outFirst;
}
// BlendMode::SetMode 2 on a layer.
void layer_additive_set(LayerState& layer)
{
KAGE::Graphics::BlendMode mode;
mode.SetMode(KAGE::Graphics::BLEND_ADDITIVE);
layer.blendMode = {mode.equation, mode.rgbSource, mode.rgbDest, mode.alphaSource, mode.alphaDest};
}
// 0060c400 Only a boss spawn pentagram holds the doors shut.
bool Entity_Effect::CanShutDoors()
{
@@ -119,7 +180,10 @@ void Entity_Effect::Init(int entityType, int entityVariant, int entitySubType, u
entityGridCollisionClass = variant == EFFECT_BLOOD_PARTICLE ? GRIDCOLL_WALLS : GRIDCOLL_NONE;
entityCollisionClass = ENTCOLL_NONE;
if (is_ambient_effect(variant)) ambient_effect_init(*this);
if (const EffectBehaviour* behaviour = behaviour_find(variant))
{
if (behaviour->init) behaviour->init(*this);
}
else if (is_combat_effect(variant)) combat_effect_init(*this);
else reconstruction_missing("Entity_Effect::Init 005cdb20: this effect variant");
if (!isExists) return;
@@ -137,11 +201,9 @@ void Entity_Effect::Update()
speedMultiplier = g_game->room->GetTimeScale(this);
if (variant == EFFECT_HUSH_LASER || variant == EFFECT_HUSH_LASER_UP)
{
if (TemporaryEffect* hourglass = g_game->room->temporaryEffects.GetCollectibleEffect(COLLECTIBLE_HOURGLASS))
{
float t = std::clamp((float)hourglass->cooldown / HOURGLASS_COOLDOWN_SPAN, 0.0f, 1.0f);
speedMultiplier *= (HOURGLASS_SLOWEST - 1) * t + 1;
}
TemporaryEffect* hourglass = g_game->room->temporaryEffects.GetCollectibleEffect(COLLECTIBLE_HOURGLASS);
if (hourglass)
speedMultiplier *= lerp_clamped((float)hourglass->cooldown, 0, HOURGLASS_COOLDOWN_SPAN, 1, HOURGLASS_SLOWEST);
}
if (variant == EFFECT_BLACK_POWDER) pauseTimer = 0;
if (pauseTimer != 0)
@@ -174,7 +236,10 @@ void Entity_Effect::Update()
}
EffectUpdateEnd end = EFFECT_UPDATE_FINISH;
if (is_ambient_effect(variant)) end = ambient_effect_update(*this);
if (const EffectBehaviour* behaviour = behaviour_find(variant))
{
if (behaviour->update) end = behaviour->update(*this);
}
else if (is_combat_effect(variant)) end = combat_effect_update(*this);
else reconstruction_missing("Entity_Effect::Update 005d4380: this effect variant");
if (end == EFFECT_UPDATE_RETURN) return;
@@ -204,7 +269,8 @@ void Entity_Effect::Render(const Vector& offset)
Vector screen = render_position_get(vector_make(pos.x + posOffset.x, pos.y + posOffset.y), RENDER_SNAPPED);
renderPosition = vector_make(screen.x + offset.x, screen.y + offset.y);
if (is_ambient_effect(variant)) ambient_effect_render(*this, offset);
const EffectBehaviour* behaviour = behaviour_find(variant);
if (behaviour && behaviour->render) behaviour->render(*this, offset);
else sprite.Render(SpriteDraw{renderPosition, {}, {}});
lua_engine_get().PostEffectRender(this, offset);
}