Skip to content
Snippets Groups Projects
Commit 2004f759 authored by MaZiFAU's avatar MaZiFAU
Browse files

Added FunctionFact 0.1; Swept through Facts

parent 0e30a644
No related branches found
No related tags found
No related merge requests found
Showing
with 997 additions and 1049 deletions
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="NuGet" value="http://www.nuget.org/api/v2/" />
</packageSources>
<disabledPackageSources />
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
<config>
<add key="repositoryPath" value="./Packages" />
<add key="DefaultPushSource" value="http://www.nuget.org/api/v2/" />
</config>
</configuration>
\ No newline at end of file
fileFormatVersion: 2
guid: 3e34b64f99847434194ad0a37edc3cf0
labels:
- NuGetForUnity
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: bad6190ce424ec646b87f05af274bb7e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 09d3adb0df9f5884a8756194602658fb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
File added
File added
fileFormatVersion: 2
guid: a5b313142ecbdda489127bbe06606f1b
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 8bce5e6ab2451d34b9d3e2cb00c4c1f2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 88f51312e09cc724b92503b79e0e5829
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
File added
fileFormatVersion: 2
guid: 2e40212350bcf654394f43feaad17b3c
labels:
- NuGetForUnity
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
......@@ -4,6 +4,13 @@
public class Interactable : MonoBehaviour
{
Object AttributeSave;
List<string> URI;
Interactable parent;
List<Interactable> Children;
// Start is called before the first frame update
void Start()
{
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class KineticFactBehaviour : MonoBehaviour
{
List<FunctionFact<float, float>> functions;
private int active_func_ind = -1;
private float time = 0;
private bool _done;
public bool done {
get => _done;
private set {
if (value && repeat) {
Reset();
StartExecution();
} else
_done = value;
}
}
public bool repeat = true;
public bool execute {
get { return active_func_ind < 0; }
set { if (value) StartExecution(); else StoppExecution(); }
}
private Transform startcondition;
void Awake()
{
startcondition = transform;
}
private void Update()
{
if (!execute)
return;
active_func_ind = functions.FindIndex(active_func_ind, ff => ff.domain.Item1 <= time);
if (!execute) {
done = true;
return;
}
transform.position = new Vector3(transform.position.x, functions[active_func_ind].function(time), transform.position.z);
time += Time.deltaTime;
}
public void Reset()
{
active_func_ind = -1;
time = 0;
transform.position = startcondition.position;
done = false;
}
public void StartExecution()
{
active_func_ind = 0;
}
public void StoppExecution()
{
active_func_ind = -1;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class RigidbodyFact : MonoBehaviour
{
Rigidbody ribot;
private bool isOriginal = true;
void Awake()
{
ribot = gameObject.GetComponent<Rigidbody>();
}
private void CloneAndSend(RaycastHit[] _)
{
if (!isOriginal) return;
GameObject clone = GameObject.Instantiate(gameObject, transform.parent);
var clRbF = clone.GetComponent<RigidbodyFact>();
clRbF.isOriginal = false;
clRbF.RandomMovement(null);
}
private void RandomMovement(RaycastHit[] _)
{
gameObject.GetComponent<SphereCollider>().enabled = true;
ribot.isKinematic = false;
ribot.AddForce(
Random.rotationUniform * Vector3.up,
ForceMode.VelocityChange
);
}
void OnEnable()
=> CommunicationEvents.TriggerModFireEvent.AddListener(CloneAndSend);
void OnDisable()
=> CommunicationEvents.TriggerModFireEvent.RemoveListener(CloneAndSend);
}
......@@ -7,6 +7,7 @@
using System;
using static UnityEngine.Windows.Speech.PhraseRecognitionSystem;
using System.Linq;
using static JSONManager;
public static class JSONManager
{
......@@ -202,7 +203,7 @@ void ThrowArgumentException(ExpressionType expression_cast, int expected)
{
if (args_lamda == null) {
ParameterExpression[] args = new ParameterExpression[] {
Expression.Parameter(typeof(T), "PNamed_" + (++param_counter).ToString()),
Expression.Parameter(typeof(T), "PNamed_" + param_counter++.ToString()),
};
return Expression.Lambda(Expression.MakeUnary(unnary_type, args[0], typeof(T)), args);
}
......@@ -219,8 +220,8 @@ void ThrowArgumentException(ExpressionType expression_cast, int expected)
{
if (args_lamda == null) {
ParameterExpression[] args = new ParameterExpression[] {
Expression.Parameter(typeof(T), "PNamed_" + (++param_counter).ToString()),
Expression.Parameter(typeof(T), "PNamed_" + (++param_counter).ToString()),
Expression.Parameter(typeof(T), "PNamed_" + param_counter++.ToString()),
Expression.Parameter(typeof(T), "PNamed_" + param_counter++.ToString()),
};
return Expression.Lambda(Expression.MakeBinary(binary_type, args[0], args[1]), args);
}
......@@ -253,6 +254,7 @@ private static LambdaExpression ExpresionFuncToLambda(Expression func, string na
? ExpresionFuncToLambda(func, name, nTargs_fallback)
: Expression.Lambda(Expression.Invoke(func, args_lamda.Select(l => l.Body)), name, args_lamda.SelectMany(l => l.Parameters));
// TODO: LambdaExpression?wtf
private static Expression<Func<U, U>> ParseFuncUUToExpression<U>(Func<U, U> func)
=> (Expression<Func<U, U>>) ((x) => func(x));
......@@ -291,12 +293,13 @@ public URI(string uri)
}
[JsonConverter(typeof(JsonSubtypes), "kind")]
public class MMTTerm
abstract public class MMTTerm
{
string kind;
virtual public LambdaExpression GetLambdaExpression(LambdaExpression[] args = null)
=> Expression.Lambda(Expression.Empty(), null);
public abstract LambdaExpression GetLambdaExpression(LambdaExpression[] args = null);
public abstract override string ToString();
}
public class OMA : MMTTerm
......@@ -311,8 +314,11 @@ public OMA(MMTTerm applicant, List<MMTTerm> arguments)
this.arguments = arguments;
}
override public LambdaExpression GetLambdaExpression(LambdaExpression[] args = null)
public override LambdaExpression GetLambdaExpression(LambdaExpression[] args = null)
=> applicant.GetLambdaExpression(arguments?.Select(mmt => mmt.GetLambdaExpression()).ToArray());
public override string ToString()
=> applicant.ToString() + "(" + arguments.ToString() + ")";
}
public class OMS : MMTTerm
......@@ -325,8 +331,11 @@ public OMS(string uri)
this.uri = uri;
}
override public LambdaExpression GetLambdaExpression(LambdaExpression[] args)
public override LambdaExpression GetLambdaExpression(LambdaExpression[] args)
=> MMTtoLambdaExpression<float>.MakeLambdaExpression(uri, args);
public override string ToString()
=> uri;
}
public class OMSTR : MMTTerm
......@@ -340,8 +349,11 @@ public OMSTR(string s)
this.s = s;
}
override public LambdaExpression GetLambdaExpression(LambdaExpression[] args = null)
public override LambdaExpression GetLambdaExpression(LambdaExpression[] args = null)
=> Expression.Lambda(Expression.Constant(s, typeof(string)), null);
public override string ToString()
=> s;
}
public class OMF : MMTTerm
......@@ -355,8 +367,11 @@ public OMF(float f)
this.f = f;
}
override public LambdaExpression GetLambdaExpression(LambdaExpression[] args = null)
public override LambdaExpression GetLambdaExpression(LambdaExpression[] args = null)
=> Expression.Lambda(Expression.Constant(f, typeof(float)), null);
public override string ToString()
=> f.ToString();
}
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Neleus.LambdaCompare" version="1.0.3" />
</packages>
\ No newline at end of file
fileFormatVersion: 2
guid: e3583e9e06cbab84ab75a2f924c89619
labels:
- NuGetForUnity
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment