-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
1,318 additions
and
451 deletions.
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
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
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
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,45 @@ | ||
#if GODOT | ||
|
||
using Godot; | ||
using System; | ||
|
||
/* | ||
* ANTI-CAPITALIST SOFTWARE LICENSE (v 1.4) | ||
* | ||
* Copyright © 2023 Pelle Bruinsma | ||
* | ||
* This is anti-capitalist software, released for free use by individuals and organizations that do not operate by capitalist principles. | ||
* | ||
* Permission is hereby granted, free of charge, to any person or organization (the "User") obtaining a copy of this software and associated documentation files (the "Software"), to use, copy, modify, merge, distribute, and/or sell copies of the Software, subject to the following conditions: | ||
* | ||
* 1. The above copyright notice and this permission notice shall be included in all copies or modified versions of the Software. | ||
* | ||
* 2. The User is one of the following: | ||
* a. An individual person, laboring for themselves | ||
* b. A non-profit organization | ||
* c. An educational institution | ||
* d. An organization that seeks shared profit for all of its members, and allows non-members to set the cost of their labor | ||
* | ||
* 3. If the User is an organization with owners, then all owners are workers and all workers are owners with equal equity and/or equal vote. | ||
* | ||
* 4. If the User is an organization, then the User is not law enforcement or military, or working for or under either. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
namespace HiHi { | ||
public abstract partial class NetworkObject : Node { | ||
#region Godot | ||
|
||
public override void _ExitTree() { | ||
base._ExitTree(); | ||
|
||
if (Interface.Registered) { | ||
Interface.UnRegister(); | ||
} | ||
} | ||
|
||
#endregion | ||
} | ||
} | ||
|
||
#endif |
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
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,57 @@ | ||
#if UNITY_EDITOR || UNITY_STANDALONE | ||
|
||
using HiHi.Common; | ||
using HiHi.Serialization; | ||
using UnityEngine; | ||
|
||
/* | ||
* ANTI-CAPITALIST SOFTWARE LICENSE (v 1.4) | ||
* | ||
* Copyright © 2023 Pelle Bruinsma | ||
* | ||
* This is anti-capitalist software, released for free use by individuals and organizations that do not operate by capitalist principles. | ||
* | ||
* Permission is hereby granted, free of charge, to any person or organization (the "User") obtaining a copy of this software and associated documentation files (the "Software"), to use, copy, modify, merge, distribute, and/or sell copies of the Software, subject to the following conditions: | ||
* | ||
* 1. The above copyright notice and this permission notice shall be included in all copies or modified versions of the Software. | ||
* | ||
* 2. The User is one of the following: | ||
* a. An individual person, laboring for themselves | ||
* b. A non-profit organization | ||
* c. An educational institution | ||
* d. An organization that seeks shared profit for all of its members, and allows non-members to set the cost of their labor | ||
* | ||
* 3. If the User is an organization with owners, then all owners are workers and all workers are owners with equal equity and/or equal vote. | ||
* | ||
* 4. If the User is an organization, then the User is not law enforcement or military, or working for or under either. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
namespace HiHi { | ||
public class Helper : MonoBehaviour, IHelper { | ||
public static UnityHelper Instance { get; private set; } | ||
|
||
[Header("Spawning")] | ||
[SerializeField] public SpawnData[] SpawnDataRegistry = new SpawnData[0]; | ||
|
||
public virtual void OnEnable() { | ||
Instance = this; | ||
} | ||
|
||
void IHelper.SerializeSpawnData(ISpawnData spawnData, BitBuffer buffer) { | ||
spawnData.Serialize(buffer); | ||
} | ||
|
||
ISpawnData IHelper.DeserializeSpawnData(BitBuffer buffer) { | ||
byte spawnDataIndex = buffer.ReadByte(); | ||
|
||
if (SpawnDataRegistry.Length <= spawnDataIndex) { | ||
throw new HiHiException($"Received spawn message referencing spawn index {spawnDataIndex}. Which doesn't exist in the {nameof(UnityHelper)}.{nameof(SpawnDataRegistry)}. Make sure your spawndata is the same across peers."); | ||
} | ||
|
||
return SpawnDataRegistry[spawnDataIndex]; | ||
} | ||
} | ||
} | ||
|
||
#endif |
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,38 @@ | ||
#if UNITY_EDITOR || UNITY_STANDALONE | ||
|
||
/* | ||
* ANTI-CAPITALIST SOFTWARE LICENSE (v 1.4) | ||
* | ||
* Copyright © 2023 Pelle Bruinsma | ||
* | ||
* This is anti-capitalist software, released for free use by individuals and organizations that do not operate by capitalist principles. | ||
* | ||
* Permission is hereby granted, free of charge, to any person or organization (the "User") obtaining a copy of this software and associated documentation files (the "Software"), to use, copy, modify, merge, distribute, and/or sell copies of the Software, subject to the following conditions: | ||
* | ||
* 1. The above copyright notice and this permission notice shall be included in all copies or modified versions of the Software. | ||
* | ||
* 2. The User is one of the following: | ||
* a. An individual person, laboring for themselves | ||
* b. A non-profit organization | ||
* c. An educational institution | ||
* d. An organization that seeks shared profit for all of its members, and allows non-members to set the cost of their labor | ||
* | ||
* 3. If the User is an organization with owners, then all owners are workers and all workers are owners with equal equity and/or equal vote. | ||
* | ||
* 4. If the User is an organization, then the User is not law enforcement or military, or working for or under either. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
namespace HiHi { | ||
public partial struct HiHiVector3 { | ||
public static implicit operator UnityEngine.Vector3(HiHiVector3 from) => new UnityEngine.Vector3(from.X, from.Y, from.Z); | ||
public static implicit operator HiHiVector3(UnityEngine.Vector3 from) => new HiHiVector3(from.x, from.y, from.z); | ||
} | ||
|
||
public partial struct HiHiQuaternion { | ||
public static implicit operator UnityEngine.Quaternion(HiHiQuaternion from) => new UnityEngine.Quaternion(from.X, from.Y, from.Z, from.W); | ||
public static implicit operator HiHiQuaternion(UnityEngine.Quaternion from) => new HiHiQuaternion(from.x, from.y, from.z, from.w); | ||
} | ||
} | ||
|
||
#endif |
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,43 @@ | ||
#if UNITY_EDITOR || UNITY_STANDALONE | ||
|
||
using UnityEngine; | ||
using System; | ||
|
||
/* | ||
* ANTI-CAPITALIST SOFTWARE LICENSE (v 1.4) | ||
* | ||
* Copyright © 2023 Pelle Bruinsma | ||
* | ||
* This is anti-capitalist software, released for free use by individuals and organizations that do not operate by capitalist principles. | ||
* | ||
* Permission is hereby granted, free of charge, to any person or organization (the "User") obtaining a copy of this software and associated documentation files (the "Software"), to use, copy, modify, merge, distribute, and/or sell copies of the Software, subject to the following conditions: | ||
* | ||
* 1. The above copyright notice and this permission notice shall be included in all copies or modified versions of the Software. | ||
* | ||
* 2. The User is one of the following: | ||
* a. An individual person, laboring for themselves | ||
* b. A non-profit organization | ||
* c. An educational institution | ||
* d. An organization that seeks shared profit for all of its members, and allows non-members to set the cost of their labor | ||
* | ||
* 3. If the User is an organization with owners, then all owners are workers and all workers are owners with equal equity and/or equal vote. | ||
* | ||
* 4. If the User is an organization, then the User is not law enforcement or military, or working for or under either. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
namespace HiHi { | ||
public abstract partial class NetworkObject : MonoBehaviour, INetworkObject { | ||
#region Unity | ||
|
||
public virtual void OnDestroy() { | ||
if (Interface.Registered) { | ||
Interface.UnRegister(); | ||
} | ||
} | ||
|
||
#endregion | ||
} | ||
} | ||
|
||
#endif |
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,52 @@ | ||
#if UNITY_EDITOR || UNITY_STANDALONE | ||
|
||
using UnityEngine; | ||
using HiHi.Serialization; | ||
using System; | ||
|
||
/* | ||
* ANTI-CAPITALIST SOFTWARE LICENSE (v 1.4) | ||
* | ||
* Copyright © 2023 Pelle Bruinsma | ||
* | ||
* This is anti-capitalist software, released for free use by individuals and organizations that do not operate by capitalist principles. | ||
* | ||
* Permission is hereby granted, free of charge, to any person or organization (the "User") obtaining a copy of this software and associated documentation files (the "Software"), to use, copy, modify, merge, distribute, and/or sell copies of the Software, subject to the following conditions: | ||
* | ||
* 1. The above copyright notice and this permission notice shall be included in all copies or modified versions of the Software. | ||
* | ||
* 2. The User is one of the following: | ||
* a. An individual person, laboring for themselves | ||
* b. A non-profit organization | ||
* c. An educational institution | ||
* d. An organization that seeks shared profit for all of its members, and allows non-members to set the cost of their labor | ||
* | ||
* 3. If the User is an organization with owners, then all owners are workers and all workers are owners with equal equity and/or equal vote. | ||
* | ||
* 4. If the User is an organization, then the User is not law enforcement or military, or working for or under either. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
namespace HiHi { | ||
[CreateAssetMenu(fileName = "SpawnData", menuName = "HiHi/SpawnData")] | ||
public class SpawnData : ScriptableObject, ISpawnData { | ||
public int Index => Array.IndexOf(helper.SpawnDataRegistry, this); | ||
|
||
[SerializeField] public NetworkObject Prefab; | ||
|
||
private UnityHelper helper => Peer.Helper as UnityHelper; | ||
|
||
void ISpawnData.Serialize(BitBuffer buffer) { | ||
buffer.AddByte((byte)Index); | ||
} | ||
|
||
INetworkObject ISpawnData.Spawn() { | ||
UnityNetworkObject spawnedInstance = Instantiate(Prefab); | ||
spawnedInstance.transform.parent = helper.transform; | ||
|
||
return spawnedInstance as INetworkObject; | ||
} | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.