/// <summary> /// Constructor /// </summary> /// <param name="dictionary"></param> public BoolType(EfsSystem efsSystem) : base(efsSystem, "Boolean") { True = new BoolValue(this, true); False = new BoolValue(this, false); InitDeclaredElements(); }
override public void AssignValues (List<ActionParameter> parameters) { variableID = AssignVariableID (parameters, parameterID, variableID); intValue = AssignInteger (parameters, checkParameterID, intValue); boolValue = AssignBoolean (parameters, checkParameterID, boolValue); floatValue = AssignFloat (parameters, checkParameterID, floatValue); stringValue = AssignString (parameters, checkParameterID, stringValue); compareVariableID = AssignVariableID (parameters, checkParameterID, compareVariableID); }
public override void AssignValues(List<ActionParameter> parameters) { variableID = AssignVariableID (parameters, parameterID, variableID); intValue = AssignInteger (parameters, setParameterID, intValue); boolValue = AssignBoolean (parameters, setParameterID, boolValue); floatValue = AssignFloat (parameters, setParameterID, floatValue); stringValue = AssignString (parameters, setParameterID, stringValue); formula = AssignString (parameters, setParameterID, formula); slotNumber = AssignInteger (parameters, slotNumberParameterID, slotNumber); }
/// <summary> /// Provides the value of the expression provided /// </summary> /// <param name="expect"></param> /// <returns></returns> private bool getBoolValue(ModelElement instance, Expression expression) { bool retVal = false; Interpreter.InterpretationContext context = new Interpreter.InterpretationContext(instance); BoolValue val = expression.GetValue(context) as BoolValue; if (val != null) { retVal = val.Val; } else { throw new Exception("Cannot evaluate vaue of " + expression); } return(retVal); }
public ViewModel_BRUS() { repos = ModelVariableRepository.Instance; Podsvet = repos.BitValues[1].ValState[0]; Vent = repos.BitValues[1].ValState[1]; Ilym = repos.BitValues[1].ValState[2]; BoaSaOsn = repos.BitValues[1].ValState[3]; BoaSaRez = repos.BitValues[1].ValState[4]; Vsa = repos.BitValues[1].ValState[5]; PitEpkrdOsn = repos.BitValues[1].ValState[6]; PitEpkrdRez = repos.BitValues[1].ValState[7]; RazreshRrst = repos.BitValues[1].ValState[8]; Pvk = repos.BitValues[1].ValState[9]; Pbk = repos.BitValues[1].ValState[10]; Vp1 = repos.BitValues[1].ValState[11]; Vp2 = repos.BitValues[1].ValState[12]; Sro = repos.BitValues[1].ValState[13]; }
public override int GetHashCode() { unchecked { var result = GuidValue.GetHashCode(); result = (result * 397) ^ (StringValue != null ? StringValue.GetHashCode() : 0); result = (result * 397) ^ IntValue; result = (result * 397) ^ LongValue.GetHashCode(); result = (result * 397) ^ BoolValue.GetHashCode(); result = (result * 397) ^ ByteValue.GetHashCode(); result = (result * 397) ^ DecimalValue.GetHashCode(); result = (result * 397) ^ DoubleValue.GetHashCode(); result = (result * 397) ^ DateTimeValue.GetHashCode(); result = (result * 397) ^ MaybeMoney.GetHashCode(); result = (result * 397) ^ TimeSpanValue.GetHashCode(); return(result); } }
public void ExecuteOnTarget(HeroKitObject targetObject, string childName) { Transform transform = null; if (childName == "") { transform = targetObject.transform; } else { transform = targetObject.GetHeroChildComponent <Transform>("Transform", childName); } Vector3 pos = transform.localPosition; // get the values to update bool changeX = BoolValue.GetValue(heroKitObject, 4); if (changeX) { pos.x = FloatFieldValue.GetValueA(heroKitObject, 5); position.x = pos.x; } bool changeY = BoolValue.GetValue(heroKitObject, 6); if (changeY) { pos.y = FloatFieldValue.GetValueA(heroKitObject, 7); position.y = pos.y; } bool changeZ = BoolValue.GetValue(heroKitObject, 8); if (changeZ) { pos.z = FloatFieldValue.GetValueA(heroKitObject, 9); position.z = pos.z; } // update the transform transform.localPosition = pos; }
// Gets objects in a scene that match a certerin criteria public int Execute(HeroKitObject hko) { // Get variables heroKitObject = hko; SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false); HeroKitListenerUI listener = null; if (objectData.heroKitObject != null) { listener = objectData.heroKitObject[0].GetHeroComponent <HeroKitListenerUI>("HeroKitListenerUI"); } else if (objectData.gameObject != null) { listener = heroKitObject.GetGameObjectComponent <HeroKitListenerUI>("HeroKitListenerUI", false, objectData.gameObject[0]); } if (listener != null) { // get item id bool getItemID = BoolValue.GetValue(heroKitObject, 2); if (getItemID) { IntegerFieldValue.SetValueB(heroKitObject, 3, listener.itemID); } // get item id bool getItem = BoolValue.GetValue(heroKitObject, 4); if (getItem) { HeroObjectFieldValue.SetValueC(heroKitObject, 5, listener.item); } } //------------------------------------ // debug message //------------------------------------ if (heroKitObject.debugHeroObject) { string debugMessage = "Hero Kit Listener: " + listener; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
private void CmdSendServerValueBool(string eventName, bool value) { var vh = GetComponent <ValueHolder>(); if (vh.ContainsKey(eventName)) { var val = vh[eventName] as CATGenericValueComponent <bool>; if (val != null) { val.IsReplicating = true; val.SetValue(new CATContext(vh.gameObject), value); val.IsReplicating = false; } } else { vh[eventName] = new BoolValue(value); } }
public void SerializeValue() { Value a = new IntValue(1); Value b = Reserialize(a); Assert.AreEqual(a, b); a = new FloatValue(1.0f); b = Reserialize(a); Assert.AreEqual(a, b); a = new StringValue("1"); b = Reserialize(a); Assert.AreEqual(a, b); a = new BoolValue(true); b = Reserialize(a); Assert.AreEqual(a, b); }
/// <summary> /// Indicates whether the condition is satisfied with the value provided /// Hyp : the value of the iterator variable has been assigned before /// </summary> /// <param name="context"></param> /// <param name="explain"></param> /// <returns></returns> public bool ConditionSatisfied(InterpretationContext context, ExplanationPart explain) { bool retVal = true; if (Condition != null) { BoolValue b = Condition.GetValue(context, explain) as BoolValue; if (b == null) { retVal = false; } else { retVal = b.Val; } } return(retVal); }
public override int GetHashCode() { int hash = 1; if (BoolValue != false) { hash ^= BoolValue.GetHashCode(); } if (IntValue != 0L) { hash ^= IntValue.GetHashCode(); } if (FloatValue != 0D) { hash ^= FloatValue.GetHashCode(); } if (StringValue.Length != 0) { hash ^= StringValue.GetHashCode(); } if (BlobValue.Length != 0) { hash ^= BlobValue.GetHashCode(); } if (MessageValue.Length != 0) { hash ^= MessageValue.GetHashCode(); } if (FourccValue.Length != 0) { hash ^= FourccValue.GetHashCode(); } if (UintValue != 0UL) { hash ^= UintValue.GetHashCode(); } if (entityIdValue_ != null) { hash ^= EntityIdValue.GetHashCode(); } return(hash); }
private void AfterDeserialization() { var evaluatedSolutions = new IntValue(0); var checkExpressionsWithIntervalArithmetic = new BoolValue(false); if (Parameters.ContainsKey(EvaluatedSolutionsParameterName)) { var evaluatedSolutionsParameter = (IValueParameter <IntValue>)Parameters[EvaluatedSolutionsParameterName]; evaluatedSolutions = evaluatedSolutionsParameter.Value; Parameters.Remove(EvaluatedSolutionsParameterName); } Parameters.Add(new FixedValueParameter <IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", evaluatedSolutions)); if (Parameters.ContainsKey(CheckExpressionsWithIntervalArithmeticParameterName)) { var checkExpressionsWithIntervalArithmeticParameter = (IValueParameter <BoolValue>)Parameters[CheckExpressionsWithIntervalArithmeticParameterName]; Parameters.Remove(CheckExpressionsWithIntervalArithmeticParameterName); checkExpressionsWithIntervalArithmetic = checkExpressionsWithIntervalArithmeticParameter.Value; } Parameters.Add(new FixedValueParameter <BoolValue>(CheckExpressionsWithIntervalArithmeticParameterName, CheckExpressionsWithIntervalArithmeticParameterDescription, checkExpressionsWithIntervalArithmetic)); }
public override async Task <BoolValue> ClearBasket(Empty request, ServerCallContext context) { BoolValue status = new BoolValue(); var userId = _httpContextAccessor.HttpContext.User?.FindFirst(x => x.Type.Equals("sub"))?.Value; if (userId != null) { var basketItemsJson = await _cache.GetStringAsync(userId); if (!string.IsNullOrEmpty(basketItemsJson)) { await _cache.RemoveAsync(userId); status.Value = true; return(await Task.FromResult(status)); } } status.Value = false; return(await Task.FromResult(status)); }
public void ExecuteOnTarget(HeroKitObject targetObject, string childName) { Transform transform = null; if (childName == "") { transform = targetObject.transform; } else { transform = targetObject.GetHeroChildComponent <Transform>("Transform", childName); } if (transform != null) { Vector3 degrees = new Vector3(); // get the target rotation bool changeX = BoolValue.GetValue(heroKitObject, 4); if (changeX) { degrees.x = IntegerFieldValue.GetValueA(heroKitObject, 5); degreesToChange.x = degrees.x; } bool changeY = BoolValue.GetValue(heroKitObject, 6); if (changeY) { degrees.y = IntegerFieldValue.GetValueA(heroKitObject, 7); degreesToChange.y = degrees.y; } bool changeZ = BoolValue.GetValue(heroKitObject, 8); if (changeZ) { degrees.z = IntegerFieldValue.GetValueA(heroKitObject, 9); degreesToChange.z = degrees.z; } // change the rotation transform.localEulerAngles = transform.localEulerAngles + degrees; } }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1); bool useLayers = BoolValue.GetValue(heroKitObject, 2); bool runThis = (targetObject != null); // execute action for all objects in list for (int i = 0; runThis && i < targetObject.Length; i++) { ExecuteOnTarget(targetObject[i], useLayers); } // debug message if (heroKitObject.debugHeroObject) { Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject)); } return(-99); }
static Constants() { BoolValue = true; DateTimeValue = DateTime.Parse(DateTime.MaxValue.ToString(), CultureInfo.InvariantCulture); DecimalValue = Decimal.MaxValue; GuidValue = Guid.NewGuid(); Int16Value = Int16.MaxValue; Int32Value = Int32.MaxValue; Int64Value = Int64.MaxValue; StringValue = Guid.NewGuid().ToString(); NullableInt64Value = Int64.MaxValue; BoolStringValue = BoolValue.ToString(); DateTimeStringValue = DateTimeValue.ToString(); DecimalStringValue = DecimalValue.ToString(); GuidStringValue = GuidValue.ToString(); Int16StringValue = Int16Value.ToString(); Int32StringValue = Int32Value.ToString(); Int64StringValue = Int64Value.ToString(); NullableInt64StringValue = NullableInt64Value.ToString(); }
/* public bool Avtomat * { * get * { * if (repos == null) return false; * return repos.BitValues[2].ValState[14].ValueState; * } * } * public bool Osnov * { * get * { * if (repos == null) return false; * return repos.BitValues[2].ValState[15].ValueState; * } * } * public bool Dubl * { * get * { * if (repos == null) return false; * return repos.BitValues[2].ValState[16].ValueState; * } * }*/ public ViewModel_BAPD() { repos = ModelVariableRepository.Instance; Avtomat = repos.BitValues[2].ValState[13]; Osnov = repos.BitValues[2].ValState[14]; Dubl = repos.BitValues[2].ValState[15]; repos.BitValues[2].ValState[13].PropertyChanged += delegate { Debug.WriteLine(Avtomat.ValueState + "-A"); }; repos.BitValues[2].ValState[14].PropertyChanged += delegate { Debug.WriteLine(Osnov.ValueState + "-O"); }; repos.BitValues[2].ValState[15].PropertyChanged += delegate { Debug.WriteLine(Dubl.ValueState + "-D"); }; }
public IValue Visit(Argument argument) { //var current = Environment.GetCurrentFrame(); //Console.WriteLine("ARGUMENT STATEMENT"); if (Environment.ContainsVarInCurrCall(argument.id)) { var err = new ErrorMessage(); throw new EvaluationError(err.ErrorOutput(ErrorMessage.ErrorCode.DECL, argument)); } var typeName = ((Syntax.Type)argument.type).GetType().Name; IValue value = new NumberValue(0); if (typeName != "IntType") { value = new BoolValue(false); } Environment.AddVar(argument.id, value); return(null); // new PointerValue(0); }
} //расчитанная скорость /// <summary> /// Конструкор, инициализация состояний /// </summary> public ViewModel_LDI() { l1 = new IntValue(); l1.ValueState = -1; l2 = new IntValue(); l2.ValueState = -1; l3 = new IntValue(); l3.ValueState = -1; l4 = new IntValue(); l4.ValueState = -1; l5 = new IntValue(); l5.ValueState = -1; ls1 = new IntValue(); ls1.ValueState = -1; ls2 = new IntValue(); ls2.ValueState = -1; ls3 = new IntValue(); ls3.ValueState = -1; ls4 = new IntValue(); ls4.ValueState = -1; lamp1 = new BoolValue(); lamp1.ValueState = false; lamp2 = new BoolValue(); lamp2.ValueState = false; Indicator = new IntValue(); Indicator.ValueState = 0; Razryad = new IntValue(); Razryad.ValueState = 4; Speed = new DoubleValue(); Speed.ValueState = 0d; curValue3 = 0; rspeed = 0; }
public override int GetHashCode() { int hash = 1; hash ^= Labels.GetHashCode(); if (startTime_ != null) { hash ^= StartTime.GetHashCode(); } if (endTime_ != null) { hash ^= EndTime.GetHashCode(); } if (valueCase_ == ValueOneofCase.BoolValue) { hash ^= BoolValue.GetHashCode(); } if (valueCase_ == ValueOneofCase.Int64Value) { hash ^= Int64Value.GetHashCode(); } if (valueCase_ == ValueOneofCase.DoubleValue) { hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DoubleValue); } if (valueCase_ == ValueOneofCase.StringValue) { hash ^= StringValue.GetHashCode(); } if (valueCase_ == ValueOneofCase.DistributionValue) { hash ^= DistributionValue.GetHashCode(); } hash ^= (int)valueCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
/// <summary> /// Applies this step activation be registering it in the activation cache /// </summary> /// <param name="runner"></param> public override void Apply(Runner runner) { base.Apply(runner); TimeLine.SubStepActivationCache[SubStep] = this; foreach (VariableUpdate update in Updates) { TimeLine.AddModelEvent(update, true); } // Store the step corresponding expectations foreach (Expectation expectation in SubStep.Expectations) { bool addExpectation = true; if (expectation.getKind() == acceptor.ExpectationKind.aInstantaneous) { if (!String.IsNullOrEmpty(expectation.getCondition())) { Expression expression = new Parser().Expression(expectation, expectation.getCondition()); BoolValue value = expression.GetExpressionValue(new InterpretationContext(expectation), null) as BoolValue; if (value != null) { addExpectation = value.Val; } else { throw new Exception("Cannot evaluate " + expectation.getCondition() + " as a boolean value"); } } } if (addExpectation) { TimeLine.AddModelEvent(new Expect(expectation, runner.CurrentPriority), true); } } }
/// <summary> /// Parse the AST constant node and return Object value. /// </summary> /// <param name="node">parse node for which to parse the string value</param> /// <returns>value matching AST node type</returns> public static Object Parse(IParseTree node) { if (node is ITerminalNode) { var terminal = (ITerminalNode) node; switch(terminal.Symbol.Type) { case EsperEPL2GrammarParser.BOOLEAN_TRUE: return BoolValue.ParseString(terminal.GetText()); case EsperEPL2GrammarParser.BOOLEAN_FALSE: return BoolValue.ParseString(terminal.GetText()); case EsperEPL2GrammarParser.VALUE_NULL: return null; default: throw ASTWalkException.From("Encountered unexpected constant type " + terminal.Symbol.Type, terminal.Symbol); } } else { var ruleNode = (IRuleNode)node; var ruleIndex = ruleNode.RuleContext.RuleIndex; if (ruleIndex == EsperEPL2GrammarParser.RULE_number) { return ParseNumber(ruleNode, 1); } else if (ruleIndex == EsperEPL2GrammarParser.RULE_numberconstant) { var number = FindChildRuleByType(ruleNode, EsperEPL2GrammarParser.RULE_number); if (ruleNode.ChildCount > 1) { if (ASTUtil.IsTerminatedOfType(ruleNode.GetChild(0), EsperEPL2GrammarLexer.MINUS)) { return ParseNumber(number, -1); } return ParseNumber(number, 1); } else { return ParseNumber(number, 1); } } else if (ruleIndex == EsperEPL2GrammarParser.RULE_stringconstant) { return StringValue.ParseString(node.GetText()); } else if (ruleIndex == EsperEPL2GrammarParser.RULE_constant) { return Parse(ruleNode.GetChild(0)); } throw ASTWalkException.From("Encountered unrecognized constant", node.GetText()); } }
// Gets objects in a scene that match a certerin criteria public int Execute(HeroKitObject hko) { // Get variables heroKitObject = hko; // Get values GameObject targetObject = GameObjectFieldValue.GetValueB(heroKitObject, 0); bool useName = BoolValue.GetValue(heroKitObject, 2); string name = (useName) ? StringFieldValue.GetValueA(heroKitObject, 3) : ""; bool useTag = BoolValue.GetValue(heroKitObject, 4); string tag = (useTag) ? TagValue.GetValue(heroKitObject, 5) : ""; bool useLayer = BoolValue.GetValue(heroKitObject, 6); int layer = (useLayer) ? DropDownListValue.GetValue(heroKitObject, 7) - 1 : 0; GameObject childObject = null; bool runThis = (targetObject != null); if (runThis) { // get the child object childObject = GetChild(targetObject, useName, name, useTag, tag, useLayer, layer); // save the game object GameObjectFieldValue.SetValueB(heroKitObject, 8, childObject); } //----------------------------------------- // debugging stuff //----------------------------------------- if (heroKitObject.debugHeroObject) { string strLayer = (useLayer) ? layer.ToString() : ""; string debugMessage = "Child: " + childObject + "\n" + "With Tag: " + tag + "\n" + "On Layer: " + strLayer + "\n" + "With Name: " + name; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
/// <summary> /// Provides the value associated to this Expression /// </summary> /// <param name="context">The context on which the value must be found</param> /// <param name="explain">The explanation to fill, if any</param> /// <returns></returns> protected internal override IValue GetValue(InterpretationContext context, ExplanationPart explain) { IValue retVal = EfsSystem.Instance.BoolType.False; ListValue value = ListExpression.GetValue(context, explain) as ListValue; if (value != null) { int token = PrepareIteration(context); retVal = EfsSystem.Instance.BoolType.False; foreach (IValue v in value.Val) { if (v != EfsSystem.Instance.EmptyValue) { // All elements should always be != from EmptyValue ElementFound = true; IteratorVariable.Value = v; if (Condition != null) { BoolValue b = Condition.GetValue(context, explain) as BoolValue; if (b != null && b.Val) { MatchingElementFound = true; retVal = EfsSystem.Instance.BoolType.True; break; } } else { retVal = EfsSystem.Instance.BoolType.True; break; } } NextIteration(); } EndIteration(context, explain, token); } return(retVal); }
public override void AssignValues(List <ActionParameter> parameters) { switch (method) { case OptionSetMethod.Language: index = AssignInteger(parameters, indexParameterID, index); break; case OptionSetMethod.Subtitles: BoolValue boolValue = (BoolValue)index; boolValue = AssignBoolean(parameters, indexParameterID, boolValue); index = (int)boolValue; break; case OptionSetMethod.SFXVolume: case OptionSetMethod.SpeechVolume: case OptionSetMethod.MusicVolume: volume = AssignFloat(parameters, volumeParameterID, volume); volume = Mathf.Clamp01(volume); break; } }
public override int GetHashCode() { int hash = 1; if (Name.Length != 0) { hash ^= Name.GetHashCode(); } if (Type != 0) { hash ^= Type.GetHashCode(); } if (TypeName.Length != 0) { hash ^= TypeName.GetHashCode(); } if (oneofValueCase_ == OneofValueOneofCase.BoolValue) { hash ^= BoolValue.GetHashCode(); } if (oneofValueCase_ == OneofValueOneofCase.IntValue) { hash ^= IntValue.GetHashCode(); } if (oneofValueCase_ == OneofValueOneofCase.DoubleValue) { hash ^= DoubleValue.GetHashCode(); } if (oneofValueCase_ == OneofValueOneofCase.StringValue) { hash ^= StringValue.GetHashCode(); } if (ProtoDesc.Length != 0) { hash ^= ProtoDesc.GetHashCode(); } hash ^= (int)oneofValueCase_; return(hash); }
// Gets objects in a scene that match a certerin criteria public int Execute(HeroKitObject hko) { // Get variables heroKitObject = hko; // Get values HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1); bool useName = BoolValue.GetValue(heroKitObject, 2); string name = (useName) ? StringFieldValue.GetValueA(heroKitObject, 3) : ""; bool useTag = BoolValue.GetValue(heroKitObject, 4); string tag = (useTag) ? TagValue.GetValue(heroKitObject, 5) : ""; bool useLayer = BoolValue.GetValue(heroKitObject, 6); int layer = (useLayer) ? DropDownListValue.GetValue(heroKitObject, 7) - 1 : 0; GameObject[] targetGameObject = new GameObject[targetObject.Length]; bool runThis = (targetObject != null); // execute action for all objects in list for (int i = 0; runThis && i < targetObject.Length; i++) { targetGameObject[i] = ExecuteOnTarget(targetObject[i], useName, name, useTag, tag, useLayer, layer); } //----------------------------------------- // debugging stuff //----------------------------------------- if (heroKitObject.debugHeroObject) { string strLayer = (useLayer) ? layer.ToString() : ""; string strCount = (targetGameObject != null) ? targetGameObject.Length.ToString() : ""; string debugMessage = "Child With Tag: " + tag + "\n" + "Child On Layer: " + strLayer + "\n" + "Child With Name: " + name + "\n" + "Children Found: " + strCount; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
async Task <BoolValue <AuthResult> > acquireRenewedAccessTokenAsync(string refreshToken) { var body = makeRefreshTokenBody(refreshToken, Config.IsPkceUsed); var uri = Config.TokenIssuer; var request = (HttpWebRequest)WebRequest.Create(uri); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.Accept = "Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; var bodyData = Encoding.ASCII.GetBytes(body); request.ContentLength = bodyData.Length; var stream = request.GetRequestStream(); await stream.WriteAsync(bodyData, 0, bodyData.Length); stream.Close(); Log?.DebugWebRequest(request, body); try { var response = await request.GetResponseAsync(); var responseStream = response.GetResponseStream() ?? throw new Exception("Unexpected error: No response when requesting token."); using (var r = new StreamReader(responseStream)) { var text = await r.ReadToEndAsync(); Log.DebugWebResponse(response as HttpWebResponse, text); return(await buildAuthResultAsync(text)); } } catch (Exception ex) { LogDebug($"Failed request"); return(BoolValue <AuthResult> .Fail("Could not get a valid access token.", ex)); } }
public int NonConvertingCompare(BindingValue right) { if (ReferenceEquals(right, this)) { return(0); } bool thisIsEmpty = (ReferenceEquals(this, Empty)); if (ReferenceEquals(right, Empty)) { // empty is less than all values return(thisIsEmpty ? 0 : 1); } int typeDifference = _nativeValueType - right._nativeValueType; if (typeDifference != 0) { // different types sort by type return(typeDifference); } switch (_nativeValueType) { case BindingValueType.Boolean: return(BoolValue.CompareTo(right.BoolValue)); case BindingValueType.String: return(string.Compare(StringValue, right.StringValue, StringComparison.InvariantCulture)); case BindingValueType.Double: return(DoubleValue.CompareTo(right.DoubleValue)); default: throw new ArgumentOutOfRangeException(); } }
public string GetStringValue() { if (BoolValue != null) { return(BoolValue.ToString()); } if (IntValue.HasValue) { return(IntValue.ToString()); } if (DoubleValue.HasValue) { return(DoubleValue.ToString()); } if (!string.IsNullOrEmpty(StringValue)) { return(StringValue); } else { return("None"); } }
public string ToString(string indent) { switch (LVT) { case LuaValueType.LVT_Nil: return("nil"); case LuaValueType.LVT_String: return('\"' + StringValue + '\"'); case LuaValueType.LVT_Float: return(FloatValue.ToString()); case LuaValueType.LVT_Bool: return(BoolValue.ToString()); case LuaValueType.LVT_Table: return(TableValue.ToString(indent)); default: return(indent + "INVALID LUAVALUE"); } }
public override int GetHashCode() { int hash = 1; if (valueCase_ == ValueOneofCase.StringValue) { hash ^= StringValue.GetHashCode(); } if (valueCase_ == ValueOneofCase.BoolValue) { hash ^= BoolValue.GetHashCode(); } if (valueCase_ == ValueOneofCase.FloatValue) { hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(FloatValue); } hash ^= (int)valueCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
private void AfterDeserialization() { #region conversion of old NSM parameters if (Parameters.ContainsKey(SelectorParameterName)) { // change SelectorParameter type from ISelector to ISingleObjectiveSelector ValueParameter<ISelector> param = Parameters[SelectorParameterName] as ValueParameter<ISelector>; if (param != null) { ISingleObjectiveSelector selector = param.Value as ISingleObjectiveSelector; if (selector == null) selector = new TournamentSelector(); Parameters.Remove(SelectorParameterName); Parameters.Add(new ValueParameter<ISingleObjectiveSelector>(SelectorParameterName, "The inner selection operator to select the parents.", selector)); } } // FixedValueParameter for quality difference percentage, max attempts, use range if (Parameters.ContainsKey(QualityDifferencePercentageParameterName)) { ValueParameter<PercentValue> param = Parameters[QualityDifferencePercentageParameterName] as ValueParameter<PercentValue>; if (!(param is FixedValueParameter<PercentValue>)) { PercentValue diff = param != null ? param.Value as PercentValue : null; if (diff == null) diff = new PercentValue(0.05); Parameters.Remove(QualityDifferencePercentageParameterName); Parameters.Add(new FixedValueParameter<PercentValue>(QualityDifferencePercentageParameterName, "The minimum quality difference from parent1 to parent2 to accept the selection.", diff)); } } if (Parameters.ContainsKey(QualityDifferenceMaxAttemptsParameterName)) { ValueParameter<IntValue> param = Parameters[QualityDifferenceMaxAttemptsParameterName] as ValueParameter<IntValue>; if (!(param is FixedValueParameter<IntValue>)) { IntValue attempts = param != null ? param.Value as IntValue : null; if (attempts == null) attempts = new IntValue(5); Parameters.Remove(QualityDifferenceMaxAttemptsParameterName); Parameters.Add(new FixedValueParameter<IntValue>(QualityDifferenceMaxAttemptsParameterName, "The maximum number of attempts to find parents which differ in quality.", attempts)); } } if (Parameters.ContainsKey(QualityDifferenceUseRangeParameterName)) { ValueParameter<BoolValue> param = Parameters[QualityDifferenceUseRangeParameterName] as ValueParameter<BoolValue>; if (!(param is FixedValueParameter<BoolValue>)) { BoolValue range = param != null ? param.Value as BoolValue : null; if (range == null) range = new BoolValue(true); Parameters.Remove(QualityDifferenceUseRangeParameterName); Parameters.Add(new FixedValueParameter<BoolValue>(QualityDifferenceUseRangeParameterName, "Use the range from minimum to maximum quality as basis for QualityDifferencePercentage.", range)); } } if (!Parameters.ContainsKey(QualityDifferenceUseRangeParameterName)) // add use range parameter Parameters.Add(new FixedValueParameter<BoolValue>(QualityDifferenceUseRangeParameterName, "Use the range from minimum to maximum quality as basis for QualityDifferencePercentage.", new BoolValue(true))); #endregion RegisterParameterEventHandlers(); }
private void ShowVarGUI(List<GVar> vars, List<ActionParameter> parameters, ParameterType parameterType) { // Create a string List of the field's names (for the PopUp box) List<string> labelList = new List<string>(); int i = 0; if (parameterID == -1) { variableNumber = -1; } if (vars.Count > 0) { foreach (GVar _var in vars) { labelList.Add (_var.label); // If a GlobalVar variable has been removed, make sure selected variable is still valid if (_var.id == variableID) { variableNumber = i; } i ++; } if (variableNumber == -1 && (parameters == null || parameters.Count == 0 || parameterID == -1)) { // Wasn't found (variable was deleted?), so revert to zero Debug.LogWarning ("Previously chosen variable no longer exists!"); variableNumber = 0; variableID = 0; } parameterID = Action.ChooseParameterGUI ("Variable:", parameters, parameterID, parameterType); if (parameterID >= 0) { //variableNumber = 0; variableNumber = Mathf.Min (variableNumber, vars.Count-1); variableID = -1; } else { variableNumber = EditorGUILayout.Popup ("Variable:", variableNumber, labelList.ToArray()); variableID = vars [variableNumber].id; } string label = "Statement: "; if (vars [variableNumber].type == VariableType.Boolean) { setVarMethodIntBool = (SetVarMethodIntBool) EditorGUILayout.EnumPopup ("New value is:", setVarMethodIntBool); label += "="; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { setParameterID = Action.ChooseParameterGUI (label, parameters, setParameterID, ParameterType.Boolean); if (setParameterID < 0) { boolValue = (BoolValue) EditorGUILayout.EnumPopup (label, boolValue); } } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { ShowMecanimGUI (); } } if (vars [variableNumber].type == VariableType.PopUp) { label += "="; intValue = EditorGUILayout.Popup (label, intValue, vars[variableNumber].popUps); } else if (vars [variableNumber].type == VariableType.Integer) { setVarMethodIntBool = (SetVarMethodIntBool) EditorGUILayout.EnumPopup ("New value is:", setVarMethodIntBool); if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { setVarMethod = (SetVarMethod) EditorGUILayout.EnumPopup ("Method:", setVarMethod); if (setVarMethod == SetVarMethod.Formula) { label += "="; setParameterID = Action.ChooseParameterGUI (label, parameters, setParameterID, ParameterType.String); if (setParameterID < 0) { formula = EditorGUILayout.TextField (label, formula); } #if UNITY_WP8 EditorGUILayout.HelpBox ("This feature is not available for Windows Phone 8.", MessageType.Warning); #endif } else { if (setVarMethod == SetVarMethod.IncreaseByValue) { label += "+="; } else if (setVarMethod == SetVarMethod.SetValue) { label += "="; } else if (setVarMethod == SetVarMethod.SetAsRandom) { label += ("= 0 to"); } setParameterID = Action.ChooseParameterGUI (label, parameters, setParameterID, ParameterType.Integer); if (setParameterID < 0) { intValue = EditorGUILayout.IntField (label, intValue); if (setVarMethod == SetVarMethod.SetAsRandom && intValue < 0) { intValue = 0; } } } } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { ShowMecanimGUI (); } } else if (vars [variableNumber].type == VariableType.Float) { setVarMethodIntBool = (SetVarMethodIntBool) EditorGUILayout.EnumPopup ("New value is:", setVarMethodIntBool); if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { setVarMethod = (SetVarMethod) EditorGUILayout.EnumPopup ("Method:", setVarMethod); if (setVarMethod == SetVarMethod.Formula) { label += "="; setParameterID = Action.ChooseParameterGUI (label, parameters, setParameterID, ParameterType.String); if (setParameterID < 0) { formula = EditorGUILayout.TextField (label, formula); } #if UNITY_WP8 EditorGUILayout.HelpBox ("This feature is not available for Windows Phone 8.", MessageType.Warning); #endif } else { if (setVarMethod == SetVarMethod.IncreaseByValue) { label += "+="; } else if (setVarMethod == SetVarMethod.SetValue) { label += "="; } else if (setVarMethod == SetVarMethod.SetAsRandom) { label += "= 0 to"; } setParameterID = Action.ChooseParameterGUI (label, parameters, setParameterID, ParameterType.Float); if (setParameterID < 0) { floatValue = EditorGUILayout.FloatField (label, floatValue); if (setVarMethod == SetVarMethod.SetAsRandom && floatValue < 0f) { floatValue = 0f; } } } } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { ShowMecanimGUI (); } } else if (vars [variableNumber].type == VariableType.String) { setVarMethodString = (SetVarMethodString) EditorGUILayout.EnumPopup ("New value is:", setVarMethodString); label += "="; if (setVarMethodString == SetVarMethodString.EnteredHere) { setParameterID = Action.ChooseParameterGUI (label, parameters, setParameterID, ParameterType.String); if (setParameterID < 0) { stringValue = EditorGUILayout.TextField (label, stringValue); } } else if (setVarMethodString == SetVarMethodString.SetAsMenuElementText) { menuName = EditorGUILayout.TextField ("Menu name:", menuName); elementName = EditorGUILayout.TextField ("Element name:", elementName); slotNumberParameterID = Action.ChooseParameterGUI ("Slot # (optional):", parameters, slotNumberParameterID, ParameterType.Integer); if (slotNumberParameterID < 0) { slotNumber = EditorGUILayout.IntField ("Slot # (optional):", slotNumber); } } } AfterRunningOption (); } else { EditorGUILayout.HelpBox ("No variables exist!", MessageType.Info); variableID = -1; variableNumber = -1; } }
private string GetBoolLLVM(BoolValue value) { if (value == BoolValue.TRUE) { return "1"; } return "0"; }
public AstBoolValueExpression(BoolValue val) { Value = val; }
private void ShowVarGUI(List<ActionParameter> parameters, ActionParameter parameter) { if (parameters == null || parameters.Count == 0 || parameter == null) { EditorGUILayout.HelpBox ("No parameters exist! Please define one in the Inspector.", MessageType.Warning); parameterLabel = ""; return; } parameterLabel = parameter.label; EditorGUILayout.BeginHorizontal (); if (parameter.parameterType == ParameterType.Boolean) { boolCondition = (BoolCondition) EditorGUILayout.EnumPopup (boolCondition); boolValue = (BoolValue) EditorGUILayout.EnumPopup (boolValue); } else if (parameter.parameterType == ParameterType.Integer) { intCondition = (IntCondition) EditorGUILayout.EnumPopup (intCondition); intValue = EditorGUILayout.IntField (intValue); } else if (parameter.parameterType == ParameterType.Float) { intCondition = (IntCondition) EditorGUILayout.EnumPopup (intCondition); floatValue = EditorGUILayout.FloatField (floatValue); } else if (parameter.parameterType == ParameterType.String) { boolCondition = (BoolCondition) EditorGUILayout.EnumPopup (boolCondition); stringValue = EditorGUILayout.TextField (stringValue); } else if (parameter.parameterType == ParameterType.GameObject) { compareObject = (GameObject) EditorGUILayout.ObjectField ("Is equal to:", compareObject, typeof (GameObject), true); compareObjectConstantID = FieldToID (compareObject, compareObjectConstantID); compareObject = IDToField (compareObject, compareObjectConstantID, false); } else if (parameter.parameterType == ParameterType.GlobalVariable) { if (AdvGame.GetReferences ().variablesManager == null || AdvGame.GetReferences ().variablesManager.vars == null || AdvGame.GetReferences ().variablesManager.vars.Count == 0) { EditorGUILayout.HelpBox ("No Global variables exist!", MessageType.Info); } else { compareVariableID = ShowVarSelectorGUI (AdvGame.GetReferences ().variablesManager.vars, compareVariableID); } } else if (parameter.parameterType == ParameterType.InventoryItem) { ShowInvSelectorGUI (compareVariableID); } else if (parameter.parameterType == ParameterType.LocalVariable) { if (isAssetFile) { EditorGUILayout.HelpBox ("Cannot compare local variables in an asset file.", MessageType.Warning); } else if (KickStarter.localVariables == null || KickStarter.localVariables.localVars == null || KickStarter.localVariables.localVars.Count == 0) { EditorGUILayout.HelpBox ("No Local variables exist!", MessageType.Info); } else { compareVariableID = ShowVarSelectorGUI (KickStarter.localVariables.localVars, compareVariableID); } } EditorGUILayout.EndHorizontal (); }
private void AddSemanticallyDifferentFromRootedParentTableEntry(BoolValue[] semanticallyDifferentFromRootedParent) { if (SemanticallyDifferentFromRootedParentDataTable == null) { var table = new DataTable(SemanticallyDifferentFromRootedParentParameterName, ""); table.VisualProperties.YAxisTitle = "Percentage"; table.VisualProperties.YAxisMaximumFixedValue = 100.0; table.VisualProperties.YAxisMaximumAuto = false; DataRow differentRow = new DataRow("Different From Parent"); differentRow.VisualProperties.StartIndexZero = true; table.Rows.Add(differentRow); DataRow sameRow = new DataRow("Same As Parent"); sameRow.VisualProperties.StartIndexZero = true; table.Rows.Add(sameRow); SemanticallyDifferentFromRootedParentDataTable = table; } double different = semanticallyDifferentFromRootedParent.Count(x => x.Value); SemanticallyDifferentFromRootedParentDataTable.Rows["Different From Parent"].Values.Add(different / semanticallyDifferentFromRootedParent.Length * 100.0); SemanticallyDifferentFromRootedParentDataTable.Rows["Same As Parent"].Values.Add((semanticallyDifferentFromRootedParent.Length - different) / semanticallyDifferentFromRootedParent.Length * 100.0); }
private int ShowVarGUI (List<ActionParameter> parameters, List<GVar> vars, int ID, bool changeID) { if (vars.Count > 0) { if (changeID) { ID = ShowVarSelectorGUI (vars, ID); } variableNumber = Mathf.Min (variableNumber, vars.Count-1); getVarMethod = (GetVarMethod) EditorGUILayout.EnumPopup ("Compare with:", getVarMethod); if (parameters == null || parameters.Count == 0) { EditorGUILayout.BeginHorizontal (); } if (vars [variableNumber].type == VariableType.Boolean) { boolCondition = (BoolCondition) EditorGUILayout.EnumPopup (boolCondition); if (getVarMethod == GetVarMethod.EnteredValue) { checkParameterID = Action.ChooseParameterGUI ("Boolean:", parameters, checkParameterID, ParameterType.Boolean); if (checkParameterID < 0) { boolValue = (BoolValue) EditorGUILayout.EnumPopup ("Boolean:", boolValue); } } } else if (vars [variableNumber].type == VariableType.Integer) { intCondition = (IntCondition) EditorGUILayout.EnumPopup (intCondition); if (getVarMethod == GetVarMethod.EnteredValue) { checkParameterID = Action.ChooseParameterGUI ("Integer:", parameters, checkParameterID, ParameterType.Integer); if (checkParameterID < 0) { intValue = EditorGUILayout.IntField ("Integer:", intValue); } } } else if (vars [variableNumber].type == VariableType.PopUp) { intCondition = (IntCondition) EditorGUILayout.EnumPopup (intCondition); if (getVarMethod == GetVarMethod.EnteredValue) { checkParameterID = Action.ChooseParameterGUI ("Value:", parameters, checkParameterID, ParameterType.Integer); if (checkParameterID < 0) { intValue = EditorGUILayout.Popup ("Value:", intValue, vars [variableNumber].popUps); } } } else if (vars [variableNumber].type == VariableType.Float) { intCondition = (IntCondition) EditorGUILayout.EnumPopup (intCondition); if (getVarMethod == GetVarMethod.EnteredValue) { checkParameterID = Action.ChooseParameterGUI ("Float:", parameters, checkParameterID, ParameterType.Float); if (checkParameterID < 0) { floatValue = EditorGUILayout.FloatField ("Float:", floatValue); } } } else if (vars [variableNumber].type == VariableType.String) { boolCondition = (BoolCondition) EditorGUILayout.EnumPopup (boolCondition); if (getVarMethod == GetVarMethod.EnteredValue) { checkParameterID = Action.ChooseParameterGUI ("String:", parameters, checkParameterID, ParameterType.String); if (checkParameterID < 0) { stringValue = EditorGUILayout.TextField ("String:", stringValue); } } } if (getVarMethod == GetVarMethod.GlobalVariable) { if (!variablesManager) { variablesManager = AdvGame.GetReferences ().variablesManager; } if (variablesManager == null || variablesManager.vars == null || variablesManager.vars.Count == 0) { EditorGUILayout.HelpBox ("No Global variables exist!", MessageType.Info); } else { checkParameterID = Action.ChooseParameterGUI ("Global variable:", parameters, checkParameterID, ParameterType.GlobalVariable); if (checkParameterID < 0) { compareVariableID = ShowVarSelectorGUI (variablesManager.vars, compareVariableID); } } } else if (getVarMethod == GetVarMethod.LocalVariable) { if (!localVariables && GameObject.FindWithTag (Tags.gameEngine) && GameObject.FindWithTag (Tags.gameEngine).GetComponent<LocalVariables>()) { localVariables = GameObject.FindWithTag (Tags.gameEngine).GetComponent <LocalVariables>(); } if (localVariables == null || localVariables.localVars == null || localVariables.localVars.Count == 0) { EditorGUILayout.HelpBox ("No Local variables exist!", MessageType.Info); } else { checkParameterID = Action.ChooseParameterGUI ("Local variable:", parameters, checkParameterID, ParameterType.LocalVariable); if (checkParameterID < 0) { compareVariableID = ShowVarSelectorGUI (localVariables.localVars, compareVariableID); } } } if (parameters == null || parameters.Count == 0) { EditorGUILayout.EndHorizontal (); } } else { EditorGUILayout.HelpBox ("No variables exist!", MessageType.Info); ID = -1; variableNumber = -1; } return ID; }