Skip to content
Open
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
30 changes: 28 additions & 2 deletions src/main/java/rs117/hd/HdPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
import net.runelite.api.events.NpcChanged;
import net.runelite.api.events.NpcDespawned;
import net.runelite.api.events.NpcSpawned;
import net.runelite.api.events.PlayerDespawned;
import net.runelite.api.events.PlayerSpawned;
import net.runelite.api.events.PlayerChanged;
import net.runelite.api.events.ProjectileMoved;
import net.runelite.api.events.WallObjectChanged;
import net.runelite.api.events.WallObjectDespawned;
Expand Down Expand Up @@ -396,6 +399,7 @@ enum ComputeMode
public boolean configTzhaarHD = true;
public boolean configProjectileLights = true;
public boolean configNpcLights = true;
public boolean configEquipmentLights = true;
public boolean configShadowsEnabled = false;
public boolean configExpandShadowDraw = false;

Expand All @@ -414,6 +418,7 @@ protected void startUp()
configTzhaarHD = config.tzhaarHD();
configProjectileLights = config.projectileLights();
configNpcLights = config.npcLights();
configEquipmentLights = config.equipmentLights();
configShadowsEnabled = config.shadowsEnabled();
configExpandShadowDraw = config.expandShadowDraw();

Expand Down Expand Up @@ -2130,6 +2135,9 @@ public void onConfigChanged(ConfigChanged event)
case "npcLights":
configNpcLights = config.npcLights();
break;
case "equipmentLights":
configEquipmentLights = config.equipmentLights();
break;
case "expandShadowDraw":
configExpandShadowDraw = config.expandShadowDraw();
break;
Expand Down Expand Up @@ -2466,11 +2474,29 @@ public void onNpcDespawned(NpcDespawned npcDespawned)
{
lightManager.removeNpcLight(npcDespawned);
}

@Subscribe
@Subscribe
public void onNpcChanged(NpcChanged npcChanged)
{
lightManager.updateNpcChanged(npcChanged);
}

@Subscribe
public void onPlayerSpawned(PlayerSpawned playerSpawned)
{
lightManager.addEquipmentLight(playerSpawned.getPlayer());
}

@Subscribe
public void onPlayerDespawned(PlayerDespawned playerDespawned)
{
lightManager.removeEquipmentLight(playerDespawned);
}

@Subscribe
public void onPlayerChanged(PlayerChanged playerChanged)
{
lightManager.equipmentLightChanged(playerChanged);
}

@Subscribe
Expand Down
22 changes: 17 additions & 5 deletions src/main/java/rs117/hd/HdPluginConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,23 @@ default boolean npcLights()
return true;
}

@ConfigItem(
keyName = "equipmentLights",
name = "Equipment Lights",
description = "Adds dynamic lights to some equipment when equipped on a player.",
position = 104,
section = lightingSettings
)
default boolean equipmentLights()
{
return true;
}

@ConfigItem(
keyName = "atmosphericLighting",
name = "Atmospheric Lighting",
description = "Changes the color and brightness of full-scene lighting in certain areas.",
position = 104,
position = 105,
section = lightingSettings
)
default boolean atmosphericLighting()
Expand All @@ -250,7 +262,7 @@ default boolean atmosphericLighting()
keyName = "shadowsEnabled",
name = "Shadows",
description = "Enables fully-dynamic shadows.",
position = 105,
position = 106,
section = lightingSettings
)
default boolean shadowsEnabled()
Expand All @@ -262,7 +274,7 @@ default boolean shadowsEnabled()
keyName = "shadowResolution",
name = "Shadow Resolution",
description = "The resolution of the shadow maps. Higher resolutions result in sharper, higher quality shadows at the cost of performance.",
position = 106,
position = 107,
section = lightingSettings
)
default ShadowResolution shadowResolution()
Expand All @@ -274,7 +286,7 @@ default ShadowResolution shadowResolution()
keyName = "shadowDistance",
name = "Shadow Distance",
description = "The maximum draw distance of shadow maps. Shorter distances result in sharper, higher quality shadows.",
position = 107,
position = 108,
section = lightingSettings
)
default ShadowDistance shadowDistance()
Expand All @@ -286,7 +298,7 @@ default ShadowDistance shadowDistance()
keyName = "expandShadowDraw",
name = "Expand Shadow Draw",
description = "Reduces 'flickering' of shadows disappearing at screen edge by increasing geometry drawn at a cost of performance.",
position = 108,
position = 109,
section = lightingSettings
)
default boolean expandShadowDraw()
Expand Down
70 changes: 70 additions & 0 deletions src/main/java/rs117/hd/lighting/EquipmentLight.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package rs117.hd.lighting;

import com.google.common.collect.ImmutableMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.runelite.api.ItemID;
import static net.runelite.api.ItemID.*;
import rs117.hd.lighting.LightManager.LightType;
import rs117.hd.lighting.LightManager.Alignment;

@AllArgsConstructor
@Getter
enum EquipmentLight
{
FIRE_CAPE(90, Alignment.BACK, 150, 6f, rgb(220, 156, 74), LightType.PULSE, 4000, 8, ItemID.FIRE_CAPE, FIRE_CAPE_10566),
FIRE_MAX_CAPE(90, Alignment.BACK, 150, 6f, rgb(220, 156, 74), LightType.PULSE, 4000, 8, ItemID.FIRE_MAX_CAPE, FIRE_MAX_CAPE_21186),
INFERNAL_CAPE(90, Alignment.BACK, 150, 6f, rgb(133, 64, 0), LightType.PULSE, 4000, 8, ItemID.INFERNAL_CAPE, INFERNAL_CAPE_21297, INFERNAL_CAPE_23622),
INFERNAL_MAX_CAPE(90, Alignment.BACK, 150, 6f, rgb(133, 64, 0), LightType.PULSE, 4000, 8, ItemID.INFERNAL_MAX_CAPE, INFERNAL_MAX_CAPE_21285),
LIT_BUG_LANTERN(50, Alignment.LEFT, 250, 6f, rgb(255, 233, 138), LightType.FLICKER, 0, 10, ItemID.LIT_BUG_LANTERN),
;

private final int[] id;
private final int height;
private final Alignment alignment;
private final int size;
private final float strength;
private final int rgb;
private final LightType lightType;
private final float duration;
private final float range;

EquipmentLight(int height, Alignment alignment, int size, float strength, int rgb, LightType lightType, float duration, float range, int... ids)
{
this.height = height;
this.alignment = alignment;
this.size = size;
this.strength = strength;
this.rgb = rgb;
this.lightType = lightType;
this.duration = duration;
this.range = range;
this.id = ids;
}

private static final Map<Integer, EquipmentLight> LIGHTS;

static
{
ImmutableMap.Builder<Integer, EquipmentLight> builder = new ImmutableMap.Builder<>();
for (EquipmentLight equipmentLight : values())
{
for (int id : equipmentLight.id)
{
builder.put(id + 512, equipmentLight);
}
}
LIGHTS = builder.build();
}

static EquipmentLight find(int id)
{
return LIGHTS.get(id);
}

private static int rgb(int r, int g, int b)
{
return (r << 16) | (g << 8) | b;
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're missing a newline here

Copy link

@stevenwaterman stevenwaterman Sep 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more I think about it, the more pieces of equipment I can think of. Makes sense if you want to leave this PR as just infra and then a second one adding all the equipment

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's generally pretty easy just got to setup the positioning and brightness etc. It works the same as adding lights for objects, npcs etc. just a bit outside of the scope of both the issue and the amount of time I had available to spend on writing this.

Loading