mirror of
https://github.com/soarqin/DSP_Mods_TO.git
synced 2025-12-17 03:53:27 +08:00
add XianTu
This commit is contained in:
21
XianTu/ToolScripts/EventTriggerExpand.cs
Normal file
21
XianTu/ToolScripts/EventTriggerExpand.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace ToolScripts
|
||||
{
|
||||
internal static class EventTriggerExpand
|
||||
{
|
||||
public static void Add(this EventTrigger trigger, EventTriggerType eventID, UnityAction<BaseEventData> callback)
|
||||
{
|
||||
var flag = trigger.triggers == null;
|
||||
if (flag)
|
||||
{
|
||||
trigger.triggers = [];
|
||||
}
|
||||
var entry = new EventTrigger.Entry();
|
||||
entry.eventID = eventID;
|
||||
entry.callback.AddListener(callback);
|
||||
trigger.triggers.Add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
75
XianTu/ToolScripts/GameObjectExpand.cs
Normal file
75
XianTu/ToolScripts/GameObjectExpand.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ToolScripts
|
||||
{
|
||||
public static class GameObjectExpand
|
||||
{
|
||||
public static T Find<T>(this GameObject obj, string name) where T : class
|
||||
{
|
||||
var gameObject = GameObject.Find(name);
|
||||
bool flag = gameObject;
|
||||
T t;
|
||||
if (flag)
|
||||
{
|
||||
t = gameObject.GetComponent<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
t = default(T);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
public static T Find<T>(this Transform obj, string name) where T : class
|
||||
{
|
||||
var transform = obj.Find(name);
|
||||
bool flag = transform;
|
||||
T t;
|
||||
if (flag)
|
||||
{
|
||||
t = transform.GetComponent<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
t = default(T);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
public static bool TryFind<T>(this GameObject obj, string name, out T result) where T : class
|
||||
{
|
||||
var gameObject = GameObject.Find(name);
|
||||
bool flag = gameObject;
|
||||
bool flag2;
|
||||
if (flag)
|
||||
{
|
||||
result = gameObject.GetComponent<T>();
|
||||
flag2 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = default(T);
|
||||
flag2 = false;
|
||||
}
|
||||
return flag2;
|
||||
}
|
||||
|
||||
public static bool TryFind<T>(this Transform obj, string name, out T result) where T : class
|
||||
{
|
||||
var transform = obj.Find(name);
|
||||
bool flag = transform;
|
||||
bool flag2;
|
||||
if (flag)
|
||||
{
|
||||
result = transform.GetComponent<T>();
|
||||
flag2 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = default(T);
|
||||
flag2 = false;
|
||||
}
|
||||
return flag2;
|
||||
}
|
||||
}
|
||||
}
|
||||
32
XianTu/ToolScripts/_BlueprintBuildingExpands.cs
Normal file
32
XianTu/ToolScripts/_BlueprintBuildingExpands.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ToolScripts
|
||||
{
|
||||
public static class _BlueprintBuildingExpands
|
||||
{
|
||||
static _BlueprintBuildingExpands()
|
||||
{
|
||||
BeltProtoDict.Add(2001, null);
|
||||
BeltProtoDict.Add(2002, null);
|
||||
BeltProtoDict.Add(2003, null);
|
||||
SoltProtoDict.Add(2011, null);
|
||||
SoltProtoDict.Add(2012, null);
|
||||
SoltProtoDict.Add(2013, null);
|
||||
SoltProtoDict.Add(2014, null);
|
||||
}
|
||||
|
||||
public static bool IsBelt(this BlueprintBuilding bb)
|
||||
{
|
||||
return BeltProtoDict.ContainsKey(bb.itemId);
|
||||
}
|
||||
|
||||
public static bool IsSlot(this BlueprintBuilding bb)
|
||||
{
|
||||
return SoltProtoDict.ContainsKey(bb.itemId);
|
||||
}
|
||||
|
||||
private static readonly Dictionary<int, ItemProto> BeltProtoDict = new();
|
||||
|
||||
private static readonly Dictionary<int, ItemProto> SoltProtoDict = new();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user