Skip to content

Commit 4be7be0

Browse files
committed
Read the description for detailed changes.
- Added `Sandbox.Players`: a synchronized list of `NetworkPlayerId` structs representing connected players. - Added `Sandbox.Events.OnPlayerJoined` and `Sandbox.Events.OnPlayerLeft` callbacks, synchronized across all clients. - Changed internal interpolation of quaternions to use `Slerp` instead of `Lerp`. - Fixed a potential crash caused by undefined behavior when reaching `NetickConfig.MaxPlayers` and destroying network objects. - Fixed an issue where sandbox-loaded scenes were not being unloaded during shutdown. - Fixed a bug preventing Prediction Error Correction from functioning correctly.
1 parent 555796d commit 4be7be0

21 files changed

+1403
-1087
lines changed

Netick/Editor/Netick.CodeGen.dll

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

Netick/Runtime/Netick.Unity.dll

3.5 KB
Binary file not shown.

Netick/Runtime/Netick.Unity.xml

Lines changed: 602 additions & 384 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Netick/Runtime/Netick.dll

5 KB
Binary file not shown.

Netick/Runtime/Netick.xml

Lines changed: 256 additions & 205 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Samples~/Bomberman/Scenes/Bomberman.unity

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ RenderSettings:
3838
m_ReflectionIntensity: 1
3939
m_CustomReflection: {fileID: 0}
4040
m_Sun: {fileID: 0}
41-
m_IndirectSpecularColor: {r: 0.45137393, g: 0.50092196, b: 0.57263935, a: 1}
4241
m_UseRadianceAmbientProbe: 0
4342
--- !u!157 &3
4443
LightmapSettings:
@@ -123,6 +122,37 @@ NavMeshSettings:
123122
debug:
124123
m_Flags: 0
125124
m_NavMeshData: {fileID: 0}
125+
--- !u!1 &293298009
126+
GameObject:
127+
m_ObjectHideFlags: 0
128+
m_CorrespondingSourceObject: {fileID: 0}
129+
m_PrefabInstance: {fileID: 0}
130+
m_PrefabAsset: {fileID: 0}
131+
serializedVersion: 6
132+
m_Component:
133+
- component: {fileID: 293298010}
134+
m_Layer: 0
135+
m_Name: GameObject
136+
m_TagString: Untagged
137+
m_Icon: {fileID: 0}
138+
m_NavMeshLayer: 0
139+
m_StaticEditorFlags: 0
140+
m_IsActive: 1
141+
--- !u!4 &293298010
142+
Transform:
143+
m_ObjectHideFlags: 0
144+
m_CorrespondingSourceObject: {fileID: 0}
145+
m_PrefabInstance: {fileID: 0}
146+
m_PrefabAsset: {fileID: 0}
147+
m_GameObject: {fileID: 293298009}
148+
serializedVersion: 2
149+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
150+
m_LocalPosition: {x: -133.02965, y: 72.981926, z: 47.2627}
151+
m_LocalScale: {x: 1, y: 1, z: 1}
152+
m_ConstrainProportionsScale: 0
153+
m_Children: []
154+
m_Father: {fileID: 0}
155+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
126156
--- !u!1 &1070948396
127157
GameObject:
128158
m_ObjectHideFlags: 0
@@ -7204,3 +7234,4 @@ SceneRoots:
72047234
- {fileID: 1070948398}
72057235
- {fileID: 1809360484}
72067236
- {fileID: 3762179930698311635}
7237+
- {fileID: 293298010}

Samples~/Bomberman/Scripts/Block.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44

55
namespace Netick.Samples.Bomberman
66
{
7-
public class Block : NetworkBehaviour
8-
{
9-
// Networked Properties
10-
[Networked]
11-
public NetworkBool Visible { get; set; } = true;
7+
public class Block : NetworkBehaviour
8+
{
9+
// Networked Properties
10+
[Networked]
11+
public NetworkBool Visible { get; set; } = true;
1212

13-
[OnChanged(nameof(Visible))]
14-
private void OnVisibleChanged(OnChangedData onChangedData)
15-
{
16-
// for visual components, don't use "enabled" property when you want to disable/enable it, instead use SetEnabled().
17-
// -- GetComponent<Renderer>().enabled = Visible; #### Not like this.
13+
[OnChanged(nameof(Visible))]
14+
private void OnVisibleChanged(OnChangedData onChangedData)
15+
{
16+
// for visual components, don't use "enabled" property when you want to disable/enable it, instead use SetEnabled().
17+
// -- GetComponent<Renderer>().enabled = Visible; #### Not like this.
1818

19-
GetComponent<Renderer>().SetEnabled(Sandbox, Visible); // #### Like this.
19+
GetComponent<Renderer>().SetEnabled(Sandbox, Visible); // #### Like this.
2020

21-
GetComponent<BoxCollider>().enabled = Visible;
22-
}
21+
GetComponent<BoxCollider>().enabled = Visible;
2322
}
23+
}
2424
}
2525

Samples~/Bomberman/Scripts/Bomb.cs

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -5,68 +5,68 @@
55
namespace Netick.Samples.Bomberman
66
{
77

8-
public class Bomb : NetworkBehaviour
9-
{
10-
public GameObject ExplosionPrefab;
8+
public class Bomb : NetworkBehaviour
9+
{
10+
public GameObject ExplosionPrefab;
1111

12-
public BombermanController Bomber;
13-
public float ExplosionDelay = 3.0f;
12+
public BombermanController Bomber;
13+
public float ExplosionDelay = 3.0f;
1414

15-
private readonly Vector3[] _directionsAroundBomb = new Vector3[4] { Vector3.right, Vector3.left, Vector3.up, Vector3.down };
16-
private static RaycastHit[] _hits = new RaycastHit[20];
15+
private readonly Vector3[] _directionsAroundBomb = new Vector3[4] { Vector3.right, Vector3.left, Vector3.up, Vector3.down };
16+
private static RaycastHit[] _hits = new RaycastHit[20];
1717

18-
public override void NetworkStart()
19-
{
20-
Bomber?.SpawnedBombs.Add(this);
21-
GetComponent<Renderer>().enabled = true;
18+
public override void NetworkStart()
19+
{
20+
Bomber?.SpawnedBombs.Add(this);
21+
GetComponent<Renderer>().enabled = true;
2222
}
2323

24-
public override void NetworkDestroy()
25-
{
26-
Bomber?.SpawnedBombs.Remove(this);
24+
public override void NetworkDestroy()
25+
{
26+
Bomber?.SpawnedBombs.Remove(this);
2727

28-
// spawn explosion.
29-
if (ExplosionPrefab != null)
30-
Instantiate(ExplosionPrefab, transform.position, Quaternion.identity);
31-
}
28+
// spawn explosion.
29+
if (ExplosionPrefab != null)
30+
Instantiate(ExplosionPrefab, transform.position, Quaternion.identity);
31+
}
3232

33-
public override void NetworkFixedUpdate()
34-
{
35-
if (Sandbox.TickToTime(Sandbox.Tick - Object.SpawnTick) >= ExplosionDelay)
36-
Explode();
37-
}
33+
public override void NetworkFixedUpdate()
34+
{
35+
if (Sandbox.TickToTime(Sandbox.Tick - Object.SpawnTick) >= ExplosionDelay)
36+
Explode();
37+
}
3838

39-
private void Explode()
40-
{
41-
// hide bomb after delay.
42-
GetComponent<Renderer>().enabled = false;
39+
private void Explode()
40+
{
41+
// hide bomb after delay.
42+
GetComponent<Renderer>().enabled = false;
4343

44-
// dealing damage is done on the server only.
45-
if (IsServer)
46-
{
47-
DamageTargetsAroundBomb(transform.position);
48-
Sandbox.Destroy(Object);
49-
}
50-
}
51-
52-
private void DamageTargetsAroundBomb(Vector3 pos)
53-
{
54-
// find all objects around the bomb position.
55-
foreach (var dir in _directionsAroundBomb)
56-
{
57-
var hitsCount = Sandbox.Physics.Raycast(pos, dir, _hits, 1f);
44+
// dealing damage is done on the server only.
45+
if (IsServer)
46+
{
47+
DamageTargetsAroundBomb(transform.position);
48+
Sandbox.Destroy(Object);
49+
}
50+
}
5851

59-
for (int i = 0; i < hitsCount; i++)
60-
{
61-
var target =_hits[i].collider.gameObject;
62-
var block = target.GetComponent<Block>();
63-
var bomber = target.GetComponent<BombermanController>();
52+
private void DamageTargetsAroundBomb(Vector3 pos)
53+
{
54+
// find all objects around the bomb position.
55+
foreach (var dir in _directionsAroundBomb)
56+
{
57+
var hitsCount = Sandbox.Physics.Raycast(pos, dir, _hits, 1f);
6458

65-
if (block != null)
66-
block.Visible = false;
67-
bomber?.Die();
68-
}
69-
}
70-
}
71-
}
59+
for (int i = 0; i < hitsCount; i++)
60+
{
61+
var target = _hits[i].collider.gameObject;
62+
var block = target.GetComponent<Block>();
63+
var bomber = target.GetComponent<BombermanController>();
64+
65+
if (block != null)
66+
block.Visible = false;
67+
bomber?.Die();
68+
}
69+
}
70+
}
71+
}
7272
}

0 commit comments

Comments
 (0)