Skip to content

Commit

Permalink
Merge pull request #275 from hackerspace-ntnu/fix/hat-upgrade
Browse files Browse the repository at this point in the history
Fix solar reload and firerate
  • Loading branch information
Fueredoriku authored Nov 5, 2023
2 parents 5c850e2 + d616310 commit 0f05424
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
18 changes: 13 additions & 5 deletions Assets/Scenes/CraterTown.unity
Original file line number Diff line number Diff line change
Expand Up @@ -2401,7 +2401,7 @@ GameObject:
- component: {fileID: 662445329}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_TagString: MainLight
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
Expand Down Expand Up @@ -3894,21 +3894,29 @@ PrefabInstance:
propertyPath: m_Name
value: ExpolingBarrel (4)
objectReference: {fileID: 0}
- target: {fileID: 3535361301455422665, guid: dcca19286c3b3ec44bf7ef4f91238ce2, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3535361301455422665, guid: dcca19286c3b3ec44bf7ef4f91238ce2, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7135334762222197563, guid: dcca19286c3b3ec44bf7ef4f91238ce2, type: 3}
propertyPath: m_RootOrder
value: -1
objectReference: {fileID: 0}
- target: {fileID: 7135334762222197563, guid: dcca19286c3b3ec44bf7ef4f91238ce2, type: 3}
propertyPath: m_LocalPosition.x
value: -5.4
value: -6.65
objectReference: {fileID: 0}
- target: {fileID: 7135334762222197563, guid: dcca19286c3b3ec44bf7ef4f91238ce2, type: 3}
propertyPath: m_LocalPosition.y
value: 0.26
objectReference: {fileID: 0}
- target: {fileID: 7135334762222197563, guid: dcca19286c3b3ec44bf7ef4f91238ce2, type: 3}
propertyPath: m_LocalPosition.z
value: -11.2
value: -15.87
objectReference: {fileID: 0}
- target: {fileID: 7135334762222197563, guid: dcca19286c3b3ec44bf7ef4f91238ce2, type: 3}
propertyPath: m_LocalRotation.w
Expand Down Expand Up @@ -3940,11 +3948,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8182485406864565770, guid: dcca19286c3b3ec44bf7ef4f91238ce2, type: 3}
propertyPath: m_LocalPosition.x
value: -1.16
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8182485406864565770, guid: dcca19286c3b3ec44bf7ef4f91238ce2, type: 3}
propertyPath: m_LocalPosition.z
value: -3.66
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scenes/GrandCanyon.unity
Original file line number Diff line number Diff line change
Expand Up @@ -2860,7 +2860,7 @@ GameObject:
- component: {fileID: 1421388810}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_TagString: MainLight
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
Expand Down
2 changes: 1 addition & 1 deletion Assets/ScriptableObjects/Stats/SolarStats.asset
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MonoBehaviour:
m_Name: SolarStats
m_EditorClassIdentifier:
firerate:
baseValue: 7
baseValue: 4
reloadTime:
baseValue: 3
magazineSize: 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class SolarBody : GunBody
[SerializeField, Range(0, 1)]
protected float reloadEfficiencyPercentagen = 0.1f;

private Quaternion globalLightDirection;
private Transform globalLightDirection;

private const float maxObscuringCheckDistance = 15f;
private const float coolDownSeconds = 0.5f;
Expand All @@ -31,8 +31,8 @@ public override void Start()
{
meshRenderer.materials[solarPanelMaterialIndex] = Instantiate(meshRenderer.materials[solarPanelMaterialIndex]);
solarPanelMaterial = meshRenderer.materials[solarPanelMaterialIndex];
// The main directional light in the scene (the sun) should ideally be tagged as such, but this works for now
globalLightDirection = FindFirstObjectByType<Light>().transform.rotation;
GameObject mainLight = GameObject.FindGameObjectsWithTag("MainLight")[0];
globalLightDirection = mainLight ? mainLight.transform : FindAnyObjectByType<Light>().transform;

gunController = transform.parent.GetComponent<GunController>();
if (!gunController)
Expand Down Expand Up @@ -70,8 +70,7 @@ private void SetEmissionStrength(float strength)

void FixedUpdate()
{
float orientationOverlap = Vector3.Dot(rayCastOrigin.transform.up, globalLightDirection.eulerAngles);
if (!Physics.Raycast(rayCastOrigin.position, globalLightDirection.eulerAngles, maxObscuringCheckDistance, obscuringLayers.value) && orientationOverlap > 0)
if (!Physics.Raycast(rayCastOrigin.position, -globalLightDirection.forward, maxObscuringCheckDistance, obscuringLayers.value))
{
Reload(gunController.stats);
}
Expand Down
3 changes: 2 additions & 1 deletion ProjectSettings/TagManager.asset
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
--- !u!78 &1
TagManager:
serializedVersion: 2
tags: []
tags:
- MainLight
layers:
- Default
- TransparentFX
Expand Down

0 comments on commit 0f05424

Please sign in to comment.