using UnityEngine; using System.Collections.Generic; using System; /// /// Context information passed to travel events for decision making /// [Serializable] public class TravelEventContext { public Vector2Int currentPosition; public MapTile currentTile; public TravelRoute currentRoute; public int dayOfJourney; public float timeOfDay; // 0-24 hours public Weather currentWeather = Weather.Clear; // Team state public List teamMembers; public int teamGold; public int teamFood; public float teamMorale = 1f; // Event tracking public TravelEventHistory eventHistory; // Travel context public Vector2Int destination; public bool isOnMainRoad; public float distanceToDestination; public TravelEventContext(Vector2Int position, MapTile tile, TravelRoute route) { currentPosition = position; currentTile = tile; currentRoute = route; eventHistory = new TravelEventHistory(); teamMembers = new List(); // Initialize with current team data var teamPlacement = UnityEngine.Object.FindFirstObjectByType(); if (teamPlacement != null) { // Get team data from the game // This would need to be implemented based on your team system } } } /// /// Tracks which events have occurred and when /// [Serializable] public class TravelEventHistory { [Serializable] public class EventOccurrence { public string eventName; public float dayOccurred; public Vector2Int location; } public List pastEvents = new List(); public bool HasOccurred(TravelEvent travelEvent) { return pastEvents.Exists(e => e.eventName == travelEvent.eventName); } public float GetTimeSinceLastOccurrence(TravelEvent travelEvent) { var lastOccurrence = pastEvents.FindLast(e => e.eventName == travelEvent.eventName); if (lastOccurrence == null) return float.MaxValue; // This would need to be implemented with actual game time return Time.time - lastOccurrence.dayOccurred; } public void RecordEvent(TravelEvent travelEvent, TravelEventContext context) { pastEvents.Add(new EventOccurrence { eventName = travelEvent.eventName, dayOccurred = context.dayOfJourney, location = context.currentPosition }); } } [Serializable] public enum Weather { Clear, Cloudy, Rain, Storm, Fog, Snow } /// /// Interface for objects that can handle travel event results /// public interface ITravelEventHandler { void HandleEventResult(EventResult result, TravelEventContext context); }