Skip to content
Snippets Groups Projects
Select Git revision
  • f42522039ee7f55ef289d46864e245e92eef8025
  • master default
  • JS-based-scroll-rendering
  • Paul_Marius_Level
  • Paul_Marius_2
  • Paul_Marius
  • Andi_Mark
  • be-UnityWebView
  • gitignoreFrameitServer
  • ZimmerBSc
  • Bugfix_StageLoading
  • stages
  • MAZIFAU_Experimental
  • tsc/coneworld
  • tsc/fact-interaction
  • marcel
  • MaZiFAU_TopSort
  • mergeHelper
  • zwischenSpeichern
  • tempAndrToMaster
  • SebBranch
  • 3.0
  • v2.1
  • v2.0
  • v1.0
25 results

FunctionFact.cs

Blame
  • FunctionFact.cs 7.58 KiB
    using System;
    using System.Collections.Generic;
    using UnityEngine;
    using Newtonsoft.Json;
    using System.Linq;
    using REST_JSON_API;
    using System.Linq.Expressions;
    using System.Collections;
    
    public class FunctionCallFact : FactWrappedCRTP<FunctionCallFact>
    {
        protected override object GetCompiledValue() 
            => Tuple.Create(Domain, Function_args.CompiledValue, Function.CompiledValue);
    
        public string func_id
        {
            get => Function?.Id ?? _func_id;
            private set
            {
                _func_id = value;
                FactRecorder.AllFacts.TryGetValue(value, out Fact func);
                Function = (FunctionFact)func;
            }
        }
        private string _func_id;
    
        public string arg_func_id
        {
            get => Function_args?.Id ?? _arg_func_id;
            private set
            {
                _arg_func_id = value;
                FactRecorder.AllFacts.TryGetValue(value, out Fact func);
                Function_args = (FunctionFact)func;
            }
        }
        private string _arg_func_id;
    
        public (float t_0, float t_n) Domain;
    
    
        [JsonIgnore]
        public FunctionFact Function;
    
        [JsonIgnore]
        public FunctionFact Function_args;
    
        [JsonConstructor]
        public FunctionCallFact(string func_id, string arg_func_id, (float t_0, float t_n) Domain) : base()
        {
            this.func_id = func_id;
            this.arg_func_id = arg_func_id;
            this.Domain = Domain;
        }
    
        public FunctionCallFact(FunctionFact Function, FunctionFact Function_args, (float t_0, float t_n) Domain) : base()
        {
            this.Function = Function;
            this.Function_args = Function_args;
            this.Domain = Domain;
        }
    
        public object[] Call(float t)
        {
            if (t < Domain.t_0 || t > Domain.t_n)
                return null;
    
            object[] path = Function_args.Function(new object[] { t });
            return Function.Function(path);
        }