public ServerGameWorld(GameWorld world, NetworkServer networkServer, Dictionary <int, ServerGameLoop.ClientInfo> clients, ChatSystemServer m_ChatSystem, BundledResourceManager resourceSystem) { m_NetworkServer = networkServer; m_Clients = clients; this.m_ChatSystem = m_ChatSystem; m_GameWorld = world; m_CharacterModule = new CharacterModuleServer(m_GameWorld, resourceSystem); m_ProjectileModule = new ProjectileModuleServer(m_GameWorld, resourceSystem); m_HitCollisionModule = new HitCollisionModule(m_GameWorld, 128, 1); m_PlayerModule = new PlayerModuleServer(m_GameWorld, resourceSystem); m_DebugPrimitiveModule = new DebugPrimitiveModule(m_GameWorld, 0.4f, 0.02f); m_SpectatorCamModule = new SpectatorCamModuleServer(m_GameWorld, resourceSystem); m_ReplicatedEntityModule = new ReplicatedEntityModuleServer(m_GameWorld, resourceSystem, m_NetworkServer); m_ReplicatedEntityModule.ReserveSceneEntities(networkServer); m_GameModeSystem = m_GameWorld.GetECSWorld().CreateManager <GameModeSystemServer>(m_GameWorld, m_ChatSystem, resourceSystem); m_DestructablePropSystem = m_GameWorld.GetECSWorld().CreateManager <UpdateDestructableProps>(m_GameWorld); m_DamageAreaSystem = m_GameWorld.GetECSWorld().CreateManager <DamageAreaSystemServer>(m_GameWorld); m_TeleporterSystem = m_GameWorld.GetECSWorld().CreateManager <TeleporterSystemServer>(m_GameWorld); m_HandleGrenadeRequests = m_GameWorld.GetECSWorld().CreateManager <HandleGrenadeRequest>(m_GameWorld, resourceSystem); m_StartGrenadeMovement = m_GameWorld.GetECSWorld().CreateManager <StartGrenadeMovement>(m_GameWorld); m_FinalizeGrenadeMovement = m_GameWorld.GetECSWorld().CreateManager <FinalizeGrenadeMovement>(m_GameWorld); m_platformSystem = m_GameWorld.GetECSWorld().CreateManager <MoverUpdate>(m_GameWorld); m_MoveableSystem = new MovableSystemServer(m_GameWorld, resourceSystem); m_CameraSystem = new ServerCameraSystem(m_GameWorld); }
public void EnableCollisionForIndex(int index) { GameDebug.Assert(colliders != null, "No collider hitcollisioncollection:{0}", gameObject.name); collidersEnabled = true; if (buffer[index].tick == lastRollbackTick) { //GameDebug.Log("skipping rollback"); return; } Profiler.BeginSample("EnableCollisionForIndex"); for (var i = 0; i < colliders.Length; i++) { if (colliders[i].collider.gameObject.layer != HitCollisionModule.HitCollisionLayer) { colliders[i].collider.gameObject.layer = HitCollisionModule.HitCollisionLayer; } } lastRollbackTick = buffer[index].tick; GameDebug.Assert(index >= 0 && index < bufferSize, "Rollback index out of bounds"); for (var i = 0; i < colliders.Length; i++) { var bonePosition = buffer[index].bonePositions[i]; var boneRotation = buffer[index].boneRotations[i]; var worldPos = boneRotation * colliders[i].localPosition + bonePosition; var worldRot = boneRotation * colliders[i].localRotation; colliders[i].collider.transform.position = worldPos; colliders[i].collider.transform.rotation = worldRot; if (HitCollisionModule.ShowDebug.IntValue > 0) { DebugPrimitiveModule.ClearChannel(HitCollisionModule.PrimDebugChannel); CapsuleCollider capsuleCollider = colliders[i].collider as CapsuleCollider; if (capsuleCollider != null) { var center = capsuleCollider.transform.TransformPoint(capsuleCollider.center); var v = capsuleCollider.transform.rotation * Vector3.up; var L = capsuleCollider.height - capsuleCollider.radius * 2; var pA = center - v * L * 0.5f; var pB = center + v * L * 0.5f; DebugPrimitiveModule.CreateCapsulePrimitive(HitCollisionModule.PrimDebugChannel, pA, pB, capsuleCollider.radius, Color.green, 0); } } } Profiler.EndSample(); }
public static void PrepareColliders(ref ComponentArray <HitCollisionHistory> collections, int tick, int mask, Entity forceExcluded, Entity forceIncluded, ray ray, float rayDist, float radius) { Profiler.BeginSample("HitCollisionHistory.PrepareColliders [SphereCast]"); for (var i = 0; i < collections.Length; i++) { var collection = collections[i]; if (!IsRelevant(collection, mask, forceExcluded, forceIncluded)) { collection.DisableHitCollision(); continue; } var stateIndex = collection.GetStateIndex(tick); Profiler.BeginSample("-capsule test"); var boundCenter = collection.boundsCenterBuffer[stateIndex]; var rayEnd = ray.origin + ray.direction * rayDist; var closestPointOnRay = coll.ClosestPointOnLineSegment(ray.origin, rayEnd, boundCenter); var dist = math.distance(closestPointOnRay, boundCenter); var boundsHit = dist < collection.settings.boundsRadius + radius; Profiler.EndSample(); if (boundsHit) { collection.EnableCollisionForIndex(stateIndex); } else { collection.DisableHitCollision(); } if (HitCollisionModule.ShowDebug.IntValue > 0) { DebugPrimitiveModule.ClearChannel(HitCollisionModule.PrimDebugChannel); DebugPrimitiveModule.CreateCapsulePrimitive(HitCollisionModule.PrimDebugChannel, ray.origin + ray.direction * radius, ray.origin + ray.direction * (rayDist - radius), radius, Color.yellow, 5); DebugPrimitiveModule.CreateSpherePrimitive(HitCollisionModule.PrimDebugChannel, boundCenter, collection.settings.boundsRadius, boundsHit ? Color.yellow : Color.gray, 5); } } Profiler.EndSample(); }
public ClientGameWorld(GameWorld world, NetworkClient networkClient, NetworkStatisticsClient networkStatistics, BundledResourceManager resourceSystem) { m_NetworkClient = networkClient; m_NetworkStatistics = networkStatistics; m_GameWorld = world; m_CharacterModule = new CharacterModuleClient(m_GameWorld, resourceSystem); m_ProjectileModule = new ProjectileModuleClient(m_GameWorld, resourceSystem); m_HitCollisionModule = new HitCollisionModule(m_GameWorld, 1, 1); m_PlayerModule = new PlayerModuleClient(m_GameWorld); m_DebugPrimitiveModule = new DebugPrimitiveModule(m_GameWorld, 1.0f, 0); m_SpectatorCamModule = new SpectatorCamModuleClient(m_GameWorld); m_EffectModule = new EffectModuleClient(m_GameWorld, resourceSystem); m_ReplicatedEntityModule = new ReplicatedEntityModuleClient(m_GameWorld, resourceSystem); m_WeaponsModule = new WeaponsModule(m_GameWorld, resourceSystem, false); m_BonusModule = new BonusModuleClient(m_GameWorld, resourceSystem); m_ragdollSystem = new RagdollModule(m_GameWorld); m_GameModeSystem = m_GameWorld.GetECSWorld().CreateManager <GameModeSystemClient>(m_GameWorld, Game.game.clientFrontend.scoreboardPanel.uiBinding, Game.game.clientFrontend.gameScorePanel); m_ClientFrontendUpdate = m_GameWorld.GetECSWorld().CreateManager <ClientFrontendUpdate>(m_GameWorld); m_DestructiblePropSystemClient = m_GameWorld.GetECSWorld().CreateManager <DestructiblePropSystemClient>(m_GameWorld); m_InterpolateGrenadeSystem = m_GameWorld.GetECSWorld().CreateManager <InterpolateGrenadePresentation>(m_GameWorld); m_ApplyGrenadePresentation = m_GameWorld.GetECSWorld().CreateManager <ApplyGrenadePresentation>(m_GameWorld); m_moverUpdate = m_GameWorld.GetECSWorld().CreateManager <MoverUpdate>(m_GameWorld); m_TeleporterSystemClient = m_GameWorld.GetECSWorld().CreateManager <TeleporterSystemClient>(m_GameWorld); m_SpinSystem = m_GameWorld.GetECSWorld().CreateManager <SpinSystem>(m_GameWorld); m_HandleNamePlateOwnerSpawn = m_GameWorld.GetECSWorld().CreateManager <HandleNamePlateSpawn>(m_GameWorld); m_HandleNamePlateOwnerDespawn = m_GameWorld.GetECSWorld().CreateManager <HandleNamePlateDespawn>(m_GameWorld); m_UpdateNamePlates = m_GameWorld.GetECSWorld().CreateManager <UpdateNamePlates>(m_GameWorld); m_GameModeSystem.SetLocalPlayerId(m_NetworkClient.clientId); m_TwistSystem = new TwistSystem(m_GameWorld); m_FanSystem = new FanSystem(m_GameWorld); m_TranslateScaleSystem = new TranslateScaleSystem(m_GameWorld); }
public static void PrepareColliders(ref ComponentArray <HitCollisionHistory> collections, int tick, int mask, Entity forceExcluded, Entity forceIncluded, sphere sphere) { Profiler.BeginSample("HitCollisionHistory.PrepareColliders [Sphere]"); for (var i = 0; i < collections.Length; i++) { var collection = collections[i]; if (!IsRelevant(collection, mask, forceExcluded, forceIncluded)) { collection.DisableHitCollision(); continue; } var stateIndex = collection.GetStateIndex(tick); var boundsCenter = collection.boundsCenterBuffer[stateIndex]; var boundsRadius = collection.settings.boundsRadius; var dist = math.distance(sphere.center, boundsCenter); var boundsHit = dist < sphere.radius + boundsRadius; if (boundsHit) { collection.EnableCollisionForIndex(stateIndex); } else { collection.DisableHitCollision(); } if (HitCollisionModule.ShowDebug.IntValue > 0) { DebugPrimitiveModule.ClearChannel(HitCollisionModule.PrimDebugChannel); DebugPrimitiveModule.CreateSpherePrimitive(HitCollisionModule.PrimDebugChannel, sphere.center, sphere.radius, Color.yellow, 5); DebugPrimitiveModule.CreateSpherePrimitive(HitCollisionModule.PrimDebugChannel, boundsCenter, boundsRadius, boundsHit ? Color.yellow : Color.gray, 5); } } Profiler.EndSample(); }
public static void PrepareColliders(ref ComponentArray <HitCollisionHistory> collections, int tick, int mask, Entity forceExcluded, Entity forceIncluded, ray ray, float rayDist) { Profiler.BeginSample("HitCollisionHistory.PrepareColliders [Ray]"); // Rollback for (var i = 0; i < collections.Length; i++) { var collection = collections[i]; if (!IsRelevant(collection, mask, forceExcluded, forceIncluded)) { collection.DisableHitCollision(); continue; } var stateIndex = collection.GetStateIndex(tick); Profiler.BeginSample("-raycast"); var sphere = primlib.sphere(collection.boundsCenterBuffer[stateIndex], collection.settings.boundsRadius); var boundsHit = coll.RayCast(sphere, ray, rayDist); Profiler.EndSample(); if (boundsHit) { collection.EnableCollisionForIndex(stateIndex); } else { collection.DisableHitCollision(); } if (HitCollisionModule.ShowDebug.IntValue > 0) { DebugPrimitiveModule.ClearChannel(HitCollisionModule.PrimDebugChannel); DebugPrimitiveModule.CreateLinePrimitive(HitCollisionModule.PrimDebugChannel, ray.origin, ray.origin + ray.direction * rayDist, Color.yellow, 5); DebugPrimitiveModule.CreateSpherePrimitive(HitCollisionModule.PrimDebugChannel, sphere.center, sphere.radius, boundsHit ? Color.yellow : Color.gray, 5); } } Profiler.EndSample(); }
void EnterActiveState() { m_GameWorld.RegisterSceneEntities(); m_resourceSystem = new BundledResourceManager("BundledResources/Client"); m_CharacterModule = new CharacterModulePreview(m_GameWorld, m_resourceSystem); m_ProjectileModule = new ProjectileModuleClient(m_GameWorld, m_resourceSystem); m_HitCollisionModule = new HitCollisionModule(m_GameWorld, 1, 2); m_PlayerModuleClient = new PlayerModuleClient(m_GameWorld); m_PlayerModuleServer = new PlayerModuleServer(m_GameWorld, m_resourceSystem); m_DebugPrimitiveModule = new DebugPrimitiveModule(m_GameWorld, 1.0f, 0); m_SpectatorCamModuleServer = new SpectatorCamModuleServer(m_GameWorld, m_resourceSystem); m_SpectatorCamModuleClient = new SpectatorCamModuleClient(m_GameWorld); m_EffectModule = new EffectModuleClient(m_GameWorld, m_resourceSystem); m_WeaponsModule = new WeaponsModule(m_GameWorld, m_resourceSystem, false); m_ragdollModule = new RagdollModule(m_GameWorld); m_DespawnProjectiles = m_GameWorld.GetECSWorld().CreateManager <DespawnProjectiles>(m_GameWorld); m_DamageAreaSystemServer = m_GameWorld.GetECSWorld().CreateManager <DamageAreaSystemServer>(m_GameWorld); m_TeleporterSystemServer = m_GameWorld.GetECSWorld().CreateManager <TeleporterSystemServer>(m_GameWorld); m_TeleporterSystemClient = m_GameWorld.GetECSWorld().CreateManager <TeleporterSystemClient>(m_GameWorld); m_UpdateDestructableProps = m_GameWorld.GetECSWorld().CreateManager <UpdateDestructableProps>(m_GameWorld); m_DestructiblePropSystemClient = m_GameWorld.GetECSWorld().CreateManager <DestructiblePropSystemClient>(m_GameWorld); m_HandleGrenadeRequests = m_GameWorld.GetECSWorld().CreateManager <HandleGrenadeRequest>(m_GameWorld, m_resourceSystem); m_StartGrenadeMovement = m_GameWorld.GetECSWorld().CreateManager <StartGrenadeMovement>(m_GameWorld); m_FinalizeGrenadeMovement = m_GameWorld.GetECSWorld().CreateManager <FinalizeGrenadeMovement>(m_GameWorld); m_ApplyGrenadePresentation = m_GameWorld.GetECSWorld().CreateManager <ApplyGrenadePresentation>(m_GameWorld); m_moverUpdate = m_GameWorld.GetECSWorld().CreateManager <MoverUpdate>(m_GameWorld); m_SpinSystem = m_GameWorld.GetECSWorld().CreateManager <SpinSystem>(m_GameWorld); m_HandleNamePlateOwnerSpawn = m_GameWorld.GetECSWorld().CreateManager <HandleNamePlateSpawn>(m_GameWorld); m_HandleNamePlateOwnerDespawn = m_GameWorld.GetECSWorld().CreateManager <HandleNamePlateDespawn>(m_GameWorld); m_UpdateNamePlates = m_GameWorld.GetECSWorld().CreateManager <UpdateNamePlates>(m_GameWorld); m_UpdateReplicatedOwnerFlag = m_GameWorld.GetECSWorld().CreateManager <UpdateReplicatedOwnerFlag>(m_GameWorld); m_TwistSystem = new TwistSystem(m_GameWorld); m_FanSystem = new FanSystem(m_GameWorld); m_TranslateScaleSystem = new TranslateScaleSystem(m_GameWorld); m_PlayerModuleClient.RegisterLocalPlayer(0, null); // Spawn PlayerState, Character and link up LocalPlayer m_Player = m_PlayerModuleServer.CreatePlayer(m_GameWorld, 0, "LocalHero", true); var playerEntity = m_Player.gameObject.GetComponent <GameObjectEntity>().Entity; var charControl = m_GameWorld.GetEntityManager().GetComponentObject <PlayerCharacterControl>(playerEntity); charControl.characterType = math.max(Game.characterType.IntValue, 0); m_Player.teamIndex = 0; m_previewGameMode = m_GameWorld.GetECSWorld().CreateManager <PreviewGameMode>(m_GameWorld, m_Player); Game.SetMousePointerLock(true); }