public override void Start() { base.Start(); void UpdatePlayer(Owner player) => OnVisionChanged?.Invoke(player, GetCurrentVision(player)); void Update(Placer placer) { foreach ( var player in Ecs.SystemManager .GetSystem <Ownership>().Subjects .Where(p => IsVisible(p, placer.Position))) { UpdatePlayer(player); } } var area = Ecs.SystemManager.GetSystem <Area>(); area.OnRemove += Update; area.OnPlace += Update; Ecs.SystemManager.GetSystem <Ownership>().OnPlayerCreated += p => { p.OnOwnedAdded += o => UpdatePlayer(p); p.OnOwnedRemoved += o => UpdatePlayer(p); }; }
private static void CheckVisionChanged() { for (var i = 0; i < VisionHeroesTuple.Count; i++) { var tuple = VisionHeroesTuple[i]; if (tuple.Item1.IsVisible != tuple.Item2) { OnVisionChanged?.Invoke(tuple.Item1.IsVisible, tuple.Item1); VisionHeroesTuple[i] = new Tuple <AIHeroClient, bool>(tuple.Item1, tuple.Item1.IsVisible); } } }