Skip to content

Commit

Permalink
Patch for v56
Browse files Browse the repository at this point in the history
- Improve performance by only getting doors on spawn not during chase
  • Loading branch information
zealsprince committed Jul 7, 2024
1 parent 95a7b65 commit 6b7be4e
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@

# Changelog #

## 1.2.2 ##

- Patch for v56
- Improve performance by only getting doors on spawn not during chase

## 1.2.1 ##

- Patch for v55
Expand Down
21 changes: 18 additions & 3 deletions Locker/MonoBehaviours/LockerAI.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using GameNetcodeStuff;
using Unity.Netcode;
using UnityEngine;
Expand Down Expand Up @@ -36,6 +37,7 @@ public enum State
private Material eyeMaterial;
private Light internalLight;
private List<Light> scrapeLights;
private DoorLock[] doors = [];

// Store the scrape/chase VFXs so they can be toggled during chase.
private VisualEffect[] visualEffects;
Expand Down Expand Up @@ -192,6 +194,9 @@ public override void Start()
consumeVFXBeginTrigger.name = consumeVFXBeginTriggerName;
consumeVFXEndTrigger.name = consumeVFXEndTriggerName;

// Get all doors in the level. We use this later to check the distance of the Locker to them.
doors = Object.FindObjectsOfType(typeof(DoorLock)) as DoorLock[];

debugLine = GetComponent<LineRenderer>();

// Begin the initial state.
Expand Down Expand Up @@ -559,11 +564,18 @@ public void FixedUpdate()
}
}

// Get all doors in the level and check their distance to the locker while chasing.
DoorLock[] doors = Object.FindObjectsOfType(typeof(DoorLock)) as DoorLock[];

// Check door's distance to the Locker while chasing.
foreach (DoorLock door in doors)
{
// Make sure we don't crash in case a door got removed by another system.
if (!door)
{
doors = doors.Where(val => val != door).ToArray();

break;
}

// TODO: We need to figure out how to tell if a door is open.
// if (!door.isDoorOpened) // Ignore open doors.
// {
if ( // Check that we're in range of a door.
Expand All @@ -574,6 +586,9 @@ public void FixedUpdate()
Utilities.Explode(door.transform.position, 2, 4, 100, 0);

Destroy(door.transform.parent.gameObject);

// Remove the door from our array.
doors = doors.Where(val => val != door).ToArray();
}
// }
}
Expand Down
2 changes: 1 addition & 1 deletion Locker/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Plugin : BaseUnityPlugin
{
public const string ModGUID = "com.zealsprince.locker";
public const string ModName = "Locker";
public const string ModVersion = "1.2.1";
public const string ModVersion = "1.2.2";

// These need to be lowercase because we're passing through the protected properties.
public static ManualLogSource logger;
Expand Down
4 changes: 2 additions & 2 deletions Locker/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.1.0")]
[assembly: AssemblyFileVersion("1.2.1.1")]
[assembly: AssemblyVersion("1.2.2.0")]
[assembly: AssemblyFileVersion("1.2.2.1")]
10 changes: 4 additions & 6 deletions Locker/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public static void Explode(
QueryTriggerInteraction.Collide
);

PlayerControllerB player = null;
for (int i = 0; i < array.Length; i++)
{
float distance = Vector3.Distance(position, array[i].transform.position);
Expand All @@ -88,7 +87,8 @@ public static void Explode(
// Damage players.
if (array[i].gameObject.layer == 3)
{
player = array[i].gameObject.GetComponent<PlayerControllerB>();
PlayerControllerB player = array[i]
.gameObject.GetComponent<PlayerControllerB>();
if (player != null && player.IsOwner)
{
float damageMultiplier =
Expand Down Expand Up @@ -139,10 +139,8 @@ public static void Explode(
for (int j = 0; j < array.Length; j++)
{
Rigidbody component = array[j].GetComponent<Rigidbody>();
if (component != null)
{
component.AddExplosionForce(70f, position, 10f);
}

component?.AddExplosionForce(70f, position, 10f);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

<img src="https://img.shields.io/badge/version-1.2.1-0AF" /></a>
<img src="https://img.shields.io/badge/lc--version-v55-000" /></a>
<img src="https://img.shields.io/badge/version-1.2.2-0AF" /></a>
<img src="https://img.shields.io/badge/lc--version-v56-000" /></a>

![banner](https://github.com/zealsprince/lc-locker/assets/1859270/120046ff-144a-4e17-b5fb-f973d5fc3a0f)

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Locker",
"version_number": "1.2.1",
"version_number": "1.2.2",
"website_url": "https://github.com/zealsprince/lc-locker",
"description": "A new and unique enemy that acts as a situational threat, praying on player's perception",
"dependencies": [
Expand Down

0 comments on commit 6b7be4e

Please sign in to comment.