TravelEventContext.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3. using System;
  4. /// <summary>
  5. /// Context information passed to travel events for decision making
  6. /// </summary>
  7. [Serializable]
  8. public class TravelEventContext
  9. {
  10. public Vector2Int currentPosition;
  11. public MapTile currentTile;
  12. public TravelRoute currentRoute;
  13. public int dayOfJourney;
  14. public float timeOfDay; // 0-24 hours
  15. public Weather currentWeather = Weather.Clear;
  16. // Team state
  17. public List<TeamCharacter> teamMembers;
  18. public int teamGold;
  19. public int teamFood;
  20. public float teamMorale = 1f;
  21. // Event tracking
  22. public TravelEventHistory eventHistory;
  23. // Travel context
  24. public Vector2Int destination;
  25. public bool isOnMainRoad;
  26. public float distanceToDestination;
  27. public TravelEventContext(Vector2Int position, MapTile tile, TravelRoute route)
  28. {
  29. currentPosition = position;
  30. currentTile = tile;
  31. currentRoute = route;
  32. eventHistory = new TravelEventHistory();
  33. teamMembers = new List<TeamCharacter>();
  34. // Initialize with current team data
  35. var teamPlacement = UnityEngine.Object.FindFirstObjectByType<SimpleTeamPlacement>();
  36. if (teamPlacement != null)
  37. {
  38. // Get team data from the game
  39. // This would need to be implemented based on your team system
  40. }
  41. }
  42. }
  43. /// <summary>
  44. /// Tracks which events have occurred and when
  45. /// </summary>
  46. [Serializable]
  47. public class TravelEventHistory
  48. {
  49. [Serializable]
  50. public class EventOccurrence
  51. {
  52. public string eventName;
  53. public float dayOccurred;
  54. public Vector2Int location;
  55. }
  56. public List<EventOccurrence> pastEvents = new List<EventOccurrence>();
  57. public bool HasOccurred(TravelEvent travelEvent)
  58. {
  59. return pastEvents.Exists(e => e.eventName == travelEvent.eventName);
  60. }
  61. public float GetTimeSinceLastOccurrence(TravelEvent travelEvent)
  62. {
  63. var lastOccurrence = pastEvents.FindLast(e => e.eventName == travelEvent.eventName);
  64. if (lastOccurrence == null) return float.MaxValue;
  65. // This would need to be implemented with actual game time
  66. return Time.time - lastOccurrence.dayOccurred;
  67. }
  68. public void RecordEvent(TravelEvent travelEvent, TravelEventContext context)
  69. {
  70. pastEvents.Add(new EventOccurrence
  71. {
  72. eventName = travelEvent.eventName,
  73. dayOccurred = context.dayOfJourney,
  74. location = context.currentPosition
  75. });
  76. }
  77. }
  78. [Serializable]
  79. public enum Weather
  80. {
  81. Clear,
  82. Cloudy,
  83. Rain,
  84. Storm,
  85. Fog,
  86. Snow
  87. }
  88. /// <summary>
  89. /// Interface for objects that can handle travel event results
  90. /// </summary>
  91. public interface ITravelEventHandler
  92. {
  93. void HandleEventResult(EventResult result, TravelEventContext context);
  94. }