Added comments to everything

This commit is contained in:
djkellerman
2025-04-18 15:54:50 -04:00
parent a0305ea0e9
commit 213bb2d14b
39 changed files with 3166 additions and 1796 deletions

View File

@@ -1,28 +1,57 @@
using UnityEngine; using Game; using Music; using Player;
using UnityEngine;
using Game;
using Music;
using Player;
namespace Game
{
public class RespawnOnTriggerEnter : MonoBehaviour
{
public Vector2 spawnPoint;
public bool spawnPointIsInitialPosition = false;
public string respawnTag;
private void Start() // Set the spawn point to the initial maps spawn point
/// <summary>
/// This class handles respawning objects when they collide with a trigger tagged with a specific value.
/// </summary>
public class RespawnOnTriggerEnter : MonoBehaviour
{
if (spawnPointIsInitialPosition)
{
spawnPoint = transform.position;
}
}
/// <summary>
/// The spawn point where the object will respawn.
/// </summary>
public Vector2 spawnPoint;
private void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag(respawnTag))
/// <summary>
/// If true, the spawn point is set to the object's initial position.
/// </summary>
public bool spawnPointIsInitialPosition = false;
/// <summary>
/// The tag of the trigger that causes the object to respawn.
/// </summary>
public string respawnTag;
/// <summary>
/// Sets the spawn point to the object's initial position if specified.
/// </summary>
private void Start()
{
if (TryGetComponent(out Damageable damageable))
if (spawnPointIsInitialPosition)
{
damageable.Damage(9999f);
// Set the spawn point to the object's initial position
spawnPoint = transform.position;
}
}
/// <summary>
/// Handles collisions with triggers and applies damage to the object if it has a <see cref="Damageable"/> component.
/// </summary>
/// <param name="other">The collider of the object that entered the trigger.</param>
private void OnTriggerEnter2D(Collider2D other)
{
// Check if the collider has the specified tag
if (other.CompareTag(respawnTag))
{
// Apply damage to the object if it has a Damageable component
if (TryGetComponent(out Damageable damageable))
{
damageable.Damage(9999f);
}
}
}
}
}}
}