Skip to content

Commit 9daac6b

Browse files
committed
Add networked building rotation and adjust hangar spawn
Introduced an RPC method to rotate buildings by 90 degrees via network in Building.cs and updated InputController to call this RPC when Ctrl+R is pressed. Also adjusted the Hangar vehicle spawn point to be 2 units higher. Removed AssetOrigin metadata from Photon Fusion .meta files.
1 parent 8aff478 commit 9daac6b

File tree

115 files changed

+80
-742
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+80
-742
lines changed

Red Strike/Assets/BuildingPlacement/Buildings/Building.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using UnityEngine;
22
using GameStateSystem;
33
using Fusion;
4-
using Unity.VisualScripting;
54

65
namespace BuildingPlacement.Buildings
76
{
@@ -49,6 +48,12 @@ public override void TakeDamage(float damage)
4948
}
5049
}
5150

51+
[Rpc(RpcSources.All, RpcTargets.StateAuthority)]
52+
public void RPC_Rotate90()
53+
{
54+
networkTransform.Teleport(transform.position, transform.rotation * Quaternion.Euler(0, 90, 0));
55+
}
56+
5257
private void OnCollisionEnter(Collision collision)
5358
{
5459
var unit = collision.gameObject.GetComponent<Unit.Unit>();

Red Strike/Assets/BuildingPlacement/Buildings/Hangar/Hangar.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class Hangar : Building
1717
private void Start()
1818
{
1919
vehicleSpawnPoint = transform.position + transform.forward * 20f;
20+
vehicleSpawnPoint.y += 2f;
2021
}
2122

2223
public void CreateVehicle(VehicleTypes vehicleType)

Red Strike/Assets/InputController/InputController.cs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using UnityEngine.UIElements;
88
using NetworkingSystem;
99
using AmmunitionSystem;
10+
using Fusion;
1011

1112
namespace InputController
1213
{
@@ -31,7 +32,7 @@ public class InputController : MonoBehaviour
3132

3233
private Building currentSelectedBuilding;
3334
private VehicleSystem.Vehicles.Vehicle currentSelectedVehicle;
34-
35+
3536
private VehiclesHUDController vehiclesHUDController;
3637
private BuildingHUDController buildingHUDController;
3738

@@ -76,7 +77,18 @@ private void Update()
7677
{
7778
if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) && Input.GetKeyDown(KeyCode.R))
7879
{
79-
tempBuildingHighlighter.transform.Rotate(0, 90, 0);
80+
// Highlight edilen objenin Building scriptini bul
81+
var building = tempBuildingHighlighter.GetComponent<BuildingPlacement.Buildings.Building>();
82+
83+
// Eğer script o objede değilse parent'a bak
84+
if (building == null) building = tempBuildingHighlighter.GetComponentInParent<BuildingPlacement.Buildings.Building>();
85+
86+
if (building != null)
87+
{
88+
Debug.Log("Dönme isteği gönderiliyor...");
89+
// 2. RPC'Yİ BURADAN ÇAĞIRIN
90+
building.RPC_Rotate90();
91+
}
8092
}
8193
}
8294

@@ -107,10 +119,10 @@ private void PlaceBuilding()
107119
if (IsPositionValid(spawnPosition))
108120
{
109121
bool isThereMainBuilding = FindObjectsByType<BuildingPlacement.Buildings.MainStation>(FindObjectsSortMode.None)
110-
.Any(station =>
122+
.Any(station =>
111123
{
112124
var unit = station.GetComponent<Unit.Unit>();
113-
return unit != null && unit.teamId == teamId;
125+
return unit != null && unit.teamId == teamId;
114126
});
115127

116128
if (currentSelectedBuilding.buildingName != "Main Station" && !isThereMainBuilding)
@@ -181,7 +193,7 @@ private void HandleObjectSelection()
181193
if (unit == null)
182194
{
183195
unit = hitInfo.collider.GetComponentInParent<Unit.Unit>();
184-
if(unit == null) { DeselectAll(); return; }
196+
if (unit == null) { DeselectAll(); return; }
185197
}
186198

187199
bool isFriendly = unit.teamId == teamId;
@@ -222,7 +234,7 @@ private void HandleObjectSelection()
222234
case Unit.UnitType.Building:
223235
tempBuildingHighlighter = GetHighlighter(unit.gameObject);
224236
tempBuildingHighlighter?.EnableHighlight();
225-
237+
226238
var building = unit.GetComponent<BuildingPlacement.Buildings.Building>();
227239
if (building != null) buildingHUDController.ShowBuildingDetails(building);
228240
break;
@@ -241,7 +253,7 @@ private void DeselectAll()
241253
vehicleHighlighter = null;
242254
targetHighlighter = null;
243255
tempBuildingHighlighter = null;
244-
256+
245257
currentSelectedVehicle = null;
246258
currentSelectedBuilding = null;
247259
}
@@ -256,7 +268,7 @@ private SelectionHighlighter GetHighlighter(GameObject obj)
256268
private bool IsPointerOverUI()
257269
{
258270
if (gameUIDocument == null) return false;
259-
271+
260272
if (UnityEngine.EventSystems.EventSystem.current != null && UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
261273
return true;
262274

Red Strike/Assets/Photon/Fusion/Assemblies/Debug/Fusion.Common.dll.debug.meta

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Red Strike/Assets/Photon/Fusion/Assemblies/Debug/Fusion.Log.dll.debug.meta

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Red Strike/Assets/Photon/Fusion/Assemblies/Debug/Fusion.Realtime.dll.debug.meta

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Red Strike/Assets/Photon/Fusion/Assemblies/Debug/Fusion.Runtime.dll.debug.meta

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Red Strike/Assets/Photon/Fusion/Assemblies/Debug/Fusion.Sockets.dll.debug.meta

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Red Strike/Assets/Photon/Fusion/Assemblies/Fusion.Common.dll.meta

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Red Strike/Assets/Photon/Fusion/Assemblies/Fusion.Common.pdb.meta

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)