public override void Save(BaseNetworkable.SaveInfo info) { base.Save(info); info.msg.relationshipManager = Pool.Get <ProtoBuf.RelationshipManager>(); info.msg.relationshipManager.maxTeamSize = RelationshipManager.maxTeamSize; if (info.forDisk) { info.msg.relationshipManager.lastTeamIndex = this.lastTeamIndex; info.msg.relationshipManager.teamList = Pool.GetList <ProtoBuf.PlayerTeam>(); foreach (KeyValuePair <ulong, RelationshipManager.PlayerTeam> playerTeam in this.playerTeams) { RelationshipManager.PlayerTeam value = playerTeam.Value; if (value == null) { continue; } ProtoBuf.PlayerTeam list = Pool.Get <ProtoBuf.PlayerTeam>(); list.teamLeader = value.teamLeader; list.teamID = value.teamID; list.teamName = value.teamName; list.members = Pool.GetList <ProtoBuf.PlayerTeam.TeamMember>(); foreach (ulong member in value.members) { ProtoBuf.PlayerTeam.TeamMember teamMember = Pool.Get <ProtoBuf.PlayerTeam.TeamMember>(); BasePlayer basePlayer = RelationshipManager.FindByID(member); teamMember.displayName = (basePlayer != null ? basePlayer.displayName : "DEAD"); teamMember.userID = member; list.members.Add(teamMember); } info.msg.relationshipManager.teamList.Add(list); } } }
public bool RemovePlayer(ulong playerID) { if (!this.members.Contains(playerID)) { return(false); } this.members.Remove(playerID); BasePlayer basePlayer = RelationshipManager.FindByID(playerID); if (basePlayer != null) { basePlayer.ClearTeam(); } if (this.teamLeader == playerID) { if (this.members.Count <= 0) { this.Disband(); } else { this.SetTeamLeader(this.members[0]); } } this.MarkDirty(); return(true); }
private List <DamageGroup> GetDamageGroups() { var result = new List <DamageGroup>(); foreach (var damage in damageEntries) { bool merged = false; foreach (var dT in result) { if (dT.TryMergeDamage(damage.Key, damage.Value.DamageDealt)) { merged = true; break; } } if (!merged) { if (RelationshipManager.FindByID(damage.Key) == null) { Instance.PrintError($"Invalid id, unable to find: {damage.Key}"); continue; } result.Add(new DamageGroup(damage.Key, damage.Value.DamageDealt)); } } return(result); }
public bool RemovePlayer(ulong playerID) { if (!this.members.Contains(playerID)) { return(false); } this.members.Remove(playerID); BasePlayer byId = RelationshipManager.FindByID(playerID); if (Object.op_Inequality((Object)byId, (Object)null)) { byId.ClearTeam(); } if ((long)this.teamLeader == (long)playerID) { if (this.members.Count > 0) { this.SetTeamLeader(this.members[0]); } else { this.Disband(); } } this.MarkDirty(); return(true); }
public override void Execute() { AppMapMarkers appMapMarkers = Pool.Get <AppMapMarkers>(); appMapMarkers.markers = Pool.GetList <AppMarker>(); RelationshipManager.PlayerTeam playerTeam = RelationshipManager.ServerInstance.FindPlayersTeam(base.UserId); if (playerTeam != null) { foreach (ulong member in playerTeam.members) { BasePlayer basePlayer = RelationshipManager.FindByID(member); if (!(basePlayer == null)) { appMapMarkers.markers.Add(GetPlayerMarker(basePlayer)); } } } else if (base.Player != null) { appMapMarkers.markers.Add(GetPlayerMarker(base.Player)); } foreach (MapMarker serverMapMarker in MapMarker.serverMapMarkers) { if (serverMapMarker.appType != 0) { appMapMarkers.markers.Add(serverMapMarker.GetAppMarkerData()); } } AppResponse appResponse = Pool.Get <AppResponse>(); appResponse.mapMarkers = appMapMarkers; Send(appResponse); }
public override void Save(BaseNetworkable.SaveInfo info) { base.Save(info); info.msg.relationshipManager = (__Null)Pool.Get <RelationshipManager>(); ((RelationshipManager)info.msg.relationshipManager).maxTeamSize = (__Null)RelationshipManager.maxTeamSize; if (!info.forDisk) { return; } ((RelationshipManager)info.msg.relationshipManager).lastTeamIndex = (__Null)(long)this.lastTeamIndex; ((RelationshipManager)info.msg.relationshipManager).teamList = (__Null)Pool.GetList <ProtoBuf.PlayerTeam>(); foreach (KeyValuePair <ulong, RelationshipManager.PlayerTeam> playerTeam1 in this.playerTeams) { RelationshipManager.PlayerTeam playerTeam2 = playerTeam1.Value; if (playerTeam2 != null) { ProtoBuf.PlayerTeam playerTeam3 = (ProtoBuf.PlayerTeam)Pool.Get <ProtoBuf.PlayerTeam>(); playerTeam3.teamLeader = (__Null)(long)playerTeam2.teamLeader; playerTeam3.teamID = (__Null)(long)playerTeam2.teamID; playerTeam3.teamName = (__Null)playerTeam2.teamName; playerTeam3.members = (__Null)Pool.GetList <ProtoBuf.PlayerTeam.TeamMember>(); foreach (ulong member in playerTeam2.members) { ProtoBuf.PlayerTeam.TeamMember teamMember = (ProtoBuf.PlayerTeam.TeamMember)Pool.Get <ProtoBuf.PlayerTeam.TeamMember>(); BasePlayer byId = RelationshipManager.FindByID(member); teamMember.displayName = Object.op_Inequality((Object)byId, (Object)null) ? (__Null)byId.displayName : (__Null)"DEAD"; teamMember.userID = (__Null)(long)member; ((List <ProtoBuf.PlayerTeam.TeamMember>)playerTeam3.members).Add(teamMember); } ((List <ProtoBuf.PlayerTeam>)((RelationshipManager)info.msg.relationshipManager).teamList).Add(playerTeam3); } } }
public DamageGroup(ulong playerId, float damage) { TotalDamage = damage; FirstDamagerDealer = playerId; if (!Instance.config.UseTeams) { return; } var target = RelationshipManager.FindByID(playerId); if (!target.IsValid()) { return; } RelationshipManager.PlayerTeam team; if (!RelationshipManager.Instance.playerToTeam.TryGetValue(playerId, out team)) { return; } for (int i = 0; i < team.members.Count; i++) { ulong member = team.members[i]; if (member == playerId) { continue; } additionalPlayers.Add(member); } }
public void Cleanup() { for (int index = this.members.Count - 1; index >= 0; --index) { ulong member = this.members[index]; if (Object.op_Equality((Object)RelationshipManager.FindByID(member), (Object)null)) { this.members.Remove(member); } } }
public void Cleanup() { for (int i = this.members.Count - 1; i >= 0; i--) { ulong item = this.members[i]; if (RelationshipManager.FindByID(item) == null) { this.members.Remove(item); } } }
public void MarkDirty() { foreach (ulong member in this.members) { BasePlayer byId = RelationshipManager.FindByID(member); if (Object.op_Inequality((Object)byId, (Object)null)) { byId.UpdateTeam(this.teamID); } } }
public void MarkDirty() { foreach (ulong member in this.members) { BasePlayer basePlayer = RelationshipManager.FindByID(member); if (basePlayer == null) { continue; } basePlayer.UpdateTeam(this.teamID); } }
private string getLineForPlayer(ulong playerId, string color, DamageInfo damageInfo) { var displayName = RelationshipManager.FindByID(playerId)?.displayName ?? Instance.covalence.Players.FindPlayerById(playerId.ToString())?.Name ?? playerId.ToString(); float damage = 0.0f; if (damageInfo.damageEntries.ContainsKey(playerId)) { damage = damageInfo.damageEntries[playerId].DamageDealt; } string damageLine = string.Format("{0:0}%", damage / damageInfo.FullDamage * 100); return($"<color={color}>{displayName}</color> {damageLine}"); }
public void DisplayDamageReport() { foreach (var damager in damageEntries.Keys) { var player = RelationshipManager.FindByID(damager); if (!player.IsValid()) { continue; } Instance.SendReply(player, GetDamageReport(player.UserIDString)); } }
public void SendInvite(BasePlayer player) { if (this.invites.Count > 8) { this.invites.RemoveRange(0, 1); } BasePlayer byId = RelationshipManager.FindByID(this.teamLeader); if (Object.op_Equality((Object)byId, (Object)null)) { return; } this.invites.Add(player.userID); player.ClientRPCPlayer <string, ulong>((Connection)null, player, "CLIENT_PendingInvite", byId.displayName, this.teamID); }
public void SendInvite(BasePlayer player) { if (this.invites.Count > 8) { this.invites.RemoveRange(0, 1); } BasePlayer basePlayer = RelationshipManager.FindByID(this.teamLeader); if (basePlayer == null) { return; } this.invites.Add(player.userID); player.ClientRPCPlayer <string, ulong>(null, player, "CLIENT_PendingInvite", basePlayer.displayName, this.teamID); }
private void Unload() { foreach (var god in storedData.godPlayers) { var player = RelationshipManager.FindByID(ulong.Parse(god)); if (player == null) { continue; } ModifyMetabolism(player, false); if (configData.showNamePrefix) { Rename(player, false); } } SaveData(); }
private void OnServerInitialized() { foreach (var god in storedData.godPlayers) { var player = RelationshipManager.FindByID(ulong.Parse(god)); if (player == null) { continue; } ModifyMetabolism(player, true); if (configData.showNamePrefix) { Rename(player, true); } } CheckOnlineGods(); }
public static void SendNotification(this RelationshipManager.PlayerTeam team, NotificationChannel channel, string title, string body, Dictionary <string, string> data, ulong ignorePlayer = 0uL) { List <ulong> obj = Facepunch.Pool.GetList <ulong>(); foreach (ulong member in team.members) { if (member != ignorePlayer) { BasePlayer basePlayer = RelationshipManager.FindByID(member); if (basePlayer == null || basePlayer.net?.connection == null) { obj.Add(member); } } } NotificationList.SendNotificationTo(obj, channel, title, body, data); Facepunch.Pool.FreeList(ref obj); }
public static AppTeamInfo GetAppTeamInfo(this RelationshipManager.PlayerTeam team, ulong requesterSteamId) { AppTeamInfo appTeamInfo = Pool.Get <AppTeamInfo>(); appTeamInfo.members = Pool.GetList <AppTeamInfo.Member>(); BasePlayer player = null; BasePlayer basePlayer = null; for (int i = 0; i < team.members.Count; i++) { ulong num = team.members[i]; BasePlayer basePlayer2 = RelationshipManager.FindByID(num); if (!basePlayer2) { basePlayer2 = null; } if (num == requesterSteamId) { player = basePlayer2; } if (num == team.teamLeader) { basePlayer = basePlayer2; } Vector2 vector = Util.WorldToMap(basePlayer2?.transform.position ?? Vector3.zero); AppTeamInfo.Member member = Pool.Get <AppTeamInfo.Member>(); member.steamId = num; member.name = basePlayer2?.displayName ?? SingletonComponent <ServerMgr> .Instance.persistance.GetPlayerName(num) ?? ""; member.x = vector.x; member.y = vector.y; member.isOnline = basePlayer2?.IsConnected ?? false; member.spawnTime = basePlayer2?.lifeStory?.timeBorn ?? 0; member.isAlive = basePlayer2?.IsAlive() ?? false; member.deathTime = basePlayer2?.previousLifeStory?.timeDied ?? 0; appTeamInfo.members.Add(member); } appTeamInfo.leaderSteamId = team.teamLeader; appTeamInfo.mapNotes = GetMapNotes(player, true); appTeamInfo.leaderMapNotes = GetMapNotes((requesterSteamId != team.teamLeader) ? basePlayer : null, false); return(appTeamInfo); }
public BasePlayer GetMember(ulong userID) { return(RelationshipManager.FindByID(userID)); }
public BasePlayer GetLeader() { return(RelationshipManager.FindByID(this.teamLeader)); }
private object OnUserChat(IPlayer player, string message) { #endif if (message.Length > _instance._config.MaxMessageLength) { message = message.Substring(0, _instance._config.MaxMessageLength); } BetterChatMessage chatMessage = ChatGroup.FormatMessage(player, message); if (chatMessage == null) { return(null); } Dictionary <string, object> chatMessageDict = chatMessage.ToDictionary(); #if RUST chatMessageDict.Add("ChatChannel", chatchannel); #endif foreach (Plugin plugin in plugins.GetAll()) { object hookResult = plugin.CallHook("OnBetterChat", chatMessageDict); if (hookResult is Dictionary <string, object> ) { try { chatMessageDict = hookResult as Dictionary <string, object>; } catch (Exception e) { PrintError($"Failed to load modified OnBetterChat hook data from plugin '{plugin.Title} ({plugin.Version})':{Environment.NewLine}{e}"); continue; } } else if (hookResult != null) { return(null); } } chatMessage = BetterChatMessage.FromDictionary(chatMessageDict); switch (chatMessage.CancelOption) { case BetterChatMessage.CancelOptions.BetterChatOnly: return(null); case BetterChatMessage.CancelOptions.BetterChatAndDefault: return(true); } var output = chatMessage.GetOutput(); #if RUST switch (chatchannel) { case Chat.ChatChannel.Team: RelationshipManager.PlayerTeam team = BasePlayer.Find(player.Id).Team; if (team == null || team.members.Count == 0) { return(true); } List <Connection> onlineMemberConnections = new List <Connection>(); foreach (ulong userID in team.members) { BasePlayer basePlayer = RelationshipManager.FindByID(userID); if (!(basePlayer == null) && basePlayer.Connection != null && !chatMessage.BlockedReceivers.Contains(basePlayer.UserIDString)) { onlineMemberConnections.Add(basePlayer.Connection); } } ConsoleNetwork.SendClientCommand(onlineMemberConnections, "chat.add", new object[] { (int)chatchannel, player.Id, output.Chat }); break; default: foreach (BasePlayer p in BasePlayer.activePlayerList.Where(p => !chatMessage.BlockedReceivers.Contains(p.UserIDString))) { p.SendConsoleCommand("chat.add", new object[] { (int)chatchannel, player.Id, output.Chat }); } break; } #else foreach (IPlayer p in players.Connected.Where(p => !chatMessage.BlockedReceivers.Contains(p.Id))) { p.Message(output.Chat); } #endif #if RUST Puts($"[{chatchannel}] {output.Console}"); RCon.Broadcast(RCon.LogType.Chat, new Chat.ChatEntry { Channel = chatchannel, Message = output.Console, UserId = player.Id, Username = player.Name, Color = chatMessage.UsernameSettings.Color, Time = Epoch.Current }); #else Puts(output.Console); #endif return(true); }