Skip to content

Commit

Permalink
Merge pull request #72 from SideQuestVR/dev
Browse files Browse the repository at this point in the history
2.3.0 merge
  • Loading branch information
mikeskydev authored Nov 21, 2024
2 parents 15aac66 + 3c4262f commit 293ec66
Show file tree
Hide file tree
Showing 65 changed files with 2,303 additions and 570 deletions.
3 changes: 3 additions & 0 deletions Editor/BanterObjectIdEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public override VisualElement CreateInspectorGUI()
{
script.ForceGenerateId();
myInspector.Q<TextField>("id").value = script.Id;
EditorUtility.SetDirty(script);
Debug.Log(EditorUtility.IsPersistent(script));
PrefabUtility.RecordPrefabInstancePropertyModifications(script);
});
return myInspector;
}
Expand Down
2 changes: 1 addition & 1 deletion Editor/Components/BanterHeldEventsEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override VisualElement CreateInspectorGUI()
var title = new Label("PROPERTIES SEEN BY JS");
title.style.fontSize = 14;
myInspector.Add(title);
var seeFields = new Label("sensitivity, fireRate, auto, blockThumbstick, blockPrimary, blockSecondary, blockThumbstickClick, ");
var seeFields = new Label("sensitivity, fireRate, auto, blockLeftPrimary, blockLeftSecondary, blockRightPrimary, blockRightSecondary, blockLeftThumbstick, blockLeftThumbstickClick, blockRightThumbstick, blockRightThumbstickClick, blockLeftTrigger, blockRightTrigger, ");
seeFields.style.unityFontStyleAndWeight = FontStyle.Bold;
seeFields.style.flexWrap = Wrap.Wrap;
seeFields.style.whiteSpace = WhiteSpace.Normal;
Expand Down
2 changes: 2 additions & 0 deletions Editor/Components/BanterRigidbodyEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public override VisualElement CreateInspectorGUI()
togglevelocity.RegisterValueChangedCallback(evt =>
{
script._velocity = evt.newValue;
EditorUtility.SetDirty(script);
});
containervelocity.Add(togglevelocity);
myInspector.Add(containervelocity);
Expand All @@ -67,6 +68,7 @@ public override VisualElement CreateInspectorGUI()
toggleangularVelocity.RegisterValueChangedCallback(evt =>
{
script._angularVelocity = evt.newValue;
EditorUtility.SetDirty(script);
});
containerangularVelocity.Add(toggleangularVelocity);
myInspector.Add(containerangularVelocity);
Expand Down
10 changes: 10 additions & 0 deletions Editor/Components/BanterTransformEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public override VisualElement CreateInspectorGUI()
toggleposition.RegisterValueChangedCallback(evt =>
{
script._position = evt.newValue;
EditorUtility.SetDirty(script);
});
containerposition.Add(toggleposition);
myInspector.Add(containerposition);
Expand All @@ -67,6 +68,7 @@ public override VisualElement CreateInspectorGUI()
togglelocalPosition.RegisterValueChangedCallback(evt =>
{
script._localPosition = evt.newValue;
EditorUtility.SetDirty(script);
});
containerlocalPosition.Add(togglelocalPosition);
myInspector.Add(containerlocalPosition);
Expand All @@ -81,6 +83,7 @@ public override VisualElement CreateInspectorGUI()
togglerotation.RegisterValueChangedCallback(evt =>
{
script._rotation = evt.newValue;
EditorUtility.SetDirty(script);
});
containerrotation.Add(togglerotation);
myInspector.Add(containerrotation);
Expand All @@ -95,6 +98,7 @@ public override VisualElement CreateInspectorGUI()
togglelocalRotation.RegisterValueChangedCallback(evt =>
{
script._localRotation = evt.newValue;
EditorUtility.SetDirty(script);
});
containerlocalRotation.Add(togglelocalRotation);
myInspector.Add(containerlocalRotation);
Expand All @@ -109,6 +113,7 @@ public override VisualElement CreateInspectorGUI()
togglelocalScale.RegisterValueChangedCallback(evt =>
{
script._localScale = evt.newValue;
EditorUtility.SetDirty(script);
});
containerlocalScale.Add(togglelocalScale);
myInspector.Add(containerlocalScale);
Expand All @@ -123,6 +128,7 @@ public override VisualElement CreateInspectorGUI()
toggleeulerAngles.RegisterValueChangedCallback(evt =>
{
script._eulerAngles = evt.newValue;
EditorUtility.SetDirty(script);
});
containereulerAngles.Add(toggleeulerAngles);
myInspector.Add(containereulerAngles);
Expand All @@ -137,6 +143,7 @@ public override VisualElement CreateInspectorGUI()
togglelocalEulerAngles.RegisterValueChangedCallback(evt =>
{
script._localEulerAngles = evt.newValue;
EditorUtility.SetDirty(script);
});
containerlocalEulerAngles.Add(togglelocalEulerAngles);
myInspector.Add(containerlocalEulerAngles);
Expand All @@ -151,6 +158,7 @@ public override VisualElement CreateInspectorGUI()
toggleup.RegisterValueChangedCallback(evt =>
{
script._up = evt.newValue;
EditorUtility.SetDirty(script);
});
containerup.Add(toggleup);
myInspector.Add(containerup);
Expand All @@ -165,6 +173,7 @@ public override VisualElement CreateInspectorGUI()
toggleforward.RegisterValueChangedCallback(evt =>
{
script._forward = evt.newValue;
EditorUtility.SetDirty(script);
});
containerforward.Add(toggleforward);
myInspector.Add(containerforward);
Expand All @@ -179,6 +188,7 @@ public override VisualElement CreateInspectorGUI()
toggleright.RegisterValueChangedCallback(evt =>
{
script._right = evt.newValue;
EditorUtility.SetDirty(script);
});
containerright.Add(toggleright);
myInspector.Add(containerright);
Expand Down
1 change: 1 addition & 0 deletions Editor/Components/BanterVideoPlayerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public override VisualElement CreateInspectorGUI()
toggletime.RegisterValueChangedCallback(evt =>
{
script._time = evt.newValue;
EditorUtility.SetDirty(script);
});
containertime.Add(toggletime);
myInspector.Add(containertime);
Expand Down
2 changes: 1 addition & 1 deletion Editor/banter-link/inject.txt

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions Runtime/Scripts/3rdParty/BSIPA.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

211 changes: 211 additions & 0 deletions Runtime/Scripts/3rdParty/BSIPA/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
#nullable enable
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace Banter.Utilities {
/// <summary>
/// Extensions for <see cref="IEnumerable{T}"/> that don't currently exist in <c>System.Linq</c>.
/// </summary>
public static class EnumerableExtensions
{
/*
/// <summary>
/// Adds a value to the beginning of the sequence.
/// </summary>
/// <typeparam name="T">the type of the elements of <paramref name="seq"/></typeparam>
/// <param name="seq">a sequence of values</param>
/// <param name="prep">the value to prepend to <paramref name="seq"/></param>
/// <returns>a new sequence beginning with <paramref name="prep"/></returns>
public static IEnumerable<T> Prepend<T>(this IEnumerable<T> seq, T prep)
=> new PrependEnumerable<T>(seq, prep);
private sealed class PrependEnumerable<T> : IEnumerable<T>
{
private readonly IEnumerable<T> rest;
private readonly T first;
public PrependEnumerable(IEnumerable<T> rest, T first)
{
this.rest = rest;
this.first = first;
}
public PrependEnumerator GetEnumerator() => new(this);
public struct PrependEnumerator : IEnumerator<T>
{
private readonly IEnumerator<T> restEnum;
private readonly PrependEnumerable<T> enumerable;
private int state;
internal PrependEnumerator(PrependEnumerable<T> enumerable)
{
this.enumerable = enumerable;
restEnum = enumerable.rest.GetEnumerator();
state = 0;
Current = default!;
}
public T Current { get; private set; }
object? IEnumerator.Current => Current;
public void Dispose() => restEnum.Dispose();
public bool MoveNext()
{
switch (state)
{
case 0:
Current = enumerable.first;
state++;
return true;
case 1:
if (!restEnum.MoveNext())
{
state = 2;
return false;
}
else
Current = restEnum.Current;
return true;
case 2:
default:
return false;
}
}
public void Reset()
{
restEnum.Reset();
state = 0;
}
}
IEnumerator<T> IEnumerable<T>.GetEnumerator() => new PrependEnumerator(this);
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
/// <summary>
/// Adds a value to the end of the sequence.
/// </summary>
/// <typeparam name="T">the type of the elements of <paramref name="seq"/></typeparam>
/// <param name="seq">a sequence of values</param>
/// <param name="app">the value to append to <paramref name="seq"/></param>
/// <returns>a new sequence ending with <paramref name="app"/></returns>
public static IEnumerable<T> Append<T>(this IEnumerable<T> seq, T app)
=> new AppendEnumerable<T>(seq, app);
private sealed class AppendEnumerable<T> : IEnumerable<T>
{
private readonly IEnumerable<T> rest;
private readonly T last;
public AppendEnumerable(IEnumerable<T> rest, T last)
{
this.rest = rest;
this.last = last;
}
public AppendEnumerator GetEnumerator() => new(this);
public struct AppendEnumerator : IEnumerator<T>
{
private readonly IEnumerator<T> restEnum;
private readonly AppendEnumerable<T> enumerable;
private int state;
internal AppendEnumerator(AppendEnumerable<T> enumerable)
{
this.enumerable = enumerable;
restEnum = enumerable.rest.GetEnumerator();
state = 0;
Current = default!;
}
public T Current { get; private set; }
object? IEnumerator.Current => Current;
public void Dispose() => restEnum.Dispose();
public bool MoveNext()
{
switch (state)
{
case 0:
if (!restEnum.MoveNext())
{
state = 1;
goto case 1;
}
else
Current = restEnum.Current;
return true;
case 1:
Current = enumerable.last;
state++;
return true;
case 2:
default:
return false;
}
}
public void Reset()
{
restEnum.Reset();
state = 0;
}
}
IEnumerator<T> IEnumerable<T>.GetEnumerator() => GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
*/

/// <summary>
/// LINQ-style extension method that filters <see langword="null"/> elements out of an enumeration.
/// </summary>
/// <typeparam name="T">the type of the enumeration</typeparam>
/// <param name="self">the enumeration to filter</param>
/// <returns>a filtered enumerable</returns>
public static IEnumerable<T> NonNull<T>(this IEnumerable<T?> self) where T : class
=> self.Where(o => o != null)!;

/// <summary>
/// LINQ-style extension method that filters <see langword="null"/> elements out of an enumeration based on a converter.
/// </summary>
/// <typeparam name="T">the type of the enumeration</typeparam>
/// <typeparam name="U">the type to compare to null</typeparam>
/// <param name="self">the enumeration to filter</param>
/// <param name="pred">the predicate to select for filtering</param>
/// <returns>a filtered enumerable</returns>
public static IEnumerable<T> NonNull<T, U>(this IEnumerable<T> self, Func<T, U?> pred) where U : class
=> self.Where(o => pred(o) != null);

/// <summary>
/// LINQ-style extension method that filters <see langword="null"/> elements from an enumeration of nullable types.
/// </summary>
/// <typeparam name="T">the underlying type of the nullable enumeration</typeparam>
/// <param name="self">the enumeration to filter</param>
/// <returns>a filtered enumerable</returns>
public static IEnumerable<T> NonNull<T>(this IEnumerable<T?> self) where T : struct
=> self.Where(o => o != null).Select(o => o!.Value);

/// <summary>
/// LINQ-style extension method that filters <see langword="null"/> elements out of an enumeration based on a converter to a nullable type.
/// </summary>
/// <typeparam name="T">the type of the enumeration</typeparam>
/// <typeparam name="U">the type of the predicate's resulting nullable</typeparam>
/// <param name="self">the enumeration to filter</param>
/// <param name="pred">the predicate to select for filtering</param>
/// <returns>a filtered enumerable</returns>
public static IEnumerable<T> NonNull<T, U>(this IEnumerable<T> self, Func<T, U?> pred) where U : struct
=> self.Where(o => pred(o) != null);
}

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 293ec66

Please sign in to comment.