using Buddy.Wildstar.Game.Actors;
using System;
using System.Collections.Generic;
using System.Linq;
namespace SuperUltraGigaPotato
{
class BlackList
{
// Attributes.
private List<BlacklistEntry> blacklist;
// Constructor.
public BlackList()
{
blacklist = new List<BlacklistEntry>();
}
// Methods.
public void Add(Actor actor, int duration)
{
uint guid;
DateTime time;
// Sanity check.
if (actor == null || !actor.IsValid)
return;
// If it's already in, update it instead.
if (this.Get(actor) != null)
{
this.Get(actor).time = DateTime.Now.AddSeconds(duration);
return;
}
// Isn't in, lets add it.
guid = actor.Guid;
time = DateTime.Now.AddSeconds(duration);
blacklist.Add(new BlacklistEntry(guid, time));
}
public void Remove(Actor actor)
{
// Sanity check.
if (actor == null || !actor.IsValid)
return;
// Make sure it exists so we can remove it.
if (this.Contains(actor))
blacklist.Remove(Get(actor));
}
public bool Contains(Actor actor)
{
return this.blacklist.Any(o => o.guid == actor.Guid);
}
public BlacklistEntry Get(Actor actor)
{
return this.blacklist.FirstOrDefault(o => o.guid == actor.Guid);
}
}
class BlacklistEntry
{
internal uint guid;
internal DateTime time;
public BlacklistEntry(uint guid, DateTime time)
{
this.guid = guid;
this.time = time;
}
}
}