Compare commits

...

3 Commits

Author SHA1 Message Date
Sveske_Juice b037d5077b Give enemies networked synced id
required for reconciliation
2024-03-27 15:55:19 +01:00
Sveske_Juice 9887ee0266 Include enemy posisions in gamestate 2024-03-17 19:59:34 +01:00
Sveske_Juice dc4309fba9 Remove unnecessary assembly definitions
we are using them completely wrong, so there's no gain in having them
2024-03-17 19:59:07 +01:00
39 changed files with 84 additions and 374 deletions

View File

@ -17,6 +17,7 @@ GameObject:
- component: {fileID: -3563373198581541198}
- component: {fileID: 5669020798899338457}
- component: {fileID: 7025838755278696983}
- component: {fileID: 3458620527668384477}
m_Layer: 0
m_Name: EnemyBase
m_TagString: Enemy
@ -154,6 +155,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
targets: []
ropeDistCheck: 1
stopBeforeTargetOffset: 1
ropeCheckMask:
serializedVersion: 2
m_Bits: 0
@ -239,3 +241,16 @@ MonoBehaviour:
objectsToDisable:
- {fileID: -2259174063119120971}
- {fileID: 5063378671874793948}
--- !u!114 &3458620527668384477
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7065654593080984807}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e071dd818c5a905209e31c2d66ea6390, type: 3}
m_Name:
m_EditorClassIdentifier:
spawnedId: -1

View File

@ -1,17 +0,0 @@
{
"name": "Project.Scripts.Animation",
"rootNamespace": "",
"references": [
"GUID:1eb4e3e6c04cdc848bab71651b1e2ecd",
"GUID:f4c364e1215051e4dbc6c0bc8fb49793"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: ddd4dba7c768b564a879069c52854fc5
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,17 +0,0 @@
{
"name": "Project.Scripts.Blood",
"rootNamespace": "",
"references": [
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:c0e1b40f519e6e84b8f4af9930403ecb"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 1eb4e3e6c04cdc848bab71651b1e2ecd
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -30,6 +30,8 @@ public class EnemySpawner : NetworkBehaviour
public static EnemySpawner instance;
private static int idCounter = 0;
private void OnEnable()
{
GameManager.OnPlayersReady += OnPlayersReady;
@ -131,6 +133,7 @@ public class EnemySpawner : NetworkBehaviour
void SpawnEnemy(GameObject enemyPrefab)
{
GameObject enemy = Instantiate(enemyPrefab, GetRandomPointOnCircle(SpawnRadius), Quaternion.identity, SpawnedEnenmyHolder.transform);
enemy.GetComponent<NetworkID>().InitialID = idCounter++;
enemy.GetComponent<NetworkObject>().Spawn();
enemy.GetComponent<EnemyPathFinding>().targets = players.Select(x => x.transform).ToArray();

View File

@ -1,22 +0,0 @@
{
"name": "Project.Scritps.Enemy",
"rootNamespace": "",
"references": [
"GUID:d8b63aba1907145bea998dd612889d6b",
"GUID:2ea4a18a75f268848b43865100892489",
"GUID:055e16077a1232f4780a04598b3bfe00",
"GUID:1031dfc67c8f1a645b71d679ac3bf7db",
"GUID:0ba5c175a7b2c8345a4e996560a9d0ab",
"GUID:1491147abca9d7d4bb7105af628b223e",
"GUID:c0e1b40f519e6e84b8f4af9930403ecb"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,22 +0,0 @@
{
"name": "Project.Scripts.HeathSystem",
"rootNamespace": "",
"references": [
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:f0aa6e1ec272fc041a727a9dfb7c1e67",
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:42d1898a72cfe6848ae89835fb20acd2",
"GUID:ddd4dba7c768b564a879069c52854fc5",
"GUID:f4c364e1215051e4dbc6c0bc8fb49793",
"GUID:1eb4e3e6c04cdc848bab71651b1e2ecd"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 2ea4a18a75f268848b43865100892489
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,3 +0,0 @@
{
"name": "Project.Scripts.Manager.Audio"
}

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 0ba5c175a7b2c8345a4e996560a9d0ab
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,14 +0,0 @@
{
"name": "Project.Scripts.Manager",
"rootNamespace": "",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: c0e1b40f519e6e84b8f4af9930403ecb
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,19 +0,0 @@
{
"name": "Project.Scripts.Manager.Rumble",
"rootNamespace": "",
"references": [
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:f4c364e1215051e4dbc6c0bc8fb49793",
"GUID:42d1898a72cfe6848ae89835fb20acd2",
"GUID:f0aa6e1ec272fc041a727a9dfb7c1e67"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 055e16077a1232f4780a04598b3bfe00
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,21 +0,0 @@
{
"name": "Project.Scripts.Misc",
"rootNamespace": "",
"references": [
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:2ea4a18a75f268848b43865100892489",
"GUID:f4c364e1215051e4dbc6c0bc8fb49793",
"GUID:42d1898a72cfe6848ae89835fb20acd2",
"GUID:0ba5c175a7b2c8345a4e996560a9d0ab",
"GUID:4307f53044263cf4b835bd812fc161a4"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 1031dfc67c8f1a645b71d679ac3bf7db
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 67e1acd1de2a09a4799421a0780855c3
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,17 +0,0 @@
{
"name": "Project.Scripts.Multiplayer.Transforms",
"rootNamespace": "",
"references": [
"GUID:1491147abca9d7d4bb7105af628b223e",
"GUID:3b8ed52f1b5c64994af4c4e0aa4b6c4b"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 41f069d934ffb98448515c5816eaffdf
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,20 +0,0 @@
{
"name": "Project.Scripts.Player.Input",
"rootNamespace": "",
"references": [
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:ab47f305e1cd6654ca0ff5d6c7942d09",
"GUID:1491147abca9d7d4bb7105af628b223e",
"GUID:41f069d934ffb98448515c5816eaffdf",
"GUID:3b8ed52f1b5c64994af4c4e0aa4b6c4b"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: f4c364e1215051e4dbc6c0bc8fb49793
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,23 +0,0 @@
{
"name": "Project.Scripts.Player.Movement",
"rootNamespace": "",
"references": [
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:0ba5c175a7b2c8345a4e996560a9d0ab",
"GUID:42d1898a72cfe6848ae89835fb20acd2",
"GUID:ddd4dba7c768b564a879069c52854fc5",
"GUID:2ea4a18a75f268848b43865100892489",
"GUID:ab47f305e1cd6654ca0ff5d6c7942d09",
"GUID:f4c364e1215051e4dbc6c0bc8fb49793",
"GUID:1491147abca9d7d4bb7105af628b223e"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 5746422f3e8049a42aa33040daade640
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,19 +0,0 @@
{
"name": "Project.scripts.player",
"rootNamespace": "",
"references": [
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:f0aa6e1ec272fc041a727a9dfb7c1e67",
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:1491147abca9d7d4bb7105af628b223e"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: ab47f305e1cd6654ca0ff5d6c7942d09
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,17 +1,15 @@
{
"name": "Project.Scripts.Multiplayer",
"name": "Project.Scripts",
"rootNamespace": "",
"references": [
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:f0aa6e1ec272fc041a727a9dfb7c1e67",
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:1491147abca9d7d4bb7105af628b223e",
"GUID:2aa43b0c797e0d444a7e82e75d4f2082",
"GUID:3b8ed52f1b5c64994af4c4e0aa4b6c4b",
"GUID:1491147abca9d7d4bb7105af628b223e",
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:42d1898a72cfe6848ae89835fb20acd2",
"GUID:ff1c299121c93f34ca827a253fc30a61",
"GUID:1eb4e3e6c04cdc848bab71651b1e2ecd",
"GUID:62165c64e8180c441b8cfaa6b82208af",
"GUID:c0e1b40f519e6e84b8f4af9930403ecb"
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:4307f53044263cf4b835bd812fc161a4",
"GUID:068707ae079d6e851b7a76adaa3014f8"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 62165c64e8180c441b8cfaa6b82208af
guid: 2af092f1d01d6ab14aa33d5a66e9d45c
AssemblyDefinitionImporter:
externalObjects: {}
userData:

View File

@ -1,10 +1,12 @@
using Unity.Netcode;
using UnityEngine;
[System.Serializable]
public struct GameState : INetworkSerializable
{
public int tick;
public NetworkRope nrope;
public Vector2[] enemyPositions;
public override int GetHashCode()
{
@ -20,6 +22,7 @@ public struct GameState : INetworkSerializable
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
serializer.SerializeValue(ref tick);
serializer.SerializeValue(ref enemyPositions);
nrope.NetworkSerialize(serializer);
}
}

View File

@ -1,24 +0,0 @@
{
"name": "Project.Scripts.Rope",
"rootNamespace": "",
"references": [
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:f4c364e1215051e4dbc6c0bc8fb49793",
"GUID:ddd4dba7c768b564a879069c52854fc5",
"GUID:c0e1b40f519e6e84b8f4af9930403ecb",
"GUID:3b8ed52f1b5c64994af4c4e0aa4b6c4b",
"GUID:1491147abca9d7d4bb7105af628b223e",
"GUID:068707ae079d6e851b7a76adaa3014f8",
"GUID:f0aa6e1ec272fc041a727a9dfb7c1e67"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 42d1898a72cfe6848ae89835fb20acd2
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -4,7 +4,6 @@ using System.Linq;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Assertions;
using Utilities;
using UnityUtils;
public class RopeSimulator : NetworkBehaviour
@ -315,7 +314,8 @@ public class RopeSimulator : NetworkBehaviour
{
GameState localState = new() {
tick = currentTick,
nrope = Rope.ToNetworkRope(this.rope)
nrope = Rope.ToNetworkRope(this.rope),
enemyPositions = GameObject.FindObjectsByType<EnemyPathFinding>(FindObjectsSortMode.None).Select(e => new Vector2(e.transform.position.x, e.transform.position.y)).ToArray()
};
return localState;

View File

@ -1,24 +0,0 @@
{
"name": "Project.Scripts.Upgrades",
"rootNamespace": "",
"references": [
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:1eb4e3e6c04cdc848bab71651b1e2ecd",
"GUID:42d1898a72cfe6848ae89835fb20acd2",
"GUID:f4c364e1215051e4dbc6c0bc8fb49793",
"GUID:0ba5c175a7b2c8345a4e996560a9d0ab",
"GUID:5746422f3e8049a42aa33040daade640",
"GUID:2ea4a18a75f268848b43865100892489",
"GUID:c0e1b40f519e6e84b8f4af9930403ecb"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: ff1c299121c93f34ca827a253fc30a61
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,18 @@
using UnityEngine;
using Unity.Netcode;
public class NetworkID : NetworkBehaviour
{
// Set from enemy spawner
public int InitialID = -1;
private NetworkVariable<int> nID = new();
public int ID => nID.Value;
public override void OnNetworkSpawn()
{
if (IsServer)
nID.Value = InitialID;
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e071dd818c5a905209e31c2d66ea6390

View File

@ -0,0 +1,16 @@
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(NetworkID))]
public class NetworkID_Inspector : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
EditorGUILayout.LabelField($"ID: {(target as NetworkID).ID}");
}
}
#endif

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e70a0a80d88c1620c955d7bdc1efe3ee

View File

@ -1,3 +1,16 @@
{
"name": "Project.Scripts.Utilities"
}
"name": "Project.Scripts.Utilities",
"rootNamespace": "",
"references": [
"GUID:1491147abca9d7d4bb7105af628b223e"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}