-
-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented entity transmit feature #608
Open
KillStr3aK
wants to merge
38
commits into
roflmuffin:main
Choose a base branch
from
KillStr3aK:feature/entity-transmit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
c7c0e8c
chore: bump to latest hl2sdk
KillStr3aK 35fca3f
feat: get interface `ISource2GameEntities`
KillStr3aK 850a389
feat: Add `CheckTransmit`
KillStr3aK 148fbf8
feat: Add `CheckTransmitPlayerSlot`
KillStr3aK 2e2771e
feat: Add hook and listener for `CheckTransmit`
KillStr3aK 01479af
feat: added `CheckTransmit` listener
KillStr3aK 265cfb8
feat: Added `CFixedBitVecBase` (thanks: qstage)
KillStr3aK ce19fe8
feat: implemented `CCheckTransmitInfoList` and added `CCheckTransmitI…
KillStr3aK 9d03cb4
feat: added example for `CheckTransmit` listener
KillStr3aK 82a2346
Merge branch 'roflmuffin:main' into feature/entity-transmit
KillStr3aK 23f625b
feat: added `WithCheckTransmit` example
KillStr3aK 3519a95
Merge branch 'feature/entity-transmit' of https://github.com/KillStr3…
KillStr3aK 0cdbc1d
fix: added check for self
KillStr3aK 46c323f
chore: update and extended examples
KillStr3aK c12ed80
fix: continue instead of return
KillStr3aK d479cac
tweak: reuse code from utils
KillStr3aK c507f6f
tweak: renamed to `TransmitEntities`
KillStr3aK 6c1125f
feat: `CFixedBitVecBase::Write`
KillStr3aK e6a1248
tweak: adjusted naming
KillStr3aK b20aaa5
feat: methods with `CEntityInstance` params
KillStr3aK 9a69a63
tweak: adjusted changes
KillStr3aK 0eac0a9
tweak: adjusted
KillStr3aK 17170b5
Merge branch 'roflmuffin:main' into feature/entity-transmit
KillStr3aK a3d5e14
feat: added `TransmitAlways` to `CCheckTransmitInfo`
KillStr3aK 6fd68b5
feat: added wrapper `CCheckTransmitInfoList`
KillStr3aK 2c9db33
tweak: removed `infoCount`
KillStr3aK a99cd58
tweak: adjusted changes and supports `Count`
KillStr3aK 663f07e
tweak: adjusted changes
KillStr3aK 6f9e465
feat: throw exception when oob
KillStr3aK 3ed0c0d
tweak: break down code
KillStr3aK 6782b93
style: adjusted code
KillStr3aK 700550d
style: adjusted code
KillStr3aK c516cce
fix: adjusted code to return full info
KillStr3aK daf35f5
tweak: `CCheckTransmitInfoList.Get` is now private
KillStr3aK 441485a
style: fix indentitation
KillStr3aK c161dcc
Merge branch 'main' into feature/entity-transmit
KillStr3aK f887fed
Merge branch 'main' into feature/entity-transmit
KillStr3aK dd24d8c
Merge branch 'main' into feature/entity-transmit
KillStr3aK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# With CheckTransmit | ||
This example shows how to work with the `CheckTransmit` listener. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\managed\CounterStrikeSharp.API\CounterStrikeSharp.API.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using CounterStrikeSharp.API; | ||
using CounterStrikeSharp.API.Core; | ||
using CounterStrikeSharp.API.Core.Attributes; | ||
|
||
namespace WithCheckTransmit; | ||
|
||
[MinimumApiVersion(276)] | ||
public class WithCheckTransmitPlugin : BasePlugin | ||
{ | ||
public override string ModuleName => "Example: With CheckTransmit"; | ||
public override string ModuleVersion => "1.0.0"; | ||
public override string ModuleAuthor => "CounterStrikeSharp & Contributors"; | ||
public override string ModuleDescription => "A simple plugin that uses the CheckTransmit listener!"; | ||
|
||
public override void Load(bool hotReload) | ||
{ | ||
RegisterListener<Listeners.CheckTransmit>((CCheckTransmitInfoList infoList, int infoCount) => | ||
{ | ||
// Get the list of the current players, we only work with this value later on | ||
List<CCSPlayerController> players = Utilities.GetPlayers(); | ||
|
||
for (int i = 0; i < infoCount; i++) | ||
{ | ||
// The 'Get' function returns a tuple with the info for the given index, also the slot the info belongs to. | ||
// You should never pass an integer outside of the boundaries! (0 <= index < infoCount) | ||
(CCheckTransmitInfo info, int slot) = infoList.Get(i); | ||
|
||
// We can use the slot to get the player the info belongs to | ||
CCSPlayerController? infoPlayer = Utilities.GetPlayerFromSlot(slot); | ||
|
||
// If no player is found, we can return | ||
if (infoPlayer == null) | ||
{ | ||
return; | ||
} | ||
|
||
// Otherwise, lets do the work: | ||
|
||
// as an example, lets hide everyone for this player who is in the same team. | ||
IEnumerable<CCSPlayerController> targetPlayers = players.Where(p => | ||
// is the player and its pawn valid | ||
p.IsValid && p.Pawn.IsValid && | ||
|
||
// is the player is in the same team | ||
p.Team == infoPlayer.Team && | ||
|
||
// is alive | ||
p.PlayerPawn.Value?.LifeState == (byte)LifeState_t.LIFE_ALIVE | ||
); | ||
|
||
foreach (CCSPlayerController targetPlayer in targetPlayers) | ||
{ | ||
// Calling 'Clear' will remove the entity index of the target player pawn from the transmission list | ||
// so it won't be transmitted for the 'infoPlayer' player. | ||
info.TransmitEntity.Clear(targetPlayer.Pawn.Index); | ||
} | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.12.35309.182 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestPlugin", "TestPlugin\TestPlugin.csproj", "{57E64289-5D69-4AA1-BEF0-D0D96A55EE8F}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CounterStrikeSharp.API", "CounterStrikeSharp.API\CounterStrikeSharp.API.csproj", "{55B47E41-61AA-4D75-9069-CB14328107B7}" | ||
|
@@ -42,6 +45,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WithSharedTypesConsumer", " | |
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WithUserMessages", "..\examples\WithUserMessages\WithUserMessages.csproj", "{A14029BA-CADE-4F25-ADC5-48CF14332F61}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WithCheckTransmit", "..\examples\WithCheckTransmit\WithCheckTransmit.csproj", "{854B06B5-0E7B-438A-BA51-3F299557F884}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
|
@@ -108,14 +113,14 @@ Global | |
{6FA3107D-42AF-42A0-BF51-2230D13268B5}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{6FA3107D-42AF-42A0-BF51-2230D13268B5}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{6FA3107D-42AF-42A0-BF51-2230D13268B5}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{4E5289B5-E81D-421C-B340-B98B6FFE09D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4E5289B5-E81D-421C-B340-B98B6FFE09D1}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4E5289B5-E81D-421C-B340-B98B6FFE09D1}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4E5289B5-E81D-421C-B340-B98B6FFE09D1}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{1309954E-FAF7-47A5-9FF9-C7263B33E4E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{1309954E-FAF7-47A5-9FF9-C7263B33E4E3}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{1309954E-FAF7-47A5-9FF9-C7263B33E4E3}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{1309954E-FAF7-47A5-9FF9-C7263B33E4E3}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{4E5289B5-E81D-421C-B340-B98B6FFE09D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4E5289B5-E81D-421C-B340-B98B6FFE09D1}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4E5289B5-E81D-421C-B340-B98B6FFE09D1}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4E5289B5-E81D-421C-B340-B98B6FFE09D1}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{A37676EA-CF2F-424D-85A1-C359D07A679D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{A37676EA-CF2F-424D-85A1-C359D07A679D}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{A37676EA-CF2F-424D-85A1-C359D07A679D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
|
@@ -128,6 +133,13 @@ Global | |
{A14029BA-CADE-4F25-ADC5-48CF14332F61}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{A14029BA-CADE-4F25-ADC5-48CF14332F61}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{A14029BA-CADE-4F25-ADC5-48CF14332F61}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{854B06B5-0E7B-438A-BA51-3F299557F884}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{854B06B5-0E7B-438A-BA51-3F299557F884}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{854B06B5-0E7B-438A-BA51-3F299557F884}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{854B06B5-0E7B-438A-BA51-3F299557F884}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{57E64289-5D69-4AA1-BEF0-D0D96A55EE8F} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A} | ||
|
@@ -141,10 +153,14 @@ Global | |
{31EABE0B-871F-497B-BF36-37FFC6FAD15F} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A} | ||
{BB44E08E-CCA8-4E22-A132-11B2F69D1890} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A} | ||
{6FA3107D-42AF-42A0-BF51-2230D13268B5} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A} | ||
{4E5289B5-E81D-421C-B340-B98B6FFE09D1} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A} | ||
{1309954E-FAF7-47A5-9FF9-C7263B33E4E3} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A} | ||
{4E5289B5-E81D-421C-B340-B98B6FFE09D1} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A} | ||
{A37676EA-CF2F-424D-85A1-C359D07A679D} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A} | ||
{76AD7BB0-A096-4336-83E2-B32CAE4E9933} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A} | ||
{A14029BA-CADE-4F25-ADC5-48CF14332F61} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A} | ||
{854B06B5-0E7B-438A-BA51-3F299557F884} = {7DF99C35-881D-4FF2-B1C9-246BD3DECB9A} | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {069C4CD4-BACA-446A-A6B8-0194E4F75355} | ||
Comment on lines
+163
to
+164
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure about these, probably was autogenerated when saving |
||
EndGlobalSection | ||
EndGlobal |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure about these, probably was autogenerated when saving