private static bool IsAcknowledged(Package package) { return Registry.Player.Values.Select(player => player.GetComponent<PlayerData>()).Where(playerData => playerData.playerType != PlayerData.PlayerType.Neutral).Any(playerData => playerData.AckwowledgedPackages.Contains(package.PackageId)); }
private void ClearAcknowledgedPacakgeFromPlayer(Package package) { foreach (var player in Registry.Player.Values) { player.GetComponent<PlayerData>().AckwowledgedPackages.Remove(package.PackageId); } }
/// <summary> /// Schedules an action to a specific turn. Adds action to a queue, if there are multiple events at the same turn scheduled. /// </summary> /// <param name="name">Action name.</param> /// <param name="turn">Turn number.</param> /// <param name="packageId">Package Id.</param> /// <param name="action">Action to be executed.</param> /// <param name="isVerified">True if acknowledged.</param> public void ScheduleAt(string name, long turn, int packageId, Action action, bool isVerified = false) { if(action != null) ++ScheduledTotal; // see if already an action is scheduld at turn, if so add to queue, if not, create new queue List<Package> queue; var p = new Package {Name = name, PackageId = packageId, Action = action, Verified = isVerified}; ExecuteOnMainThreadScheduled.TryGetValue(turn, out queue); if (queue == null) { ExecuteOnMainThreadScheduled.Add(turn, new List<Package> { p }); } else { Package package = null; foreach (var t in queue.Where(t => t.PackageId == packageId)) package = t; if (package == null) { queue.Add(p); } else { if (package.Action == null) package.Action = action; if (isVerified) { package.Verified = true; networkView.ScheduleBlinkOk(); } } } }