Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DigitalzombieTLD committed Jun 20, 2023
1 parent cd68dbf commit 300e880
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 40 deletions.
58 changes: 39 additions & 19 deletions Candlelight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,70 @@
using Il2CppInterop.Runtime.Injection;
using System.Collections;
using Il2Cpp;
using UnityEngine.Device;

namespace Candlelight
{
public class Candlelight_Main : MelonMod
{
public static Color candleLightColor = new Color(0.72f, 0.46f, 0.25f);
public static Color candleFlameColor = new Color(0f, 0f, 0f);
public int layerMask = 0;
public static RaycastHit hit;

public override void OnApplicationStart()
{
ClassInjector.RegisterTypeInIl2Cpp<CandleItem>();

Candlelight.Settings.OnLoad();
layerMask |= 1 << 17; // gear layer
}

public override void OnUpdate()
{
if (InputManager.GetKeyDown(InputManager.m_CurrentContext, Settings.options.interactButton) || InputManager.GetKeyDown(InputManager.m_CurrentContext, Settings.options.interactButton2))
{
PlayerManager currentPlayerManager = GameManager.GetPlayerManagerComponent();
GameObject targetObject = currentPlayerManager.GetInteractiveObjectUnderCrosshairs(2.5f);

if (targetObject != null && targetObject.name.Contains("GEAR_Candle"))
if (Physics.Raycast(GameManager.GetMainCamera().transform.position, GameManager.GetMainCamera().transform.TransformDirection(Vector3.forward), out hit, 2.5f, layerMask))
{
CandleItem thisCandle = targetObject.GetComponent<CandleItem>();

if (thisCandle.isLit)
GameObject hitObject = hit.collider.gameObject;
string hitObjectName = hitObject.name;

if (hitObjectName == "Body0" || hitObjectName == "Body1" || hitObjectName == "Body2" || hitObjectName == "Body3")
{
if(currentPlayerManager.m_ItemInHands.m_TorchItem && !currentPlayerManager.m_ItemInHands.IsLitTorch())
CandleItem thisCandle;

if (hitObject.transform.parent.name == "Normal")
{
currentPlayerManager.m_ItemInHands.m_TorchItem.Ignite();
thisCandle = hitObject.transform.parent.parent.GetComponent<CandleItem>();
}
else
{
thisCandle.turnOff();
}
}
else
{
if (currentPlayerManager.m_ItemInHands)
return;
}

if(thisCandle != null)
{
if(currentPlayerManager.m_ItemInHands.IsLitMatch() || currentPlayerManager.m_ItemInHands.IsLitFlare() || currentPlayerManager.m_ItemInHands.IsLitTorch())

PlayerManager currentPlayerManager = GameManager.GetPlayerManagerComponent();

if (thisCandle.isLit)
{
if (currentPlayerManager.m_ItemInHands.m_TorchItem && !currentPlayerManager.m_ItemInHands.IsLitTorch())
{
currentPlayerManager.m_ItemInHands.m_TorchItem.Ignite();
}
else
{
thisCandle.turnOff();
}
}
else
{
thisCandle.turnOn();
if (currentPlayerManager.m_ItemInHands)
{
if (currentPlayerManager.m_ItemInHands.IsLitMatch() || currentPlayerManager.m_ItemInHands.IsLitFlare() || currentPlayerManager.m_ItemInHands.IsLitTorch())
{
thisCandle.turnOn();
}
}
}
}
}
Expand Down
17 changes: 10 additions & 7 deletions Candlelight.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<PropertyGroup>
<!--This needs to be changed for the mod to compile.-->
<TheLongDarkPath>G:\Games\Steam\steamapps\common\TheLongDark</TheLongDarkPath>
<TheLongDarkPath>W:/Steam/steamapps/common/TheLongDark</TheLongDarkPath>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -48,10 +48,10 @@
<!--This is the list of assemblies that the mod references. Most of these are unnecessary for normal mods, but are included here for completeness.-->
<ItemGroup>
<Reference Include="Il2CppInterop.Common">
<HintPath>..\..\..\..\Games\Steam\steamapps\common\TheLongDark\MelonLoader\net6\Il2CppInterop.Common.dll</HintPath>
<HintPath>W:\Steam\steamapps\common\TheLongDark\MelonLoader\net6\Il2CppInterop.Common.dll</HintPath>
</Reference>
<Reference Include="Il2CppInterop.Runtime">
<HintPath>..\..\..\..\Games\Steam\steamapps\common\TheLongDark\MelonLoader\net6\Il2CppInterop.Runtime.dll</HintPath>
<HintPath>W:\Steam\steamapps\common\TheLongDark\MelonLoader\net6\Il2CppInterop.Runtime.dll</HintPath>
</Reference>
<Reference Include="MelonLoader" />
<Reference Include="0Harmony" />
Expand Down Expand Up @@ -80,14 +80,14 @@
<Reference Include="Il2CppTLD.Trial" />
<Reference Include="Il2CppTLD.UserGeneratedContent" />
<Reference Include="ModSettings">
<HintPath>G:\Games\Steam\steamapps\common\TheLongDark\Mods\ModSettings.dll</HintPath>
<HintPath>W:\Steam\steamapps\common\TheLongDark\Mods\ModSettings.dll</HintPath>
</Reference>
<Reference Include="Unity.Addressables">
<HintPath>G:\Games\Steam\steamapps\common\TheLongDark\MelonLoader\Il2CppAssemblies\Unity.Addressables.dll</HintPath>
<HintPath>W:\Steam\steamapps\common\TheLongDark\MelonLoader\Il2CppAssemblies\Unity.Addressables.dll</HintPath>
</Reference>
<Reference Include="Unity.Mathematics" />
<Reference Include="Unity.ResourceManager">
<HintPath>G:\Games\Steam\steamapps\common\TheLongDark\MelonLoader\Il2CppAssemblies\Unity.ResourceManager.dll</HintPath>
<HintPath>W:\Steam\steamapps\common\TheLongDark\MelonLoader\Il2CppAssemblies\Unity.ResourceManager.dll</HintPath>
</Reference>
<Reference Include="Unity.TextMeshPro" />
<Reference Include="UnityEngine.AssetBundleModule" />
Expand All @@ -98,7 +98,10 @@
<Reference Include="UnityEngine.Il2CppAssetBundleManager" />
<Reference Include="UnityEngine.Il2CppImageConversionManager" />
<Reference Include="UnityEngine.ParticleSystemModule">
<HintPath>G:\Games\Steam\steamapps\common\TheLongDark\MelonLoader\Il2CppAssemblies\UnityEngine.ParticleSystemModule.dll</HintPath>
<HintPath>W:\Steam\steamapps\common\TheLongDark\MelonLoader\Il2CppAssemblies\UnityEngine.ParticleSystemModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>..\..\..\..\Steam\steamapps\common\TheLongDark\MelonLoader\Il2CppAssemblies\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
11 changes: 4 additions & 7 deletions Components/CandleItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Candlelight
{
[RegisterTypeInIl2Cpp]
public class CandleItem : MonoBehaviour
{
public CandleItem(IntPtr intPtr) : base(intPtr)
Expand Down Expand Up @@ -56,17 +57,13 @@ public CandleItem(IntPtr intPtr) : base(intPtr)
public string flickerPattern = "mmnmmommommnonmmonqnmmo";

public bool isLit = false;


public void Start()
{
InitAll();
}


public void Awake()
{
InitAll();
}
transformCandle();
}


public void InitAll()
Expand Down
9 changes: 3 additions & 6 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
using System.Reflection;
using System.Runtime.InteropServices;

//This is a C# comment. Comments have no impact on compilation.

//ModName, ModVersion, ModAuthor, and ModNamespace.ModClassInheritingFromMelonMod all need changed.

[assembly: AssemblyTitle("Candlelight")]
[assembly: AssemblyCopyright("Digitalzombie")]

//Version numbers in C# are a set of 1 to 4 positive integers separated by periods.
//Mods typically use 3 numbers. For example: 1.2.1
//The mod version need specified in three places.
[assembly: AssemblyVersion("1.3.5")]
[assembly: AssemblyFileVersion("1.3.5")]
[assembly: MelonInfo(typeof(Candlelight_Main), "Candlelight", "1.3.5", "Digitalzombie", null)]
[assembly: AssemblyVersion("1.3.8")]
[assembly: AssemblyFileVersion("1.3.8")]
[assembly: MelonInfo(typeof(Candlelight_Main), "Candlelight", "1.3.8", "Digitalzombie", null)]

//This tells MelonLoader that the mod is only for The Long Dark.
[assembly: MelonGame("Hinterland", "TheLongDark")]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The Long Dark - TLD Candlelight - v1.3.5 by Digitalzombie
The Long Dark - TLD Candlelight - v1.3.8 by Digitalzombie
===========================================================

How to install:
Expand Down Expand Up @@ -66,6 +66,8 @@ https://discord.gg/AqpW9TjUfr

Changelog:
==========
1.3.8
- Fixed random errors

1.3.5
- Removed AlternativeAction Utilities dependency
Expand Down

0 comments on commit 300e880

Please sign in to comment.