siegebreak/client/Assets/Scripts/Hero/HeroController.cs
caelum0x 6c7cea7592 feat: build out backend services, web client, and game roster
Backend (services/): make the app testable and fill real gaps.
- Extract buildApp() factory; index.ts owns listen()/matcher tick
- Real Apple/Google identity verification via jose JWKS (iss/aud/sub)
- Guest -> OAuth account linking (POST /auth/link), rebind in place
- POST /matches/:id/complete: record match + participants, update
  leaderboard, idempotent, guarded by server-to-server secret
- Extract pure matchmaking pairing (computePairings); fix ticket
  deckId loss on match; map ZodError -> 400; @fastify/cors
- vitest suite (40 tests), initial Prisma migration, prisma schema path

Web (web/): new Vite + React + TS client.
- Typed API client with one-shot 401 refresh/retry, localStorage auth
- Login (guest), deck builder (slot-0 hero rule), queue polling,
  leaderboard; 11 tests, clean build

Game (Assets/, Unity C#): champion-select layout now fits the roster
size; add Golem and Bandit champions.

Docs: root DEVELOPMENT.md tying game + services + web together.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-25 18:15:12 +03:00

43 lines
1.6 KiB
C#

using UnityEngine;
namespace Siegebreak.Hero
{
/// <summary>
/// Client-predicted, server-reconciled hero movement + combat.
/// This is the only entity in the game that needs full FPS-grade
/// netcode; auto-units are server-simulated and merely interpolated
/// on the client (see Units/AutoUnitAI.cs).
/// </summary>
public class HeroController : MonoBehaviour
{
[SerializeField] private float moveSpeed = 6f;
[SerializeField] private float mouseSensitivity = 2f;
[SerializeField] private HeroAbility ability;
private CharacterController _controller;
private void Awake() => _controller = GetComponent<CharacterController>();
// Driven by the network tick with server-authoritative timing.
// Movement applies locally immediately (prediction) and is
// corrected if it diverges from the server snapshot.
public void ApplyInput(Vector2 moveInput, Vector2 lookDelta, bool firePressed, bool abilityPressed)
{
var move = transform.right * moveInput.x + transform.forward * moveInput.y;
_controller.Move(move * moveSpeed * Time.deltaTime);
transform.Rotate(Vector3.up, lookDelta.x * mouseSensitivity);
if (firePressed) Fire();
if (abilityPressed) ability.TryActivate();
}
private void Fire()
{
// Local call fires visual/audio feedback only. The actual hit
// is resolved server-side via lag-compensated raycast — never
// trust a client-reported hit.
}
}
}