Browse Source

Implemented the color mapped explosion effect introduced by the Rogue expansion pack

readme
Nico de Poel 5 years ago
parent
commit
d44e75c620
  1. 4
      Assets/Scripts/Modules/GameModule.Interop.cs
  2. 6
      Assets/Scripts/Modules/GameModule.cs
  3. 32
      Assets/Scripts/VisualStyle.cs
  4. 2
      Assets/Styles/GLQuake/GLQuake.asset
  5. 4864
      Assets/Styles/GLQuake/Particles/RogueExplosion.prefab
  6. 7
      Assets/Styles/GLQuake/Particles/RogueExplosion.prefab.meta
  7. 2
      engine/Quake/r_part.c
  8. 1
      engine/Quake/render.h
  9. 10
      engine/UniQuake/game_uniquake.c

4
Assets/Scripts/Modules/GameModule.Interop.cs

@ -115,8 +115,8 @@ public partial class GameModule : CallbackHandler<GameModule>
{ {
Profiler.BeginSample("CreateParticleEffect"); Profiler.BeginSample("CreateParticleEffect");
if (type == ParticleEffect.Explosion2)
GetSelf(context).CreateParticleExplosion(origin.ToUnityPosition(), colorMin.ToColor(), colorMax.ToColor());
if (type == ParticleEffect.RogueExplosion)
GetSelf(context).CreateRogueExplosion(origin.ToUnityPosition(), colorMin.ToColor(), colorMax.ToColor());
else else
GetSelf(context).CreateParticleEffect(type, origin.ToUnityPosition()); GetSelf(context).CreateParticleEffect(type, origin.ToUnityPosition());

6
Assets/Scripts/Modules/GameModule.cs

@ -89,16 +89,16 @@ public partial class GameModule
} }
} }
private void CreateParticleExplosion(Vector3 position, Color colorMin, Color colorMax)
private void CreateRogueExplosion(Vector3 position, Color colorMin, Color colorMax)
{ {
uq.CurrentStyle.Particles.CreateRogueExplosion(position, colorMin, colorMax, uq.GameLayer);
} }
// Should correspond to particle_effect_t in game_uniquake.c // Should correspond to particle_effect_t in game_uniquake.c
private enum ParticleEffect private enum ParticleEffect
{ {
Explosion = 0, Explosion = 0,
Explosion2,
RogueExplosion,
BlobExplosion, BlobExplosion,
LavaSplash, LavaSplash,
TeleportSplash, TeleportSplash,

32
Assets/Scripts/VisualStyle.cs

@ -158,6 +158,9 @@ public class ParticleSystems
[SerializeField] [SerializeField]
protected ParticleSystem explosion; protected ParticleSystem explosion;
[SerializeField]
protected ParticleSystem rogueExplosion;
[SerializeField] [SerializeField]
protected ParticleSystem teleportSplash; protected ParticleSystem teleportSplash;
@ -172,14 +175,7 @@ public class ParticleSystems
var main = effect.main; var main = effect.main;
main.maxParticles = count; main.maxParticles = count;
var startColor = main.startColor;
startColor.gradient.colorKeys = new[]
{
new GradientColorKey(colorMin, 0f),
new GradientColorKey(colorMax, 1f),
};
main.startColor = startColor;
SetColorGradient(main, colorMin, colorMax);
var velocity = effect.velocityOverLifetime; var velocity = effect.velocityOverLifetime;
velocity.x = direction.x * 15f; velocity.x = direction.x * 15f;
@ -192,6 +188,15 @@ public class ParticleSystems
InstantiateEffect(explosion, position, layer); InstantiateEffect(explosion, position, layer);
} }
public virtual void CreateRogueExplosion(Vector3 position, Color colorMin, Color colorMax, Layers layer)
{
var effect = InstantiateEffect(rogueExplosion, position, layer);
if (effect == null)
return;
SetColorGradient(effect.main, colorMin, colorMax);
}
public virtual void CreateTeleportSplash(Vector3 position, Layers layer) public virtual void CreateTeleportSplash(Vector3 position, Layers layer)
{ {
InstantiateEffect(teleportSplash, position, layer); InstantiateEffect(teleportSplash, position, layer);
@ -223,4 +228,15 @@ public class ParticleSystems
go.transform.GetChild(i).gameObject.layer = (int)layer; go.transform.GetChild(i).gameObject.layer = (int)layer;
} }
} }
protected static void SetColorGradient(ParticleSystem.MainModule main, Color colorMin, Color colorMax)
{
var startColor = main.startColor;
startColor.gradient.colorKeys = new[]
{
new GradientColorKey(colorMin, 0f),
new GradientColorKey(colorMax, 1f),
};
main.startColor = startColor;
}
} }

2
Assets/Styles/GLQuake/GLQuake.asset

@ -27,6 +27,8 @@ MonoBehaviour:
type: 3} type: 3}
explosion: {fileID: 9150008102338277659, guid: 94e2cf23692eef24d9a5145b0f705c55, explosion: {fileID: 9150008102338277659, guid: 94e2cf23692eef24d9a5145b0f705c55,
type: 3} type: 3}
rogueExplosion: {fileID: 9150008102338277659, guid: 0a1fede38a8884d488bcf7625cad527e,
type: 3}
teleportSplash: {fileID: 9150008102338277659, guid: 79bef89ba1457cb42a9fbeaf4acff66f, teleportSplash: {fileID: 9150008102338277659, guid: 79bef89ba1457cb42a9fbeaf4acff66f,
type: 3} type: 3}
lavaSplash: {fileID: 9150008102338277659, guid: 4db0c926dce46fe4c90920ecd8c5df2e, lavaSplash: {fileID: 9150008102338277659, guid: 4db0c926dce46fe4c90920ecd8c5df2e,

4864
Assets/Styles/GLQuake/Particles/RogueExplosion.prefab
File diff suppressed because it is too large
View File

7
Assets/Styles/GLQuake/Particles/RogueExplosion.prefab.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0a1fede38a8884d488bcf7625cad527e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

2
engine/Quake/r_part.c

@ -408,6 +408,8 @@ R_ParticleExplosion2
*/ */
void R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength) void R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength)
{ {
UQ_Game_ParticleExplosion2(org, colorStart, colorLength);
#ifdef USE_OPENGL #ifdef USE_OPENGL
int i, j; int i, j;
particle_t *p; particle_t *p;

1
engine/Quake/render.h

@ -180,6 +180,7 @@ void UQ_GL_SetupView(vec3_t origin, vec3_t angles, mleaf_t *viewLeaf);
void UQ_Game_RunParticleEffect(vec3_t origin, vec3_t direction, int color, int count); void UQ_Game_RunParticleEffect(vec3_t origin, vec3_t direction, int color, int count);
void UQ_Game_ParticleExplosion(vec3_t origin); void UQ_Game_ParticleExplosion(vec3_t origin);
void UQ_Game_ParticleExplosion2(vec3_t origin, int colorStart, int colorLength);
void UQ_Game_TeleportSplash(vec3_t origin); void UQ_Game_TeleportSplash(vec3_t origin);
void UQ_Game_LavaSplash(vec3_t origin); void UQ_Game_LavaSplash(vec3_t origin);

10
engine/UniQuake/game_uniquake.c

@ -59,7 +59,7 @@ void UQ_Game_RunParticleEffect(vec3_t origin, vec3_t direction, int color, int c
typedef enum typedef enum
{ {
PARTFX_EXPLOSION = 0, PARTFX_EXPLOSION = 0,
PARTFX_EXPLOSION2,
PARTFX_ROGUE_EXPLOSION,
PARTFX_BLOB_EXPLOSION, PARTFX_BLOB_EXPLOSION,
PARTFX_LAVA_SPLASH, PARTFX_LAVA_SPLASH,
PARTFX_TELEPORT_SPLASH, PARTFX_TELEPORT_SPLASH,
@ -70,6 +70,14 @@ void UQ_Game_ParticleExplosion(vec3_t origin)
unity_gamecalls->CreateParticleEffect(unity_context, PARTFX_EXPLOSION, origin, 0, 0); unity_gamecalls->CreateParticleEffect(unity_context, PARTFX_EXPLOSION, origin, 0, 0);
} }
void UQ_Game_ParticleExplosion2(vec3_t origin, int colorStart, int colorLength)
{
unsigned int colorMin, colorMax;
colorMin = d_8to24table[colorStart];
colorMax = d_8to24table[colorStart + colorLength - 1];
unity_gamecalls->CreateParticleEffect(unity_context, PARTFX_ROGUE_EXPLOSION, origin, colorMin, colorMax);
}
void UQ_Game_TeleportSplash(vec3_t origin) void UQ_Game_TeleportSplash(vec3_t origin)
{ {
unity_gamecalls->CreateParticleEffect(unity_context, PARTFX_TELEPORT_SPLASH, origin, 0, 0); unity_gamecalls->CreateParticleEffect(unity_context, PARTFX_TELEPORT_SPLASH, origin, 0, 0);

Loading…
Cancel
Save