Skip to content
Snippets Groups Projects
Select Git revision
  • a17a586a77bb0ca988b966f3257fc8ae18295a49
  • 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

FactSpawner.cs

Blame
  • SOMDocs.cs 33.36 KiB
    using JsonSubTypes;
    using Newtonsoft.Json;
    using System.Collections.Generic;
    using System.Linq.Expressions;
    using System.Linq;
    using System;
    using UnityEngine;
    using MoreLinq;
    using System.Runtime.CompilerServices;
    using System.Collections;
    
    namespace REST_JSON_API
    {
        public class ApproximationComparer : EqualityComparer<object>
        {
            public static readonly ApproximationComparer Instance = new();
            private double precission;
    
            public ApproximationComparer(double precission = Math3d.vectorPrecission)
            {
                this.precission = precission;
            }
    
            public override bool Equals(object x, object y)
            {
                if (x.Equals(y))
                    return true;
                if (x.GetType() != y.GetType())
                    return false;
    
                if (x is float fx)
                    return Math3d.Approximately(fx, (float)y, (float)precission);
                if (x is Vector3 vx)
                    return Math3d.IsApproximatelyEqual(vx, (Vector3)y, precission);
    
                return false;
            }
    
            public override int GetHashCode(object obj)
            {
                if (obj is float)
                    return typeof(float).GetHashCode();
                if (obj is Vector3)
                    return typeof(Vector3).GetHashCode();
    
                return obj.GetHashCode();
            }
        }
    
        [JsonConverter(typeof(JsonSubtypes), "kind")]
        [JsonSubtypes.KnownSubType(typeof(RAW), "RAW")]
        [JsonSubtypes.KnownSubType(typeof(OMS), "OMS")]
        [JsonSubtypes.KnownSubType(typeof(OMA), "OMA")]
        [JsonSubtypes.KnownSubType(typeof(OMV), "VAR")]
        [JsonSubtypes.KnownSubType(typeof(OML_Member), "OML")]
        [JsonSubtypes.KnownSubType(typeof(FUN), "FUN")]
        [JsonSubtypes.KnownSubType(typeof(FUNTYPE), "FUNTYPE")]
        //[JsonSubtypes.KnownSubType(typeof(OMC<T>), "OMC<" + typeof(T).Name + ">")]
        [JsonSubtypes.KnownSubType(typeof(OMLIT<bool>), "OMLIT<Boolean>")]
        [JsonSubtypes.KnownSubType(typeof(OMLIT<byte>), "OMLIT<Byte>")]
        [JsonSubtypes.KnownSubType(typeof(OMLIT<short>), "OMLIT<Int16>")]
        [JsonSubtypes.KnownSubType(typeof(OMLIT<int>), "OMLIT<Int32>")]
        [JsonSubtypes.KnownSubType(typeof(OMLIT<long>), "OMLIT<Int64>")]
        [JsonSubtypes.KnownSubType(typeof(OMLIT<float>), "OMLIT<Single>")]
        [JsonSubtypes.KnownSubType(typeof(OMLIT<float>), "OMLIT<Double>")] // we dont use double
        [JsonSubtypes.KnownSubType(typeof(OMLIT<string>), "OMLIT<String>")]
        [JsonSubtypes.KnownSubType(typeof(OMLIT<Vector3>), "OMLIT<Vector3>")]
        [JsonSubtypes.FallBackSubType(typeof(FallbackWrapper))]
        //[JsonSubtypes.KnownSubType(typeof(FallbackWrapper), "SFunction")]
        //[JsonSubtypes.KnownSubTypeWithProperty(typeof(FallbackWrapper), "SFunction")]