public void OnAllKilled(Actor[] actors, LuaFunction func) { var group = actors.ToList(); var copy = (LuaFunction)func.CopyReference(); Action<Actor> onMemberKilled = m => { try { group.Remove(m); if (!group.Any()) { copy.Call(); copy.Dispose(); } } catch (Exception e) { Context.FatalError(e.Message); } }; foreach (var a in group) GetScriptTriggers(a).OnKilledInternal += onMemberKilled; }
public void OnAllRemovedFromWorld(Actor[] actors, LuaFunction func) { var group = actors.ToList(); var f = (LuaFunction)func.CopyReference(); Action<Actor> onMemberRemoved = m => { try { if (!group.Remove(m)) return; if (!group.Any()) using (f) f.Call().Dispose(); } catch (Exception e) { Context.FatalError(e.Message); } }; foreach (var a in group) GetScriptTriggers(a).OnRemovedInternal += onMemberRemoved; }
public void refreshPlayersList(Actor[] actors) { PlayerList.Items.Clear(); Players = actors.ToList(); balancelist.Items.Clear(); foreach (Actor item in actors) { PlayerList.Items.Add(item.Name); balancelist.Items.Add(item.Money); PictureBox pictureBox = new PictureBox(); playerTokens[item.PlayerID].Location = pictureBoxes[item.Location].Location; if (proxy.username == item.Name) { usernamelb.Text = item.Name; balancelb.Text = item.Money.ToString(); } } }