This is part of my Debriefing Script (work in progress)

I store the playernames of the players which use a plane with timestamps and position for entering and leaving. So i can decide to evaluate the usage of an actor. If a player leaves the plane short before it is Killed, i can get the players using this plane anyway

.
Code:
public class ActorUsage
{
public class CrewMember
{
public string CrewmanName { get; set; }
public int CrewmanPlace { get; set; }
internal DateTime EnterTime { get; set; }
internal DateTime LeaveTime { get; set; }
internal Point3d EnterPlanePos { get; set; }
internal Point3d LeavePlanePos { get; set; }
public CrewMember(Player player, int placeIndex, Point3d enterPos)
{
this.CrewmanName = player.Name();
this.CrewmanPlace = placeIndex;
this.EnterPlanePos = enterPos;
this.EnterTime = DateTime.Now;
}
}
public class ActorDetails
{
public AiActor actor { get; set; }
public AiAirport StartAirport { get; set; }
public bool AircraftUsed = false;
public bool AircraftDamaged = false;
public List<CrewMember> CrewHistory = new List<CrewMember>();
public bool IsActorAirborne(AiActor actor)
{
if (actor == null
|| !actor.IsAlive()
|| !(actor as AiAircraft).IsAirborne()
|| (actor as AiAircraft).getParameter(part.ParameterTypes.Z_AltitudeAGL, -1) <= 2.0
|| (actor as AiAircraft).getParameter(part.ParameterTypes.Z_VelocityTAS, -1) <= 1.0
)
{
return false;
}
else
return true;
}
}
public List<ActorDetails> ActorHistory = new List<ActorDetails>();
public void PlaceEnter(Player player, AiActor actor, int placeIndex)
{
if (actor != null && !ActorHistory.Exists(item => item.actor == actor))
{
ActorDetails NewActor = new ActorDetails();
NewActor.actor = actor;
NewActor.CrewHistory.Add(new CrewMember(player, placeIndex, (actor as AiAircraft).Pos()));
ActorHistory.Add(NewActor);
}
else if (actor != null)
{
int i = ActorHistory.FindIndex(item => item.actor == actor);
if (ActorHistory[i].CrewHistory.Exists(item => item.CrewmanName.Equals(player.Name())))
{
int j = ActorHistory[i].CrewHistory.FindIndex(item => item.CrewmanName.Equals(player.Name()));
ActorHistory[i].CrewHistory[j].CrewmanPlace = placeIndex;
}
else
{
ActorHistory[i].CrewHistory.Add(new CrewMember(player, placeIndex, (actor as AiAircraft).Pos()));
}
}
}
public void PlaceLeave(Player player, AiActor actor, int placeIndex)
{
if (actor != null && ActorHistory.Exists(item => item.actor == actor))
{
int i = ActorHistory.FindIndex(item => item.actor == actor);
if (ActorHistory[i].CrewHistory.Exists(item => item.CrewmanName.Equals(player.Name())))
{
int j = ActorHistory[i].CrewHistory.FindIndex(item => item.CrewmanName.Equals(player.Name()));
Point3d tmpPoint = ActorHistory[i].CrewHistory[j].EnterPlanePos;
if ((actor as AiAircraft).Pos().distance(ref tmpPoint) < 1)
{
ActorHistory[i].CrewHistory.RemoveAt(j); // no position changes of plane so delete the crewman entry
}
else
{
ActorHistory[i].CrewHistory[j].LeavePlanePos = (actor as AiAircraft).Pos();
ActorHistory[i].CrewHistory[j].LeaveTime = DateTime.Now;
ActorHistory[i].AircraftUsed = true;
}
}
}
}
public List<KeyValuePair<string, int>> ActorDead(AiActor actor)
{
List<KeyValuePair<string, int>> tmpActorPlace = new List<KeyValuePair<string, int>>();
if (ActorHistory.Exists(item => item.actor == actor))
{
int i = ActorHistory.FindIndex(item => item.actor == actor);
ActorHistory[i].CrewHistory.ForEach(item =>
{
tmpActorPlace.Add(new KeyValuePair<string, int>(item.CrewmanName, item.CrewmanPlace));
});
return tmpActorPlace;
}
else return null;
}
public List<AiActor> GetActors()
{
List<AiActor> tmpActors = new List<AiActor>();
foreach (ActorDetails ad in ActorHistory)
{
tmpActors.Add(ad.actor);
}
return tmpActors;
}
public List<string> GetActorPlayer()
{
List<string> tmpStrings = new List<string>();
foreach (ActorDetails ad in ActorHistory)
{
foreach (CrewMember cm in ad.CrewHistory)
{
tmpStrings.Add(ad.actor.Name().ToString() + "::" + ad.AircraftUsed + "::" + cm.CrewmanName + "::" + cm.CrewmanPlace.ToString() + "::" + cm.EnterTime.ToShortTimeString() + "::" + cm.LeaveTime.ToShortTimeString());
}
}
return tmpStrings;
}
}