Exemple #1
0
 public TrailDrawer()
 {
     getNode = idx => new LineMeshGenerator.NodeData(
         relativePosition: nodes[idx].position - getTransformPosition(),
         distanceToPrevNode: nodes[idx].distanceToPrevNode
         );
     lineMeshGenerator = F.lazy(() => new LineMeshGenerator(
                                    trailWidth, gameObject.GetComponent <MeshFilter>(), color, widthMultiplierCurve)
                                );
 }
Exemple #2
0
 public static A getOrElse <A>(this LazyVal <A> lazy, Fn <A> orElse) =>
 lazy.isCompleted ? lazy.strict : orElse();
Exemple #3
0
 public static LazyVal <LST> upcast <MST, LST>(this LazyVal <MST> lazy) where MST : LST =>
 project(lazy, mst => (LST)mst);
Exemple #4
0
 /// <summary>
 /// Create a new lazy value B, based on lazy value A.
 ///
 /// Evaluating B will evaluate A and evaluating A will evaluate B.
 ///
 /// Projector function is called on every access, so make sure it is something lite,
 /// like a cast or field access.
 /// </summary>
 public static LazyVal <B> project <A, B>(this LazyVal <A> lazy, Fn <A, B> projector) =>
 new ProjectedLazyVal <A, B>(lazy, projector);
Exemple #5
0
 public static ConfigLookupError keyNotFound(LazyVal <string> message) =>
 new ConfigLookupError(Kind.KEY_NOT_FOUND, message);
Exemple #6
0
 public static A getOrNull <A>(this LazyVal <A> lazy) where A : class =>
 lazy.getOrElse((A)null);
Exemple #7
0
 /// <summary>
 /// Allows to use lazy value of more specific type where a lazy value of less specific type
 /// is required.
 ///
 /// You would think that this should work:
 /// <code><![CDATA[
 /// worldSelect.map(_ => _.upcast<WorldSelectScreen.Init, IScreen>())
 /// ]]></code>
 ///
 /// However, because <see cref="map{A,B}"/> creates a new lazy value, it does not propogate
 /// the initialization status. That means an underlying lazy value might be initialized, but
 /// a mapped value would not be.
 /// </summary>
 /// <typeparam name="MST">More specific type (like Cat)</typeparam>
 /// <typeparam name="LST">Less specific type (like Animal)</typeparam>
 public static LazyVal <LST> upcast <MST, LST>(this LazyVal <MST> lazy) where MST : LST =>
 new UpcastLazyVal <MST, LST>(lazy);
Exemple #8
0
 public static ConfigLookupError wrongType(LazyVal <ImmutableArray <Tpl <string, string> > > extras) =>
 new ConfigLookupError(Kind.WRONG_TYPE, extras);
Exemple #9
0
 public static LazyVal <LessSpecific> upcast <MoreSpecific, LessSpecific>(
     this LazyVal <MoreSpecific> lazy
     ) where MoreSpecific : LessSpecific =>
 project(lazy, mst => (LessSpecific)mst);
Exemple #10
0
 /// <summary>
 /// Create a new lazy value B, based on lazy value A.
 ///
 /// Evaluating B will evaluate A, but evaluating A will not evaluate B.
 /// </summary>
 public static LazyVal <B> lazyMap <A, B>(this LazyVal <A> lazy, Func <A, B> mapper) =>
 Lazy.a(() => mapper(lazy.strict));
Exemple #11
0
 public LazyRef(LazyVal <Ref <A> > backing)
 {
     this.backing = backing;
 }
Exemple #12
0
 [PublicAPI] public static LazyVal <Future <B> > lazyMapT <A, B>(
     this LazyVal <Future <A> > m, Fn <A, B> mapper
     ) => m.lazyMap(_ => _.map(mapper));
Exemple #13
0
 public static LazyVal <Option <B> > lazyFlatMapT <A, B>(
     this LazyVal <Option <A> > m, Fn <A, Option <B> > mapper
     ) => m.lazyMap(_ => _.flatMap(mapper));
Exemple #14
0
 public static ConfigLookupError wrongType(LazyVal <string> message) =>
 new ConfigLookupError(Kind.WRONG_TYPE, message);
Exemple #15
0
 public ConfigLookupError(Kind kind, LazyVal <ImmutableArray <Tpl <string, string> > > lazyExtras)
 {
     this.kind       = kind;
     this.lazyExtras = lazyExtras;
 }
Exemple #16
0
 public static LazyVal <LessSpecific> upcast <MoreSpecific, LessSpecific>(
     this LazyVal <MoreSpecific> lazy, LessSpecific example
     ) where MoreSpecific : LessSpecific => lazy.upcast <MoreSpecific, LessSpecific>();
Exemple #17
0
 public static ConfigLookupError keyNotFound(LazyVal <ImmutableArray <Tpl <string, string> > > extras) =>
 new ConfigLookupError(Kind.KEY_NOT_FOUND, extras);
Exemple #18
0
 public static LazyVal <Try <B> > mapT <A, B>(
     this LazyVal <Try <A> > m, Fn <A, B> mapper
     ) => m.map(_ => _.map(mapper));
Exemple #19
0
 public UpcastLazyVal(LazyVal <MST> backing)
 {
     this.backing = backing;
 }
Exemple #20
0
 public static MarkovState <A> a <A>(
     A data, LazyVal <MarkovTransition <A>[]> transitions
     )
 {
     return(new MarkovState <A>(data, transitions));
 }
Exemple #21
0
 public static A getOrElse <A>(this LazyVal <A> lazy, A orElse) =>
 lazy.isCompleted ? lazy.get : orElse;
Exemple #22
0
 public ProjectedLazyVal(LazyVal <A> backing, Fn <A, B> projector)
 {
     this.backing   = backing;
     this.projector = projector;
 }
Exemple #23
0
 public static LazyVal <B> map <A, B>(this LazyVal <A> lazy, Fn <A, B> mapper) =>
 F.lazy(() => mapper(lazy.get));
Exemple #24
0
 public ConfigLookupError(Kind kind, LazyVal <string> messageLazy)
 {
     this.kind        = kind;
     this.messageLazy = messageLazy;
 }