//public Node Node_GoAlongPoints(Val<Vector3>[] targ) //{ // return new LeafInvoke( // () => this.Character.NavAlongPoints(targ), // () => this.Character.NavStop()); //} // TODO: No speed support yet! - AS 5/4/14 ///// <summary> ///// Approaches a target with a certain speed ///// </summary> //public Node Node_GoTo(Val<Vector3> targ, Val<float> speed) //{ // this.Character.SetSpeed(speed.Value); // return new LeafInvoke( // () => this.Character.NavGoTo(targ), // () => this.Character.NavStop()); //} /// <summary> /// Orient towards a target position /// </summary> /// <param name="targ"></param> /// <returns></returns> public Node Node_OrientTowards(Val<Vector3> targ) { return new LeafInvoke( () => this.Character.NavTurn(targ), () => this.Character.NavOrientBehavior( OrientationBehavior.LookForward)); }
public MsmqQueue() { Machine = "."; Transactional = false; Private = true; Permissions = new MsmqUserPermissions[0]; }
/// <summary> /// This constructor is used by special subclasses which provide /// a transparent mapping between .NET and Fantom exception types. /// </summary> public Err(Val val, Exception actual) { this.val = val; val.m_err = this; this.m_actual = actual; this.m_msg = actual.Message; }
protected Node ApproachAndOrientTarget(GameObject a, Val<Vector3> target, Val<float> distance) { Quaternion rotation = Quaternion.LookRotation(target.Value - a.transform.position); Vector3 targetLoc = target.Value - (rotation * new Vector3(0, 0, distance.Value)); Val<Vector3> targetAdjusted = Val.V(() => targetLoc); return new Sequence(mec(a).Node_GoTo(targetAdjusted), mec(a).Node_OrientTowards(target)); }
public RunStatus throwingBall(Val<Vector3> direction) { transform.parent = null; rb.velocity = direction.Value * 2f; rb.isKinematic = false; rb.useGravity = true; return RunStatus.Success; }
// //Root Node // protected Node conversationTree(Val<Vector3> P1Pos, Val<Vector3> P2Pos, Val<Vector3> P3Pos) { return new Sequence(OrientAndWave(P1Pos, P2Pos), WalkAndTalk(P1Pos, P2Pos), new DecoratorForceStatus(RunStatus.Success, new SequenceParallel(DeltreseWalkTo(DeltreseGoTo), ThatDamnDeltrese(P3Pos))), CallDeltrese(P1Pos, P2Pos, P3Pos) ); }
public Iis6WebSite() { Port = 80; ScriptMapsToAdd = new Iis6ScriptMap[0]; Authentication = new[] {Iis6Authentication.Basic, Iis6Authentication.NTLM}; AppPool = null; Started = true; }
public static Node Node_Affordance( this SmartObject o, Behavior b, Val<string> affordance) { return new LeafInvoke( () => o.Affordance(b.Character, affordance.Value)); }
protected Node TurnOnLight(Val<FullBodyBipedEffector> effector, Val<InteractionObject> obj, Transform lightSwitch) { Val<Vector3> position = Val.V(() => lightSwitch.position); return new Sequence( participant.GetComponent<BehaviorMecanim>().Node_GoToUpToRadius(position, 2.0f), participant.GetComponent<BehaviorMecanim>().Node_StartInteraction(effector, obj)); // participant.GetComponent<BehaviorMecanim>().Node_WaitForFinish(effector), // participant.GetComponent<BehaviorMecanim>().Node_StopInteraction(effector)); }
public LeafAffordance( Val<string> affordance, Val<SmartObject> user, Val<SmartObject> obj) { this.affordance = affordance.Value; this.user = user.Value; this.obj = obj.Value; }
public RunStatus throwball(Val<Vector3> direction) { transform.parent = null; ball.isKinematic = false; ball.useGravity = true; ball.velocity = -direction.Value * 2.1f; return RunStatus.Success; }
public Node EyeContact(Val<Vector3> WanderPos, Val<Vector3> FriendPos) { Vector3 height = new Vector3(0.0f, 1.85f, 0.0f); Val<Vector3> WanderHead = Val.V(() => WanderPos.Value + height); Val<Vector3> Friendhead = Val.V(() => FriendPos.Value + height); return new SequenceParallel( numberOfParticipants[0].GetComponent<BehaviorMecanim>().Node_HeadLook(Friendhead), numberOfParticipants[1].GetComponent<BehaviorMecanim>().Node_HeadLook(WanderHead)); }
protected Node ApproachAndOrient( Val<Vector3> WandererPos, Val<Vector3> FriendPos) { return new Sequence( // Approach at distance 1.0f Friend.Node_GoTo(WandererPos, 1.0f), new SequenceParallel( Friend.Node_OrientTowards(WandererPos), Wanderer.Node_OrientTowards(FriendPos))); }
public void addSlider(string name, Val val) { GameObject sliderGo = Instantiate(Resources.Load("GUISliderPrefab") as GameObject) as GameObject; FuzzyGUISlider tmpSlider = sliderGo.GetComponentInChildren<FuzzyGUISlider>(); sliderGo.transform.parent = transform; tmpSlider.setTarget(Vector3.right*200 + (-10)*nSlider*Vector3.up ); //tmpSlider.setReference(mf); tmpSlider.setReference(mf,val); nSlider++; }
public static Func<string, string> MappedTranslationFunc(Val val) { switch (val) { case Val.Expiration: return x => Pastebin.Expiration.ReverseMap(x).ToString(); case Val.Visibility: return x => Pastebin.Visibility.ReverseMap(x).ToString(); default: return x => x; } }
public virtual RunStatus BodyAnimationButton(Val<string> gestureName, Val<bool> isActive) { if (button_interact) { this.Body.BodyAnimation(gestureName.Value, isActive.Value); button_interact = false; return RunStatus.Success; } this.Body.BodyAnimation(gestureName.Value, false); return RunStatus.Success; }
protected Node CallDeltrese(Val<Vector3> P1Pos, Val<Vector3> P2Pos, Val<Vector3> P3Pos) { return new Sequence( person2.GetComponent<BehaviorMecanim>().Node_OrientTowards(P3Pos), person2.GetComponent<BehaviorMecanim>().ST_PlayHandGesture("Point", 3000), deltrese.GetComponent<BehaviorMecanim>().Node_OrientTowards(P1Pos), deltrese.GetComponent<BehaviorMecanim>().ST_PlayHandGesture("Wave", 3000), deltrese.GetComponent<BehaviorMecanim>().Node_GoToUpToRadius(P2Pos, 3.0f), Argue(P1Pos, P2Pos, P3Pos) ); }
/// <summary> /// Turns to face a desired target point /// </summary> public virtual RunStatus NavTurn(Val<Vector3> target) { this.Body.NavSetOrientationBehavior(OrientationBehavior.None); this.Body.NavSetDesiredOrientation(target.Value); if (this.Body.NavIsFacingDesired() == true) { this.Body.NavSetOrientationBehavior( OrientationBehavior.LookForward); return RunStatus.Success; } return RunStatus.Running; }
/// <summary> /// This subtree will cause the two characters to look at each other's /// heads. It will run indefinitely until terminated, at which point /// the characters will stop gaze tracking /// </summary> protected Node EyeContact( Val<Vector3> WandererPos, Val<Vector3> FriendPos) { // Estimate the head position based on height Vector3 height = new Vector3(0.0f, 1.85f, 0.0f); Val<Vector3> WandererHead = Val.Value(() => WandererPos.Value + height); Val<Vector3> FriendHead = Val.Value(() => FriendPos.Value + height); return new SequenceParallel( Friend.Node_HeadLook(WandererHead), Wanderer.Node_HeadLook(FriendHead)); }
public virtual RunStatus BodyAnimationCriminal(Val<string> gestureName, Val<bool> isActive) { if (criminal_interact) { if(thisCharacter != COP) { Wait(); } Debug.Log("Criminal action invoked!"); this.Body.BodyAnimation(gestureName.Value, isActive.Value); criminal_interact = false; return RunStatus.Success; } this.Body.BodyAnimation(gestureName.Value, false); return RunStatus.Success; }
protected Node Argue( Val<Vector3> P1Pos, Val<Vector3> P2Pos, Val<Vector3> P3Pos ) { return new Sequence( new SequenceParallel( person1.GetComponent<BehaviorMecanim>().Node_OrientTowards(P3Pos) , person2.GetComponent<BehaviorMecanim>().Node_OrientTowards(P3Pos) , deltrese.GetComponent<BehaviorMecanim>().Node_OrientTowards(P1Pos) ), new SequenceShuffle( deltrese.GetComponent<BehaviorMecanim>().Node_OrientTowards(P1Pos) , new LeafWait(1000) , deltrese.GetComponent<BehaviorMecanim>().Node_OrientTowards(P2Pos) ), person1.GetComponent<BehaviorMecanim>().ST_PlayHandGesture("dismissinggesture" , 3000), person2.GetComponent<BehaviorMecanim>().ST_PlayBodyGesture("shakingheadno" , 3000), deltrese.GetComponent<BehaviorMecanim>().ST_PlayBodyGesture("headnodyes" , 3000) ); }
private static Node Coerce( SmartCharacter aggressor, SmartCharacter target, Val<float> distance) { return new Sequence( aggressor.Node_GoToUpToRadius(Val.V(() => target.transform.position), distance), aggressor.Node_OrientTowards(Val.V(() => target.transform.position)), aggressor.Node_Icon("stickup"), new SequenceParallel( aggressor.Behavior.ST_PlayHandGesture("pistolaim", 4000), new Sequence( new LeafWait(2000), target.Node_OrientTowards(Val.V(() => aggressor.transform.position))))); }
protected Node ApproachAndOrient(GameObject a, GameObject b, Val<Vector3> target, Val<float> distance) { Quaternion rotA = Quaternion.LookRotation(b.transform.position - a.transform.position); Vector3 targetA = target.Value - (rotA * new Vector3(0, 0, distance.Value)); Quaternion rotB = Quaternion.LookRotation(a.transform.position - b.transform.position); Vector3 targetB = target.Value - (rotB * new Vector3(0, 0, distance.Value)); Val<Vector3> p1 = Val.V(() => targetA); Val<Vector3> p2 = Val.V(() => targetB); return new Sequence(new SequenceParallel(mec(a).Node_OrientTowards(p1), mec(b).Node_OrientTowards(p2)), new SequenceParallel(mec(a).Node_GoTo(p1), mec(b).Node_GoTo(p2)), new LeafInvoke(delegate { Debug.Log("Done walking"); }), new SequenceParallel(mec(a).Node_OrientTowards(target), mec(b).Node_OrientTowards(target))); }
/// <summary> /// Approaches a target at a given radius /// </summary> public Node Node_GoToUpToRadius(Val<Vector3> targ, Val<float> dist) { Func<RunStatus> GoUpToRadius = delegate() { Vector3 targPos = targ.Value; Vector3 curPos = this.transform.position; if ((targPos - curPos).magnitude < dist.Value) { this.Character.NavStop(); return RunStatus.Success; } return this.Character.NavGoTo(targ); }; return new LeafInvoke( GoUpToRadius, () => this.Character.NavStop()); }
public FuzzyMembershipFunction(string label, FuzzyVariable fuzzy_var, float slope, float origin, float width) { this.label = label; this.fuzzy_var = fuzzy_var; // Initialisation // The number of points for this FMF is determined by the resolution and the range of values for the variable N = Mathf.FloorToInt((fuzzy_var.max-fuzzy_var.min)/resolution)+1; this.x = new float[N]; this.y = new float[N]; // Default slopeVal = new Val(slope); originVal = new Val(origin); widthVal = new Val(width); recompute(); //Debug.Log(this); //startRecomputing(); }
/// <summary> /// Sets a new navigation target. Will fail immediately if the /// point is unreachable. Blocks until the agent arrives. /// </summary> public virtual RunStatus NavGoTo(Val<Vector3> target) { if (this.Body.NavCanReach(target.Value) == false) { Debug.LogWarning("NavGoTo failed -- can't reach target"); return RunStatus.Failure; } // TODO: I previously had this if statement here to prevent spam: // if (this.Interface.NavTarget() != target) // It's good for limiting the amount of SetDestination() calls we // make internally, but sometimes it causes the character1 to stand // still when we re-activate a tree after it's been terminated. Look // into a better way to make this smarter without false positives. - AS this.Body.NavGoTo(target.Value); if (this.Body.NavHasArrived() == true) { this.Body.NavStop(); return RunStatus.Success; } return RunStatus.Running; // TODO: Timeout? - AS }
/// <summary> /// Plays a gesture animation and blocks until it's done. Will fail if /// told to play a second animation while one is already active. /// </summary> public virtual RunStatus Gesture(Val<string> name) { // Cache the name's value string nameVal = name.Value; // We're not (visibly) playing an animation if (this.Body.Coordinator.aWeight.IsMinPrecise == true) { // Did we just finish playing the requested one? if (this.currentGesture == nameVal) { this.currentGesture = null; return RunStatus.Success; } // If not, start the animation else { this.currentGesture = nameVal; this.Body.AnimPlay(nameVal); return RunStatus.Running; } } // We're playing an animation, or transitioning else { if (this.currentGesture == nameVal) { return RunStatus.Running; } else { // We're busy with another animation return RunStatus.Failure; } } }
public static Node Node_Reach(this Character c, Val <Vector3> targ) { return(new LeafInvoke(() => c.ReachFor(targ), () => c.ReachStop())); }
private static float ParseKeyVal(string[] keyvals, Val val) => float.Parse(keyvals[(int)val], CultureInfo.InvariantCulture);
private Node Multiply(Val <Number> a, Val <Number> b) { return(new LeafInvoke(() => { a.Value.val *= b.Value.val; })); }
public static Node Node_Gesture(this Character c, Val <string> name) { return(new LeafInvoke(() => c.Gesture(name), () => c.GestureStop())); }
/// <summary> /// Sets a custom orientation behavior /// </summary> public virtual RunStatus NavOrientBehavior( Val <OrientationBehavior> behavior) { this.Body.NavSetOrientationBehavior(behavior.Value); return(RunStatus.Success); }
protected Node ST_ApproachAndWait(Transform target) { Val <Vector3> position = Val.V(() => target.position); return(new Sequence(participant.GetComponent <BehaviorMecanim>().Node_GoTo(position), new LeafWait(1000))); }
public WindowsService() : this(BounceRunner.Bounce.ShellCommand) { Machine = "localhost"; }
public Expr Apply(Val variable, Expr expr) => variable.Equals(this.variable) ? this : new Fun(this.variable, this.expr.Apply(this.variable, expr));
// // helpers for .net interop /// <summary> Extract a name from either the symbol or the string value of a val </summary> private static string GetStringOrSymbolName(Val v) => v.AsStringOrNull ?? v.AsSymbolOrNull?.name;
/// <summary> /// Command to look at a target point. /// </summary> public virtual void HeadLookAt(Val<Vector3> lookAtTarget) { this.ik.LookAt(lookAtTarget.Value); }
private static Val ValGTE(Val a, Val b) => a.CastToFloat >= b.CastToFloat;
/// <summary> Generates a sequence containing a single instruction </summary> private List <Instruction> Emit(Opcode type, Val first, string debug = null) => new List <Instruction>() { new Instruction(type, first, debug) };
/// <summary> /// If f is a symbol that refers to a primitive, and it's not shadowed in the local environment, /// returns an appropriate instance of Primitive for that argument count. /// </summary> public static Primitive FindGlobal(Val f, Data.Environment env, int nargs) => (f.IsSymbol && Data.Environment.GetVariable(f.AsSymbol, env).IsNotValid) ? FindNary(f.AsSymbol.name, nargs) : null;
public Expr ApplyUUID(Val a) => variable.value.Equals(a.value) ? this : new Fun(variable, expr.ApplyUUID(a));
public static Node Node_GoTo(this Character c, Val <Vector3> targ) { return(new LeafInvoke(() => c.NavGoTo(targ), () => c.NavStop())); }
public virtual RunStatus HeadLookAt(Val <Vector3> target) { this.Body.HeadLookAt(target); return(RunStatus.Success); }
public Node(Key key, Val value, Node next) { this.key = key; this.value = value; this.next = next; }
public virtual RunStatus StopInteraction(Val <FullBodyBipedEffector> effector) { this.Body.StopInteraction(effector); return(RunStatus.Success); }
public override int GetHashCode() { return(Val.GetHashCode()); }
/// <summary> Runs the given piece of code, and returns the value left at the top of the stack. </summary> public Val Execute(Closure fn, params Val[] args) { State st = new State(fn, args); CodeHandle code = default; List <Instruction> instructions = null; if (_logger.EnableInstructionLogging) { _logger.Log("Executing: ", fn.name); _logger.Log(_ctx.code.DebugPrint(fn)); } while (!st.done) { if (!code.Equals(st.fn.code)) { code = st.fn.code; instructions = _ctx.code.Get(code).instructions; } if (st.pc >= instructions.Count) { throw new LanguageError("Runaway opcodes!"); } // fetch instruction Instruction instr = instructions[st.pc++]; if (_logger.EnableStackLogging) { _logger.Log(" " + State.PrintStack(st)); _logger.Log(string.Format("[{0,2}] {1,3} : {2}", st.stack.Count, st.pc - 1, instr.DebugPrint())); } // and now a big old switch statement. not handler functions - this is much faster. switch (instr.type) { case Opcode.LABEL: // no op :) break; case Opcode.PUSH_CONST: { st.Push(instr.first); } break; case Opcode.LOCAL_GET: { VarPos pos = new VarPos(instr.first, instr.second); Val value = Environment.GetValueAt(pos, st.env); st.Push(value); } break; case Opcode.LOCAL_SET: { VarPos pos = new VarPos(instr.first, instr.second); Val value = st.Peek(); Environment.SetValueAt(pos, value, st.env); } break; case Opcode.GLOBAL_GET: { Symbol symbol = instr.first.AsSymbol; Val value = symbol.pkg.GetValue(symbol); st.Push(value); } break; case Opcode.GLOBAL_SET: { Symbol symbol = instr.first.AsSymbol; Val value = st.Peek(); symbol.pkg.SetValue(symbol, value); } break; case Opcode.STACK_POP: st.Pop(); break; case Opcode.JMP_IF_TRUE: { Val value = st.Pop(); if (value.CastToBool) { st.pc = GetLabelPosition(instr); } } break; case Opcode.JMP_IF_FALSE: { Val value = st.Pop(); if (!value.CastToBool) { st.pc = GetLabelPosition(instr); } } break; case Opcode.JMP_TO_LABEL: { st.pc = GetLabelPosition(instr); } break; case Opcode.MAKE_ENV: { int argcount = instr.first.AsInt; if (st.argcount != argcount) { throw new LanguageError($"Argument count error, expected {argcount}, got {st.argcount}"); } // make an environment for the given number of named args st.env = new Environment(st.argcount, st.env); // move named arguments onto the stack frame for (int i = argcount - 1; i >= 0; i--) { st.env.SetValue(i, st.Pop()); } } break; case Opcode.MAKE_ENVDOT: { int argcount = instr.first.AsInt; if (st.argcount < argcount) { throw new LanguageError($"Argument count error, expected {argcount} or more, got {st.argcount}"); } // make an environment for all named args, +1 for the list of remaining varargs int dotted = st.argcount - argcount; st.env = new Environment(argcount + 1, st.env); // cons up dotted values from the stack for (int dd = dotted - 1; dd >= 0; dd--) { Val arg = st.Pop(); st.env.SetValue(argcount, new Val(new Cons(arg, st.env.GetValue(argcount)))); } // and move the named ones onto the environment stack frame for (int i = argcount - 1; i >= 0; i--) { st.env.SetValue(i, st.Pop()); } } break; case Opcode.DUPLICATE: { if (st.stack.Count == 0) { throw new LanguageError("Cannot duplicate on an empty stack!"); } st.Push(st.Peek()); } break; case Opcode.JMP_CLOSURE: { st.env = st.env.parent; // discard the top environment frame Val top = st.Pop(); Closure closure = top.AsClosureOrNull; // set vm state to the beginning of the closure st.fn = closure ?? throw new LanguageError($"Unknown function during function call around: {DebugRecentInstructions(st, instructions)}"); st.env = closure.env; st.pc = 0; st.argcount = instr.first.AsInt; } break; case Opcode.SAVE_RETURN: { // save current vm state to a return value st.Push(new Val(new ReturnAddress(st.fn, GetLabelPosition(instr), st.env, instr.first.AsStringOrNull))); } break; case Opcode.RETURN_VAL: if (st.stack.Count > 1) { // preserve return value on top of the stack Val retval = st.Pop(); ReturnAddress retaddr = st.Pop().AsReturnAddress; st.Push(retval); // restore vm state from the return value st.fn = retaddr.fn; st.env = retaddr.env; st.pc = retaddr.pc; } else { st.done = true; // this will force the virtual machine to finish up } break; case Opcode.MAKE_CLOSURE: { var cl = instr.first.AsClosure; st.Push(new Closure(cl.code, st.env, null, cl.name)); } break; case Opcode.CALL_PRIMOP: { string name = instr.first.AsString; int argn = (instr.second.IsInt) ? instr.second.AsInt : st.argcount; Primitive prim = Primitives.FindNary(name, argn); if (prim == null) { throw new LanguageError($"Invalid argument count to primitive {name}, count of {argn}"); } Val result = prim.Call(_ctx, argn, st); st.Push(result); } break; default: throw new LanguageError("Unknown instruction type: " + instr.type); } } // return whatever's on the top of the stack if (st.stack.Count == 0) { throw new LanguageError("Stack underflow!"); } return(st.Peek()); }
public override string ToString() { return(Val.ToString()); }
public override string ToPrintString(ref int depth) { StringBuilder sb = new StringBuilder(); string tagName = TLVMetaDataSourceSingleton.Instance.DataSource.GetName(Tag.TagLable); string formatter = "{0,-75}"; sb.AppendLine(string.Format(formatter, Tag.ToString() + " " + tagName + " L:[" + Val.GetLength().ToString() + "]")); sb.AppendLine("V:["); sb.AppendLine("\tStatus->" + Value.Status); sb.AppendLine("\tStart->" + Value.Start); sb.AppendLine("\tOnlineResponseData->" + Value.OnlineResponseData); sb.AppendLine("\tCVM->" + Value.CVM); sb.AppendLine("\tUIRequestOnOutcomePresent->" + Value.UIRequestOnOutcomePresent); sb.AppendLine("\tUIRequestOnRestartPresent->" + Value.UIRequestOnRestartPresent); sb.AppendLine("\tDataRecordPresent->" + Value.DataRecordPresent); sb.AppendLine("\tDiscretionaryDataPresent->" + Value.DiscretionaryDataPresent); sb.AppendLine("\tReceipt->" + Value.Receipt); sb.AppendLine("\tAlternateInterfacePreference->" + Value.AlternateInterfacePreference); sb.AppendLine("\tFieldOffRequest->" + Formatting.ByteArrayToHexString(new byte[] { Value.FieldOffRequest })); sb.AppendLine("\tRemovalTimeout->" + Formatting.ByteArrayToHexString(new byte[] { Value.RemovalTimeout })); sb.AppendLine("]"); return(sb.ToString()); }
public override int CompareTo(Var other) { return(base.CompareTo(other) == 0 ? 0 : Val.CompareTo(((VInt)other).Val)); }
private Node Add(Val <Number> a, Val <Number> b) { return(new LeafInvoke(() => { a.Value.val += b.Value.val; })); }
/// <summary> /// Compiles the expression x, given the environment env, into a vector of instructions. /// </summary> private List <Instruction> Compile(Val x, Environment env, State st) { // check if macro if (IsMacroApplication(x)) { return(Compile(MacroExpandFull(x), env, st)); } if (x.IsSymbol) // check if symbol { return(CompileVariable(x.AsSymbol, env, st)); } if (x.IsAtom) // check if it's not a list { return(CompileConstant(x, st)); } // it's not an atom, it's a list, deal with it. VerifyExpression(Cons.IsList(x), "Non-list expression detected!"); Cons cons = x.AsConsOrNull; Symbol name = cons.first.AsSymbolOrNull; if (name == _quote) // (quote value) { VerifyArgCount(cons, 1); return(CompileConstant(cons.second, st)); // second element is the constant } if (name == _begin) // (begin ...) { return(CompileBegin(cons.rest, env, st)); } if (name == _set) // (set! symbol-name value) { VerifyArgCount(cons, 2); VerifyExpression(cons.second.IsSymbol, "Invalid lvalue in set!, must be a symbol, got: ", cons.second); return(CompileVarSet(cons.second.AsSymbol, cons.third, env, st)); } if (name == _if) // (if pred then else) or (if pred then) { VerifyArgCount(cons, 2, 3); return(CompileIf( cons.second, // pred cons.third, // then (cons.afterThird.IsNotNil ? cons.fourth : Val.NIL), // else env, st)); } if (name == _ifStar) // (if *pred else) { VerifyArgCount(cons, 2); return(CompileIfStar( cons.second, // pred cons.third, // else env, st)); } if (name == _while) // (while pred body ...) { Cons body = cons.afterSecond.AsConsOrNull; return(CompileWhile(cons.second, body, env, st)); } if (name == _lambda) // (lambda (args...) body...) { if (st.IsUnused) { return(null); // it's not used, don't compile } else { Cons body = cons.afterSecond.AsConsOrNull; Closure f = CompileLambda(cons.second, body, env); //string debug = $"#{f.code.index} : " + Val.DebugPrint(cons.afterSecond); string debug = Val.DebugPrint(cons.afterSecond); return(Merge( Emit(Opcode.MAKE_CLOSURE, new Val(f), Val.NIL, debug), EmitIf(st.IsFinal, Emit(Opcode.RETURN_VAL)))); } } if (name == _defmacro) { return(CompileAndInstallMacroDefinition(cons.rest.AsConsOrNull, env, st)); } return(CompileFunctionCall(cons.first, cons.rest.AsConsOrNull, env, st)); }
public static Node Node_HeadLook(this Character c, Val <Vector3> targ) { return(new LeafInvoke(() => c.HeadLook(targ), () => c.HeadLookStop())); }
public virtual RunStatus BodyAnimation(Val <string> gestureName, Val <bool> isActive) { this.Body.BodyAnimation(gestureName.Value, isActive.Value); return(RunStatus.Success); }
protected void btnUpdate_Click(object sender, EventArgs e) { string first, last, email; try { first = txFirst.Text.Trim(); last = txLast.Text.Trim(); email = txEmail.Text.Trim().ToLower(); // QueryString Info for Primary Key & Email Info I = (Info)Session["data"]; // Validation if (!Valid(first, last, email, txEmailConfirm.Text.Trim().ToLower())) { return; } // VAL: SQL Email Already in System if (_sql.State == ConnectionState.Closed) { _sql.Open(); } var com = new SqlCommand("SELECT count([id]) FROM [UserData] WHERE [Email]=@email AND [id]<>@id", _sql); com.Parameters.AddWithValue("@email", email); com.Parameters.AddWithValue("@id", I.id); if ((int)com.ExecuteScalar() > 0) { lbErrorMsg.Text = "The Specified Email is already registered in the system."; return; } // Val ReCaptcha if (!CheckRecaptcha(email)) { return; } // SQL Update with new Data if (_sql.State == ConnectionState.Closed) { _sql.Open(); } string cm = "UPDATE [UserData] SET [First]=@First, [Last]=@Last, [Email]=@Email WHERE [id]=@id"; com = new SqlCommand(cm, _sql); com.Parameters.AddWithValue("@First", Val.UpperFirst(first)); com.Parameters.AddWithValue("@Last", Val.UpperFirst(last)); com.Parameters.AddWithValue("@Email", email); com.Parameters.AddWithValue("@id", I.id); if (com.ExecuteNonQuery() == 0) { throw new Exception("Could Not update user data. email: " + I.Email); } // Update Login Session["data"] = new Info(I.id, first, email); // Disable btnUpdate.Enabled = txEmailConfirm.Enabled = false; txEmailConfirm.Text = ""; // Success User lbSuccess.Text = "Information Updated Successfully!"; } catch (Exception ex) // Exit { _sql.Close(); lbErrorMsg.Text = Logger._erMsg; Logger.Log(ex); return; } _sql.Close(); // Browser Back Navigation causes issue: This is why reload. Response.Redirect("~/EditUserInfo.aspx?msg=" + Server.UrlEncode(lbSuccess.Text)); }
protected void btnReset_Click(object sender, EventArgs e) { string code = Request.QueryString["code"].Trim(); string pass = txPass.Text.Trim(), confirm = txConfirm.Text.Trim(); // VAL Password if (pass.Length < 5) { lbErrorMsg.Text = "Password Needs to be at least 5 characters & Cannot be empty."; return; } else if (!Val.IsAlphaNumSymbols(pass, Val._passSym, length: 30)) { lbErrorMsg.Text = "Invalid Password: make sure you are using accepted symbols. Passwords are Case Sensitive."; return; } else if (pass != confirm) { lbErrorMsg.Text = "Password & Confirm_Password are Not equal."; return; } // VAL code if (string.IsNullOrEmpty(code) || !Val.IsAlphaNum(code)) { lbErrorMsg.Text = "Invalid Authorization Code. Please try a different link or Contact Support."; Lock(); return; } try { // SQL Find by code if (_sql.State == ConnectionState.Closed) { _sql.Open(); } var com = new SqlCommand("SELECT [expiry],[user] FROM [PasswordReset] WHERE [code]=@code", _sql); com.Parameters.AddWithValue("@code", code); var reader = com.ExecuteReader(); if (!reader.Read()) { lbErrorMsg.Text = "Authorization Code may have Expired. <br />Please go through the process again by going to " + "Login & selecting 'Forgot Password Link' or Contact Support."; Lock(); return; } string email = reader["user"].ToString(); var expiry = DateTime.Parse(reader["expiry"].ToString()); if (reader.Read()) { throw new Exception("Extra rows. authCode: " + code); } reader.Close(); // SQL Delete Auth. Code com = new SqlCommand("DELETE FROM [PasswordReset] WHERE [code]=@code", _sql); com.Parameters.AddWithValue("@code", code); if (com.ExecuteNonQuery() == 0) { throw new Exception("Could Not delete authCode row. code: " + code); } // Check Expiry if (expiry.Subtract(DateTime.Now).TotalMinutes < 0) { lbErrorMsg.Text = "Sorry, your Password Authorization code has Expired. <br />Please go through the process again by going to " + "Login & selecting 'Forgot Password Link' or Contact Support."; Lock(); return; } // SQL Update Password // WHERE Email: has to be email cuz that is whats in PasswordReset, and [PasswordRest] is very current & will be deleted after use. com = new SqlCommand("UPDATE [UserData] SET [Password]=@Password WHERE [Email]=@Email", _sql); com.Parameters.AddWithValue("@Password", Val.Encrypt(pass)); // Encypt Password com.Parameters.AddWithValue("@Email", email); if (com.ExecuteNonQuery() == 0) { throw new Exception("Could Not update sql password. email: " + email); } } catch (Exception ex) // EXIT: sql Close included { _sql.Close(); lbErrorMsg.Text = Logger._erMsg; Logger.Log(ex); return; } _sql.Close(); // Navigate to login with message, otherwise it will redirect them to this page string msg = "Password Reset Successful. You have Authorization to Login with your new password."; Response.Redirect("~/Login.aspx?msg=" + Server.UrlEncode(msg)); }
private string GetSetting(Val<string> setting, string scSetting) { if (setting != null && setting.Value != null) { return String.Format(@" {0}= ""{1}""", scSetting, setting.Value); } else { return ""; } }
public int CompareTo(MaskableInt32 other) { return(Val.CompareTo(other.Val)); }
private static Val ValLTE(Val a, Val b) => a.CastToFloat <= b.CastToFloat;
/// <summary> Convenience function: checks if the value is of type Symbol, and has the specified name </summary> private static bool IsSymbolWithName(Val value, string fullName) => value.AsSymbolOrNull?.fullName == fullName;