Jo Jo funguje Kappa

This commit is contained in:
Dominik G.
2025-10-06 18:15:27 +02:00
parent 807e8fc5f3
commit 515160b1ec
11 changed files with 3103 additions and 76 deletions

2602
Game/Hero/Wizard 2.0.prefab Normal file

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -1857,6 +1857,8 @@ GameObject:
- component: {fileID: -6761485100369211516}
- component: {fileID: -2990689074187600234}
- component: {fileID: 7618815643042096284}
- component: {fileID: 2662658783078050447}
- component: {fileID: 2417536914360261273}
m_Layer: 0
m_Name: Wizard
m_TagString: Untagged
@@ -2019,6 +2021,77 @@ CapsuleCollider:
m_Height: 2.0070767
m_Direction: 1
m_Center: {x: 0, y: 0.9898484, z: 0}
--- !u!114 &2662658783078050447
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7059514996416789454}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.Netcode.Runtime::Unity.Netcode.NetworkObject
GlobalObjectIdHash: 913186323
InScenePlacedSourceGlobalObjectIdHash: 0
DeferredDespawnTick: 0
Ownership: 1
AlwaysReplicateAsRoot: 0
SynchronizeTransform: 1
ActiveSceneSynchronization: 0
SceneMigrationSynchronization: 1
SpawnWithObservers: 1
DontDestroyWithOwner: 0
AutoObjectParentSync: 1
SyncOwnerTransformWhenParented: 1
AllowOwnerToParent: 0
--- !u!114 &2417536914360261273
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7059514996416789454}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.Netcode.Runtime::Unity.Netcode.Components.NetworkTransform
ShowTopMostFoldoutHeaderGroup: 1
NetworkTransformExpanded: 0
AutoOwnerAuthorityTickOffset: 1
PositionInterpolationType: 0
RotationInterpolationType: 0
ScaleInterpolationType: 0
PositionLerpSmoothing: 1
PositionMaxInterpolationTime: 0.1
RotationLerpSmoothing: 1
RotationMaxInterpolationTime: 0.1
ScaleLerpSmoothing: 1
ScaleMaxInterpolationTime: 0.1
AuthorityMode: 1
TickSyncChildren: 0
UseUnreliableDeltas: 0
SyncPositionX: 1
SyncPositionY: 1
SyncPositionZ: 1
SyncRotAngleX: 1
SyncRotAngleY: 1
SyncRotAngleZ: 1
SyncScaleX: 1
SyncScaleY: 1
SyncScaleZ: 1
PositionThreshold: 0.001
RotAngleThreshold: 0.01
ScaleThreshold: 0.01
UseQuaternionSynchronization: 0
UseQuaternionCompression: 0
UseHalfFloatPrecision: 0
InLocalSpace: 0
SwitchTransformSpaceWhenParented: 0
Interpolate: 1
SlerpPosition: 0
--- !u!1 &7094911519708027617
GameObject:
m_ObjectHideFlags: 0

View File

@@ -17,6 +17,8 @@ namespace MegaKoop.Game.Networking
[DefaultExecutionOrder(-500)]
public class LobbyGameSceneCoordinator : MonoBehaviour
{
private static LobbyGameSceneCoordinator Instance;
[SerializeField] private string characterSceneName = "CharacterScene";
[SerializeField] private float spawnRadius = 3f;
[SerializeField] private float minimumSpawnSpacing = 2.5f;
@@ -28,6 +30,14 @@ namespace MegaKoop.Game.Networking
private void Awake()
{
// Singleton to avoid double spawners (e.g., one from DontDestroyOnLoad and one from scene contents)
if (Instance != null && Instance != this)
{
// Another coordinator already exists and persists; remove this duplicate.
Destroy(gameObject);
return;
}
Instance = this;
DontDestroyOnLoad(gameObject);
SceneManager.sceneLoaded += HandleSceneLoaded;
}
@@ -58,7 +68,12 @@ namespace MegaKoop.Game.Networking
}
else
{
// Already in the target scene (e.g., during hot reload).
// Already in the target scene (e.g., during hot reload). Avoid double-spawn.
if (hasSpawned)
{
Debug.Log("[LobbyGameSceneCoordinator] BeginGame called but players already spawned; ignoring.");
return;
}
loadPending = false;
hasSpawned = false;
SpawnPlayersInScene(SceneManager.GetActiveScene());
@@ -131,11 +146,13 @@ namespace MegaKoop.Game.Networking
hasSpawned = true;
// Proactively remove any previously spawned character clones (e.g., from a duplicate coordinator)
DespawnExistingClones(scene, template);
Vector3 basePosition = template.transform.position;
Quaternion baseRotation = template.transform.rotation;
Transform parent = template.transform.parent;
// Hide template so only spawned copies are visible.
template.SetActive(false);
int total = Mathf.Max(1, pendingPlayers.Count);
@@ -155,6 +172,28 @@ namespace MegaKoop.Game.Networking
}
}
private static void DespawnExistingClones(Scene scene, GameObject template)
{
// Destroy any GameObjects in the scene that look like spawned player avatars, excluding the template hierarchy.
foreach (var root in scene.GetRootGameObjects())
{
// Skip the template root itself
if (root == template) continue;
// Heuristic: if it has a SteamCharacterNetworkBridge or ThirdPersonCharacterController, treat it as a character clone
var bridge = root.GetComponentInChildren<SteamCharacterNetworkBridge>(true);
var tpc = root.GetComponentInChildren<ThirdPersonCharacterController>(true);
if (bridge != null || tpc != null)
{
// Avoid deleting the template if nested under a different root (shouldn't happen)
if (!template.transform.IsChildOf(root.transform) && !root.transform.IsChildOf(template.transform))
{
UnityEngine.Object.Destroy(root);
}
}
}
}
private static GameObject FindWizardTemplate(Scene scene)
{
foreach (var root in scene.GetRootGameObjects())

View File

@@ -19,7 +19,11 @@ namespace MegaKoop.Game.Networking
private void Update()
{
#if STEAMWORKSNET
if (!MegaKoop.Steam.SteamManager.Initialized)
#else
if (!SteamBootstrap.IsInitialized)
#endif
{
return;
}
@@ -34,7 +38,11 @@ namespace MegaKoop.Game.Networking
public void Send(CSteamID recipient, NetworkMessageType type, byte[] payload, EP2PSend sendType = EP2PSend.k_EP2PSendReliable)
{
#if STEAMWORKSNET
if (!MegaKoop.Steam.SteamManager.Initialized)
#else
if (!SteamBootstrap.IsInitialized)
#endif
{
return;
}