Skip to content

Commit

Permalink
Allow Passing Data to CreateGameEntity
Browse files Browse the repository at this point in the history
  • Loading branch information
xenicle committed Nov 1, 2022
1 parent c7b33cb commit f8b31d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions GameEntityScript/GameEntityResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ namespace GameEntityScript
{
public class GameEntityResource : Resource
{

private void InitEntitySync()
{
AltEntitySync.Init(
1,
(threadId) => 100,
2,
(threadId) => 40,
(threadId) => true,
(threadCount, repository) => new ServerEventNetworkLayer(threadCount, repository),
(entity, threadCount) => (entity.Id % threadCount),
Expand All @@ -26,7 +27,7 @@ private void InitEntitySync()

private void RegisterExports()
{
Alt.Export("createGameEntity", new Func<long, Vector3, int, int, ulong>(this.CreateGameEntity));
Alt.Export("createGameEntity", new Func<long, Vector3, int, int, object, ulong>(this.CreateGameEntity));
Alt.Export("removeGameEntity", new Action<long, long>(this.RemoveGameEntity));
Alt.Export("doesGameEntityExist", new Func<long, long, bool>(this.DoesGameEntityExist));
Alt.Export("setGameEntityPosition", new Action<long, long, Vector3>(this.SetGameEntityPosition));
Expand All @@ -48,9 +49,9 @@ private void RegisterExports()
return entity;
}

private ulong CreateGameEntity(long type, Vector3 position, int dimension, int range)
private ulong CreateGameEntity(long type, Vector3 position, int dimension, int range, object data)
{
IEntity entity = AltEntitySync.CreateEntity((ulong) type, position, dimension, (uint) range);
IEntity entity = AltEntitySync.CreateEntity((ulong) type, position, dimension, (uint) range, (System.Collections.Generic.IDictionary<string, object>)data);

return entity.Id;
}
Expand Down
6 changes: 3 additions & 3 deletions GameEntityScript/GameEntityScript.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
Expand All @@ -19,9 +19,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AltV.Net" Version="12.0.1" />
<PackageReference Include="AltV.Net" Version="12.0.4" />
<PackageReference Include="AltV.Net.EntitySync" Version="1.18.0" />
<PackageReference Include="AltV.Net.EntitySync.ServerEvent" Version="12.0.1" />
<PackageReference Include="AltV.Net.EntitySync.ServerEvent" Version="12.0.4" />
</ItemGroup>

</Project>

0 comments on commit f8b31d7

Please sign in to comment.