commit 004262146d03c1f079c7c195b4de259d0f08650b
parent 001d74fe85ddbff7dc79d3969d0f002c51d1c944
Author: PlutoTank <qwolkensperg@gmail.com>
Date: Sun, 19 Apr 2020 21:11:27 -0400
triggers now handle returning themselves
Diffstat:
7 files changed, 18 insertions(+), 91 deletions(-)
diff --git a/Assets/Prefabs/Camera.prefab b/Assets/Prefabs/Camera.prefab
@@ -14,8 +14,6 @@ GameObject:
- component: {fileID: 114368316905943310}
- component: {fileID: 1472157838}
- component: {fileID: 1472157839}
- - component: {fileID: 619456893}
- - component: {fileID: 619456894}
m_Layer: 0
m_Name: Camera
m_TagString: MainCamera
@@ -105,7 +103,6 @@ MonoBehaviour:
minZoom: 40
maxZoom: 15
maxDistanceFromOtherPlayers: 70
- visibleThings: []
offset: {x: 0, y: 70, z: -50}
--- !u!114 &1472157838
MonoBehaviour:
@@ -161,57 +158,3 @@ MonoBehaviour:
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
---- !u!114 &619456893
-MonoBehaviour:
- m_ObjectHideFlags: 0
- m_CorrespondingSourceObject: {fileID: 0}
- m_PrefabInstance: {fileID: 0}
- m_PrefabAsset: {fileID: 0}
- m_GameObject: {fileID: 1915431236944600}
- m_Enabled: 1
- m_EditorHideFlags: 0
- m_Script: {fileID: 11500000, guid: 4f7862acd69d43259782a7a9472c703f, type: 3}
- m_Name:
- m_EditorClassIdentifier:
- gameEvent: {fileID: 11400000, guid: 08cea5bd86af3294baed5c8f7308ae0f, type: 2}
- unityEventResponse:
- m_PersistentCalls:
- m_Calls:
- - m_Target: {fileID: 114368316905943310}
- m_MethodName: AddToCameraList
- m_Mode: 0
- m_Arguments:
- m_ObjectArgument: {fileID: 0}
- m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
- m_IntArgument: 0
- m_FloatArgument: 0
- m_StringArgument:
- m_BoolArgument: 0
- m_CallState: 2
---- !u!114 &619456894
-MonoBehaviour:
- m_ObjectHideFlags: 0
- m_CorrespondingSourceObject: {fileID: 0}
- m_PrefabInstance: {fileID: 0}
- m_PrefabAsset: {fileID: 0}
- m_GameObject: {fileID: 1915431236944600}
- m_Enabled: 1
- m_EditorHideFlags: 0
- m_Script: {fileID: 11500000, guid: 4f7862acd69d43259782a7a9472c703f, type: 3}
- m_Name:
- m_EditorClassIdentifier:
- gameEvent: {fileID: 11400000, guid: 35a079d68f29c7d4f9b18d8f39634803, type: 2}
- unityEventResponse:
- m_PersistentCalls:
- m_Calls:
- - m_Target: {fileID: 114368316905943310}
- m_MethodName: RemoveFromCameraList
- m_Mode: 0
- m_Arguments:
- m_ObjectArgument: {fileID: 0}
- m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
- m_IntArgument: 0
- m_FloatArgument: 0
- m_StringArgument:
- m_BoolArgument: 0
- m_CallState: 2
diff --git a/Assets/Scripts/Slimecing/Abilities/Ability.cs b/Assets/Scripts/Slimecing/Abilities/Ability.cs
@@ -13,13 +13,13 @@ namespace Slimecing.Abilities
[SerializeField] protected AudioClip abilitySound;
[SerializeField] private Trigger abilityTrigger;
- public Trigger currentAbilityTrigger { get; set; }
+ public Trigger runtimeAbilityTrigger { get; set; }
public virtual void CheckActivation(AbilityUser aUser, TriggerState state)
{
- if (currentAbilityTrigger == null) return;
+ if (runtimeAbilityTrigger == null) return;
if (state != TriggerState.Performed) return;
- currentAbilityTrigger.currentTriggerState = TriggerState.Canceled;
+ runtimeAbilityTrigger.currentTriggerState = TriggerState.Canceled;
StartAbility(aUser);
}
@@ -27,11 +27,11 @@ namespace Slimecing.Abilities
public virtual void Initialize(AbilityUser aUser)
{
- currentAbilityTrigger = Instantiate(abilityTrigger);
- currentAbilityTrigger.EnableTrigger(aUser.gameObject);
+ runtimeAbilityTrigger = abilityTrigger.GetTrigger();
+ runtimeAbilityTrigger.EnableTrigger(aUser.gameObject);
if (abilitySound == null) abilitySound = AudioClip.Create("void", 1, 1, 1000, false);
- currentAbilityTrigger.TriggerStateChange += ctx => CheckActivation(aUser, ctx);
+ runtimeAbilityTrigger.TriggerStateChange += ctx => CheckActivation(aUser, ctx);
}
public void StartAbility(AbilityUser aUser)
@@ -74,7 +74,7 @@ namespace Slimecing.Abilities
private void EndAbility()
{
- currentAbilityTrigger.currentTriggerState = TriggerState.Canceled;
+ runtimeAbilityTrigger.currentTriggerState = TriggerState.Canceled;
}
}
}
diff --git a/Assets/Scripts/Slimecing/Abilities/UseAbilities/JumpAbility.cs b/Assets/Scripts/Slimecing/Abilities/UseAbilities/JumpAbility.cs
@@ -51,7 +51,7 @@ namespace Slimecing.Abilities.UseAbilities
public override void CheckActivation(AbilityUser aUser, TriggerState state)
{
- if (currentAbilityTrigger == null) return;
+ if (runtimeAbilityTrigger == null) return;
switch (state)
{
case TriggerState.Started:
diff --git a/Assets/Scripts/Slimecing/Characters/CharacterMovementController.cs b/Assets/Scripts/Slimecing/Characters/CharacterMovementController.cs
@@ -299,12 +299,7 @@ namespace Slimecing.Characters
private bool CheckIfValidCollider(Collider col)
{
- if (col != playerCollider && col != null)
- {
- return true;
- }
-
- return false;
+ return col != playerCollider && col != null;
}
}
diff --git a/Assets/Scripts/Slimecing/Swords/Orbitals/OrbitalLogicScripts/InputOrbitalLogic.cs b/Assets/Scripts/Slimecing/Swords/Orbitals/OrbitalLogicScripts/InputOrbitalLogic.cs
@@ -9,7 +9,7 @@ namespace Slimecing.Swords.Orbitals.OrbitalLogicScripts
{
[SerializeField] private Trigger orbitalInputTrigger;
- private Trigger operatingOrbitalInputTrigger { get; set; }
+ private Trigger runtimeOrbitalInputTrigger { get; set; }
public override OrbitalLogic GetOrbital()
{
@@ -18,9 +18,9 @@ namespace Slimecing.Swords.Orbitals.OrbitalLogicScripts
public override void Initialize(Orbital orbital)
{
- operatingOrbitalInputTrigger = Instantiate(orbitalInputTrigger);
+ runtimeOrbitalInputTrigger = orbitalInputTrigger.GetTrigger();
GetInput(orbital, Vector2.up);
- operatingOrbitalInputTrigger.EnableTrigger(orbital.ownerObject);
+ runtimeOrbitalInputTrigger.EnableTrigger(orbital.ownerObject);
}
public override void Tick(Orbital orbital)
@@ -60,7 +60,7 @@ namespace Slimecing.Swords.Orbitals.OrbitalLogicScripts
public void TickUpdate(Orbital orbital)
{
- InputAction action = operatingOrbitalInputTrigger.ReadCurrentValue<InputAction>();
+ var action = runtimeOrbitalInputTrigger.ReadCurrentValue<InputAction>();
if (action == null) return;
if (!action.triggered) return;
if (action.activeControl != null && action.activeControl?.device.name == "Mouse")
diff --git a/Assets/Scripts/Slimecing/Triggers/Trigger.cs b/Assets/Scripts/Slimecing/Triggers/Trigger.cs
@@ -8,19 +8,11 @@ namespace Slimecing.Triggers
public TriggerState currentTriggerState { get; set; }
public event Action<TriggerState> TriggerStateChange;
- public abstract void EnableTrigger(GameObject target);
- protected static T CheckRequestedValue<T>(object obj)
- {
- var result = default(T);
- if (obj is T)
- {
- result = (T) Convert.ChangeType(obj, typeof(T));
- }
- return result;
- }
- public virtual T ReadCurrentValue<T>() => CheckRequestedValue<T>(currentTriggerState);
- protected virtual void OnTriggerStateChange(TriggerState state)
+ public Trigger GetTrigger() => Instantiate(this);
+ public abstract void EnableTrigger(GameObject target);
+ public virtual T ReadCurrentValue<T>() => (T) Convert.ChangeType(currentTriggerState, typeof(T));
+ protected void OnTriggerStateChange(TriggerState state)
{
TriggerStateChange?.Invoke(state);
}
diff --git a/Assets/Scripts/Slimecing/Triggers/TriggerLogic/InputTriggerPolling.cs b/Assets/Scripts/Slimecing/Triggers/TriggerLogic/InputTriggerPolling.cs
@@ -31,10 +31,7 @@ namespace Slimecing.Triggers.TriggerLogic
}
- public override T ReadCurrentValue<T>()
- {
- return (T) Convert.ChangeType(action, typeof(T));
- }
+ public override T ReadCurrentValue<T>() => (T) Convert.ChangeType(action, typeof(T));
}
}