Closed mattkrins closed 11 months ago
Using the tag system for this would be awesome. e.g.
/// <summary>
/// A mine entity that should only be networked to players on a particular team.
/// </summary>
public partial class MineEntity : Entity
{
...
public override void Spawn()
{
base.Spawn();
// This entity should only transmit to players in its PVS.
this.Transmit = TransmitType.Pvs;
// This entity should only transmit to players in its PVS that are on its team or that have knowledge of it (spys and minesweepers).
this.TransmitTags.WithAnyTags(this.Team.Name, "spy", "minesweeper");
...
}
...
}
/// <summary>
/// An objective entity that should only be networked to players on a particular team.
/// </summary>
public partial class TeamObjectiveEntity : Entity
{
...
public override void Spawn()
{
base.Spawn();
// This entity should always transmit.
this.Transmit = TransmitType.Always;
// This entity should always transmit to players on its team or that are spys.
this.TransmitTags.WithAnyTags(this.Team.Name, "spy");
...
}
...
}
@garrynewman I'm assuming this will be addressed by the retooling?
For?
S&Box
What can't you do?
I do not see any equivalent of https://wiki.facepunch.com/gmod/Entity:SetPreventTransmit yet in the S&box wiki. Following in from https://forum.facepunch.com/t/logically-sperating-players-and-entities/1839 I would like a way to logically separate entities so they can inhabit the same space, but not know of the others existence.
There are many instances where some players will have no need to know about other entities on the server until necessary. This functionality will be particularly useful when optimizing for large numbers of players.
How would you like it to work?
client/entity 0 and client/entity 1 connect to the same server, but before the server passes any data about any other entities to them, transmit is prevented between entity 0 and 1. From this point on, no additional entity data will need to be sent from the server to these clients and the entities can not interact with each other in any way. At some future point (maybe when x amount of players have connected for example), entity 1 and 0 are allowed to transmit again and can now interact with each other.
What have you tried?
As a workaround one could theoretically disable collision between entities and make them invisible, however this is very hacky and unreliable. Additionally, each entity is still receiving data about the other which is unnecessary where processing resources could be saved on the server and clients involved.
Additional context
Additional reading: https://forum.facepunch.com/t/logically-sperating-players-and-entities/1839 https://forum.facepunch.com/t/suggestion-more-control-power-over-networking-instances/2172