public RandomizableTime Clone(int cloneFlags = 0) { var r = new RandomizableTime(); CopyTo(r, 0); return(r); }
private void CutoffChanged(string s) { var i = RandomizableTime.CutoffFromString(s); if (i == -1) { return; } if (value_ != null) { ((RandomizableTime)value_).Cutoff = i; } }
public override bool FromJSON(J.Node n) { var o = n.AsObject("RandomDuration"); if (o == null) { return(false); } RandomizableTime t = null; o.Opt("time", ref t); Time = t; Time.Reset(true); return(true); }
public bool FromJSON(J.Node n) { Clear(); var o = n.AsObject("Step"); if (o == null) { return(false); } o.Opt("enabled", enabled_); o.Opt("paused", ref paused_); o.Opt("name", ref name_); o.Opt("halfMove", halfMove_); o.Opt("modifiers", ref modifiers_); { IDuration d = null; o.Opt <DurationFactory, IDuration>("duration", ref d); Duration = d; } { RandomizableTime t = null; o.Opt("repeat", ref t); Repeat = t; } { Delay d = null; o.Opt("delay", ref d); Delay = d; } foreach (var m in modifiers_) { m.ParentStep = this; } return(true); }
public void Clear() { if (modifiers_ != null) { while (modifiers_.Count > 0) { DeleteModifier(modifiers_[0]); } } enabled_.Value = true; name_ = null; Duration = new RandomDuration(); Repeat = new RandomizableTime(0); Delay = new Delay(new RandomDuration(), false, false); halfMove_.Value = false; inFirstHalf_ = true; modifiers_ = new List <ModifierContainer>(); enabledModifiers_ = new List <ModifierContainer>(); }
public RandomizableTimeWidgets(string name, int flags = 0) : base(flags) { interval_ = new FloatSlider( name + " change interval", 0, new FloatRange(0, 10), IntervalChanged, flags); randomHalf_ = new Button("Randomize half", RandomizeHalf, flags); initial_ = new FloatSlider( name, 0, new FloatRange(0, 0), InitialChanged, flags); range_ = new FloatSlider( name + " random range", 0, new FloatRange(0, 0), RangeChanged, flags); cutoff_ = new StringList( name + " cut-off", "", RandomizableTime.GetCutoffNames(), CutoffChanged, flags); }
public void SetValue(RandomizableTime v, FloatRange preferredRange) { value_ = v; if (value_ != null) { initial_.Parameter = value_.InitialParameter; initial_.Default = value_.Initial; initial_.Range = preferredRange; range_.Parameter = value_.RangeParameter; range_.Default = value_.Range; range_.Range = preferredRange; interval_.Parameter = value_.IntervalParameter; interval_.Default = value_.Interval; } if (v != null) { cutoff_.Value = RandomizableTime.CutoffToString(v.Cutoff); } }
protected void CopyTo(RandomizableTime r, int cloneFlags) { base.CopyTo(r, cloneFlags); r.cutoff_ = cutoff_; }
public override void Removed() { base.Removed(); Time = null; }
public RandomDuration(float s, float r = 0) { Time = new RandomizableTime(s, r, 0); }