Select Git revision
Pythagoras-form.png.meta
FunctionFact.cs 9.92 KiB
using System;
using System.Collections.Generic;
using UnityEngine;
using Newtonsoft.Json;
using static SOMDocManager;
using System.Linq.Expressions;
using System.Linq;
using Characters.FirstPerson;
public class FunctionCallFact : FactWrappedCRTP<FunctionCallFact>
{
public string func_id;
public string arg_func_id;
public (float t_0, float t_n) Domain;
[JsonIgnore]
public FunctionFact Function_in => (FunctionFact)FactOrganizer.AllFacts[func_id];
[JsonIgnore]
public FunctionFact Function_args => (FunctionFact)FactOrganizer.AllFacts[arg_func_id];
public FunctionCallFact() : base() { }
public FunctionCallFact(string func_id, string arg_func_id, (float t_0, float t_n) Domain, FactOrganizer organizer) : base(organizer)
{
this.func_id = func_id;
this.arg_func_id = arg_func_id;
this.Domain = Domain;
_URI = func_id.ToString() + arg_func_id.ToString() + Domain.ToString();
}
public object[] Call(float t)
{
if (t < Domain.t_0 || t > Domain.t_n)
return null;
return Function_in.Function(Function_args.Function(new object[] { t }));
}
public override bool HasDependentFacts
=> true;
protected override string[] GetGetDependentFactIds()
=> new[] { func_id, arg_func_id };
public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
{
var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
//obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = this.Label;
//obj.GetComponent<FactWrapper>().fact = this;
return obj;
}
protected override bool EquivalentWrapped(FunctionCallFact f1, FunctionCallFact f2)
=> f1.Domain.t_0.IsApproximatelyEqual(f2.Domain.t_0)
&& f1.Domain.t_n.IsApproximatelyEqual(f2.Domain.t_n)
&& (DependentFactsEquivalent(f1, f2)
|| (f1.Function_in.Equivalent(f2.Function_in)
&& f1.Function_args.Equivalent(f2.Function_args)
));
protected override MMTDeclaration MakeMMTDeclaration()
{
throw new NotImplementedException();
}
protected override void RecalculateTransform()