Revamp the prompt system, the bootstrapper system, the starting cinematic
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// ScriptableObject representing a single puzzle step, its display info, and which steps it unlocks.
|
||||
@@ -29,4 +30,58 @@ public class PuzzleStepSO : ScriptableObject
|
||||
/// </summary>
|
||||
[Header("Unlocks")]
|
||||
public List<PuzzleStepSO> unlocks = new List<PuzzleStepSO>();
|
||||
|
||||
/// <summary>
|
||||
/// Override Equals to compare by stepId rather than reference equality.
|
||||
/// This ensures consistent behavior across different platforms (Editor vs Mobile).
|
||||
/// </summary>
|
||||
/// <param name="obj">Object to compare to</param>
|
||||
/// <returns>True if the objects represent the same puzzle step</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null) return false;
|
||||
|
||||
// Check if the object is actually a PuzzleStepSO
|
||||
PuzzleStepSO other = obj as PuzzleStepSO;
|
||||
if (other == null) return false;
|
||||
|
||||
// Compare by stepId instead of reference
|
||||
return string.Equals(stepId, other.stepId, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override GetHashCode to be consistent with the Equals method.
|
||||
/// This is crucial for HashSet and Dictionary to work properly.
|
||||
/// </summary>
|
||||
/// <returns>Hash code based on stepId</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
// Generate hash code from stepId to ensure consistent hashing
|
||||
return stepId != null ? stepId.GetHashCode() : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override == operator to use our custom equality logic
|
||||
/// </summary>
|
||||
public static bool operator ==(PuzzleStepSO a, PuzzleStepSO b)
|
||||
{
|
||||
// Check if both are null or if they're the same instance
|
||||
if (ReferenceEquals(a, b))
|
||||
return true;
|
||||
|
||||
// Check if either is null (but not both, as that's handled above)
|
||||
if (((object)a == null) || ((object)b == null))
|
||||
return false;
|
||||
|
||||
// Use our custom Equals method
|
||||
return a.Equals(b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override != operator to be consistent with == operator
|
||||
/// </summary>
|
||||
public static bool operator !=(PuzzleStepSO a, PuzzleStepSO b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user