commit 82764e7ac2ed9fecf1ceb019d52de776f7cf73af
parent 1c1e02e2972edd7f877d7ad4d1b6441aa99af0f2
Author: PlutoTank <qwolkensperg@gmail.com>
Date: Fri, 17 Apr 2020 20:38:16 -0400
orbital bug fixes
Diffstat:
5 files changed, 57 insertions(+), 33 deletions(-)
diff --git a/Assets/Scripts/Slimecing/Swords/Orbitals/OrbitalLogic.cs b/Assets/Scripts/Slimecing/Swords/Orbitals/OrbitalLogic.cs
@@ -1,5 +1,4 @@
-using Slimecing.Triggers;
-using UnityEngine;
+using UnityEngine;
namespace Slimecing.Swords.Orbitals
{
@@ -11,5 +10,6 @@ namespace Slimecing.Swords.Orbitals
public abstract void Initialize(GameObject owner, GameObject orbital);
public abstract void Tick(GameObject owner, GameObject orbital);
+
}
}
diff --git a/Assets/Scripts/Slimecing/Swords/Orbitals/OrbitalLogicScripts/TimerOrbitalLogic.cs b/Assets/Scripts/Slimecing/Swords/Orbitals/OrbitalLogicScripts/TimerOrbitalLogic.cs
@@ -8,7 +8,7 @@ using Random = UnityEngine.Random;
namespace Slimecing.Swords.Orbitals.OrbitalLogicScripts
{
[CreateAssetMenu(fileName = "TimerOrbitalLogic", menuName = "Swords/Orbitals/OrbitalLogic/TimerOrbitalLogic")]
- public class TimerOrbitalLogic : OrbitalLogic
+ public class TimerOrbitalLogic : OrbitalLogic, IOrbitalTickEveryFrame
{
[SerializeField] private bool randomProgress;
[SerializeField] private float orbitalProgress;
@@ -25,15 +25,7 @@ namespace Slimecing.Swords.Orbitals.OrbitalLogicScripts
if (randomProgress) orbitalProgress = Random.Range(0.0f, 1.0f);
SetOrbitalPos(owner, orbital);
}
- public override void Tick(GameObject owner, GameObject orbital)
- {
- if (Mathf.Abs(currentOrbitalStats.rotationSpeed) < 0.1)
- {
- currentOrbitalStats.rotationSpeed = 0.1f;
- }
- Rotate(owner, orbital);
- SetLook(owner, orbital);
- }
+ public override void Tick(GameObject owner, GameObject orbital) { }
private void SetOrbitalPos(GameObject owner, GameObject orbital)
{
@@ -52,9 +44,19 @@ namespace Slimecing.Swords.Orbitals.OrbitalLogicScripts
private void Rotate(GameObject owner, GameObject orbital)
{
float orbitSpeed = 1f / currentOrbitalStats.rotationSpeed;
- orbitalProgress += Time.fixedDeltaTime * orbitSpeed;
+ orbitalProgress += Time.deltaTime * orbitSpeed;
orbitalProgress %= 1f;
SetOrbitalPos(owner, orbital);
}
+
+ public void TickUpdate(GameObject owner, GameObject orbital)
+ {
+ if (Mathf.Abs(currentOrbitalStats.rotationSpeed) < 0.1)
+ {
+ currentOrbitalStats.rotationSpeed = 0.1f;
+ }
+ Rotate(owner, orbital);
+ SetLook(owner, orbital);
+ }
}
}
diff --git a/Assets/Scripts/Slimecing/Swords/Orbitals/OrbitalPackage.cs b/Assets/Scripts/Slimecing/Swords/Orbitals/OrbitalPackage.cs
@@ -10,7 +10,7 @@ namespace Slimecing.Swords.Orbitals
[SerializeField] private GameObject orbital;
[SerializeField] private OrbitalLogic orbitalLogic;
[SerializeField] private bool sticky;
-
+
public bool orbitalSticky
{
get => sticky;
@@ -37,7 +37,7 @@ namespace Slimecing.Swords.Orbitals
set => orbital = value;
}
- public OrbitalLogic OrbitalLogic
+ public OrbitalLogic currentOrbitalLogic
{
get => orbitalLogic;
set => orbitalLogic = value;
diff --git a/Assets/Scripts/Slimecing/Swords/Orbitals/TakesOrbitals.cs b/Assets/Scripts/Slimecing/Swords/Orbitals/TakesOrbitals.cs
@@ -29,7 +29,7 @@ namespace Slimecing.Swords.Orbitals
{
GameObject spawnedOrbital = Instantiate(orbitals[i].orbitalObject, thisTransform.position,
Quaternion.identity);
- orbitals[i] = new OrbitalPackage(spawnedOrbital, orbitals[i].OrbitalLogic);
+ orbitals[i] = new OrbitalPackage(spawnedOrbital, orbitals[i].currentOrbitalLogic);
InitializeOrbital(orbitals[i]);
}
}
@@ -47,11 +47,11 @@ namespace Slimecing.Swords.Orbitals
}
}
- public void InitializeOrbital(OrbitalPackage orbital)
+ private void InitializeOrbital(OrbitalPackage orbital)
{
AddCollisions(orbital.orbitalObject);
- orbital.OrbitalLogic = Instantiate(orbital.OrbitalLogic);
- orbital.OrbitalLogic.Initialize(gameObject, orbital.orbitalObject);
+ orbital.currentOrbitalLogic = Instantiate(orbital.currentOrbitalLogic);
+ orbital.currentOrbitalLogic.Initialize(gameObject, orbital.orbitalObject);
ResetSpawnedOrbitalObjects();
}
@@ -97,7 +97,7 @@ namespace Slimecing.Swords.Orbitals
private void RemoveOrbital(OrbitalPackage orbital)
{
- DropOrbital(orbital);
+ DropOrbital(orbital.orbitalObject);
orbitals.Remove(orbital);
}
@@ -105,7 +105,7 @@ namespace Slimecing.Swords.Orbitals
{
foreach (var orbital in orbitals)
{
- if (orbital.OrbitalLogic is IOrbitalTickEveryFrame inputOrbitalLogic)
+ if (orbital.currentOrbitalLogic is IOrbitalTickEveryFrame inputOrbitalLogic)
{
inputOrbitalLogic.TickUpdate(gameObject, orbital.orbitalObject);
}
@@ -118,7 +118,7 @@ namespace Slimecing.Swords.Orbitals
foreach (var orbital in orbitals)
{
- orbital.OrbitalLogic.Tick(gameObject, orbital.orbitalObject);
+ orbital.currentOrbitalLogic.Tick(gameObject, orbital.orbitalObject);
}
}
@@ -138,11 +138,13 @@ namespace Slimecing.Swords.Orbitals
for (int i = 0; i < loopCount; i++)
{
- if (orbitals[i].orbitalObject != _spawnedOrbitalObjects[i])
+ if (orbitals[i] == null)
{
- DropOrbital(orbitals[i]);
- InitializeOrbital(orbitals[i]);
+ orbitals.Remove(orbitals[i]);
}
+ if (orbitals[i].orbitalObject == _spawnedOrbitalObjects[i]) continue;
+ //DropOrbital(_spawnedOrbitalObjects[i]);
+ InitializeOrbital(orbitals[i]);
}
if (resetLoop)
@@ -151,17 +153,12 @@ namespace Slimecing.Swords.Orbitals
}
}
- private void DropOrbital(OrbitalPackage orbital)
+ private void DropOrbital(GameObject orbital)
{
- DropLogic dropLogic = orbital.orbitalObject.GetComponent<DropLogic>();
+ DropLogic dropLogic = orbital.GetComponent<DropLogic>();
if (dropLogic == null)
{
- if (orbital.orbitalSticky)
- {
- orbital.orbitalObject.SetActive(false);
- return;
- }
- Destroy(orbital.orbitalObject);
+ orbital.SetActive(false);
return;
}
diff --git a/Assets/_Scenes/Testing/SLope.unity b/Assets/_Scenes/Testing/SLope.unity
@@ -1510,6 +1510,12 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 570933862}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
+--- !u!1 &621488908 stripped
+GameObject:
+ m_CorrespondingSourceObject: {fileID: 2311679785310360297, guid: 4e346bd7fa8310847b295522d78bb540,
+ type: 3}
+ m_PrefabInstance: {fileID: 1031493766}
+ m_PrefabAsset: {fileID: 0}
--- !u!1 &664793195
GameObject:
m_ObjectHideFlags: 0
@@ -2735,6 +2741,7 @@ GameObject:
- component: {fileID: 1383329375}
- component: {fileID: 1383329374}
- component: {fileID: 1383329373}
+ - component: {fileID: 1383329377}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged
@@ -2816,6 +2823,24 @@ Transform:
m_Father: {fileID: 1651529366}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 10}
+--- !u!114 &1383329377
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1383329372}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 6f7780a3c04e17841825f68a82642af4, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ defaultOrbitalLogic: {fileID: 11400000, guid: f604a09f73d9b3e4a8d515810e94c6d9,
+ type: 2}
+ orbitals:
+ - orbital: {fileID: 621488908}
+ orbitalLogic: {fileID: 11400000, guid: f604a09f73d9b3e4a8d515810e94c6d9, type: 2}
+ sticky: 0
--- !u!1 &1384512436
GameObject:
m_ObjectHideFlags: 0