浏览代码

Added some events and logic

/main
peeweek 5 年前
当前提交
a4fa27fe
共有 9 个文件被更改,包括 187 次插入0 次删除
  1. 6
      Runtime/LevelScripting/Callable.cs
  2. 19
      Runtime/LevelScripting/Events/OnMouseDownEvent.cs
  3. 11
      Runtime/LevelScripting/Events/OnMouseDownEvent.cs.meta
  4. 27
      Runtime/LevelScripting/Events/OnMouseHoverEvent.cs
  5. 11
      Runtime/LevelScripting/Events/OnMouseHoverEvent.cs.meta
  6. 26
      Runtime/LevelScripting/Events/OnVisibilityEvent.cs
  7. 11
      Runtime/LevelScripting/Events/OnVisibilityEvent.cs.meta
  8. 65
      Runtime/LevelScripting/Logic/SaveDataSwitchOnIntLogic.cs
  9. 11
      Runtime/LevelScripting/Logic/SaveDataSwitchOnIntLogic.cs.meta

6
Runtime/LevelScripting/Callable.cs


public static void Call(Callable[] calls, GameObject instigator = null)
{
if (calls == null)
{
Debug.LogError("Cannot execute callable list: Null or Missing");
return;
}
foreach (var call in calls)
{
if (GameplayIngredientsSettings.currentSettings.verboseCalls)

19
Runtime/LevelScripting/Events/OnMouseDownEvent.cs


using NaughtyAttributes;
using UnityEngine;
namespace GameplayIngredients.Events
{
[RequireComponent(typeof(Collider))]
public class OnMouseDownEvent : EventBase
{
[ReorderableList]
public Callable[] MouseDown;
private void OnMouseDown()
{
Callable.Call(MouseDown, this.gameObject);
}
}
}

11
Runtime/LevelScripting/Events/OnMouseDownEvent.cs.meta


fileFormatVersion: 2
guid: cf5a82a085a6cb14fb0e2cd1fb1faf15
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: ba45de1ff09adbf459f4db4bf50a8c14, type: 3}
userData:
assetBundleName:
assetBundleVariant:

27
Runtime/LevelScripting/Events/OnMouseHoverEvent.cs


using NaughtyAttributes;
using UnityEngine;
namespace GameplayIngredients.Events
{
[RequireComponent(typeof(Collider))]
public class OnMouseHoverEvent : EventBase
{
[ReorderableList]
public Callable[] OnHoverIn;
[ReorderableList]
public Callable[] OnHoverOut;
private void OnMouseEnter()
{
Callable.Call(OnHoverIn, this.gameObject);
}
private void OnMouseExit()
{
Callable.Call(OnHoverOut, this.gameObject);
}
}
}

11
Runtime/LevelScripting/Events/OnMouseHoverEvent.cs.meta


fileFormatVersion: 2
guid: 5870adaa301ade240bf1d3f8a18a7617
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: ba45de1ff09adbf459f4db4bf50a8c14, type: 3}
userData:
assetBundleName:
assetBundleVariant:

26
Runtime/LevelScripting/Events/OnVisibilityEvent.cs


using NaughtyAttributes;
using UnityEngine;
namespace GameplayIngredients.Events
{
[RequireComponent(typeof(Renderer))]
public class OnVisibilityEvent : EventBase
{
[ReorderableList]
public Callable[] OnVisible;
[ReorderableList]
public Callable[] OnInvisible;
private void OnBecameVisible()
{
Callable.Call(OnVisible, this.gameObject);
}
private void OnBecameInvisible()
{
Callable.Call(OnInvisible, this.gameObject);
}
}
}

11
Runtime/LevelScripting/Events/OnVisibilityEvent.cs.meta


fileFormatVersion: 2
guid: 8a3e4099ce5c9524782709429b929104
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: aaf61d8ba7c39604a90345b0217bae35, type: 3}
userData:
assetBundleName:
assetBundleVariant:

65
Runtime/LevelScripting/Logic/SaveDataSwitchOnIntLogic.cs


using NaughtyAttributes;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace GameplayIngredients.Logic
{
public class SaveDataSwitchOnIntLogic : LogicBase
{
public GameSaveManager.Location SaveLocation = GameSaveManager.Location.System;
public string Key = "SomeKey";
[NonNullCheck]
public Callable[] DefaultCaseToCall;
[ReorderableList, NonNullCheck]
public Callable[] CasesToCall;
public override void Execute(GameObject instigator = null)
{
var gsm = Manager.Get<GameSaveManager>();
if (gsm.HasInt(Key, SaveLocation))
{
int value = gsm.GetInt(Key, SaveLocation);
if(value > 0 && value < CasesToCall.Length)
{
if (CasesToCall[value] != null)
Callable.Call(CasesToCall[value], instigator);
else
{
Debug.LogWarning($"[SaveDataSwitchOnIntLogic] {gameObject.name} : Callable at index #{Key} was null, using default case.");
CallDefault(instigator);
}
}
else
{
Debug.LogWarning($"[SaveDataSwitchOnIntLogic] {gameObject.name} : Callable at index #{Key} was out of range, using default case.");
CallDefault(instigator);
}
}
else
{
Debug.LogWarning($"[SaveDataSwitchOnIntLogic] {gameObject.name} : Could not Find {Key} in {SaveLocation} Save, using default case.");
CallDefault(instigator);
}
}
void CallDefault(GameObject instigator)
{
if(DefaultCaseToCall != null)
{
Callable.Call(DefaultCaseToCall, instigator);
}
else
{
Debug.LogWarning($"[SaveDataSwitchOnIntLogic] {gameObject.name} : Did not set a default callable, aborting.");
}
}
void WarnNotExist(string name, GameSaveManager.ValueType type, GameSaveManager.Location location)
{
Debug.LogWarning(string.Format("Save Data Logic: Trying to get {0} value to non existent {1} data in {2} save.", type, name, location));
}
}
}

11
Runtime/LevelScripting/Logic/SaveDataSwitchOnIntLogic.cs.meta


fileFormatVersion: 2
guid: 03c6f74af353ebd46a0c034f1ea5de57
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 6d0a734cdedf48d478f3fcc7612af66f, type: 3}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存