public void Init(DeltinScript deltinScript) { DeltinScript = deltinScript; _toWorkshop = deltinScript.WorkshopConverter; bool assignExtended = false; // Assign workshop variables. DoGetCurrent = DeltinScript.VarCollection.Assign("pathfinderDoGetCurrent", false, assignExtended); Current = DeltinScript.VarCollection.Assign("pathfinderCurrent", false, assignExtended); PathmapReference = DeltinScript.VarCollection.Assign("pathmapReference", false, assignExtended); ParentArray = DeltinScript.VarCollection.Assign("parentArray", false, assignExtended); Destination = DeltinScript.VarCollection.Assign("destination", false, assignExtended); CurrentAttribute = DeltinScript.VarCollection.Assign("lastAttribute", false, assignExtended); if (TrackTimeSinceLastNode) { DistanceToNextNode = DeltinScript.VarCollection.Assign("distanceToNextNode", false, assignExtended); TimeSinceLastNode = DeltinScript.VarCollection.Assign("timeSinceLastNode", false, assignExtended); } var pathfinderTypes = DeltinScript.GetComponent <PathfinderTypesComponent>(); if (TrackNextAttribute) { NextAttribute = DeltinScript.VarCollection.Assign("nextAttribute", false, assignExtended); } // Get the PathResolve instance and the Pathmap instance. PathmapInstance = pathfinderTypes.Pathmap; // Get the resolve subroutine. GetResolveCurrentRule(); GetNextNodeRule(); }
public override void AddObjectVariablesToAssigner(ToWorkshop toWorkshop, IWorkshopTree reference, VarIndexAssigner assigner) { assigner.Add(Opposite, Element.Part("Opposite Team Of", reference)); assigner.Add(Score, Element.Part("Team Score", reference)); assigner.Add(OnDefense, Element.Part("Is Team On Defense", reference)); assigner.Add(OnOffense, Element.Part("Is Team On Offense", reference)); }
public override void AddObjectVariablesToAssigner(ToWorkshop toWorkshop, IWorkshopTree reference, VarIndexAssigner assigner) { foreach (CodeType included in IncludedTypes) { included.AddObjectVariablesToAssigner(toWorkshop, reference, assigner); } }
public LambdaBuilder(ToWorkshop toWorkshop) { _toWorkshop = toWorkshop; _parameterRecycler = new RecycleWorkshopVariableAssigner(toWorkshop.VarCollection, "lambdaParameter"); _returnRecycler = new RecycleWorkshopVariableAssigner(toWorkshop.VarCollection, "lambdaValue"); _parameterHandler = new LambdaParameterHandler(_parameterRecycler); }
public override void AddObjectVariablesToAssigner(ToWorkshop toWorkshop, IWorkshopTree reference, VarIndexAssigner assigner) { var functionHandler = ArrayOfType.ArrayHandler.GetFunctionHandler(); assigner.Add(_length, functionHandler.Length(reference)); assigner.Add(_first, functionHandler.FirstOf(reference)); assigner.Add(_last, functionHandler.LastOf(reference)); }
} // The object variables. public ClassWorkshopInitializerComponent(ToWorkshop toWorkshop) { _toWorkshop = toWorkshop; // Init classes then assign stacks. InitClasses(); AssignStacks(); }
public override void AddObjectVariablesToAssigner(ToWorkshop toWorkshop, IWorkshopTree reference, VarIndexAssigner assigner) { assigner.Add(X, Element.XOf(reference)); assigner.Add(Y, Element.YOf(reference)); assigner.Add(Z, Element.ZOf(reference)); assigner.Add(Magnitude, Element.MagnitudeOf(reference)); assigner.Add(HorizontalAngle, Element.Part("Horizontal Angle From Direction", reference)); assigner.Add(VerticalAngle, Element.Part("Vertical Angle From Direction", reference)); }
// Extracts the Gettable from an object reference. IGettable GetGettable(ToWorkshop toWorkshop, IWorkshopTree reference) { // Get the gettable from the combo related to _classType. var gettables = toWorkshop.ClassInitializer .ComboFromClassType(_classType) .GetVariableGettables(_classType.Variables, reference); int index = Array.IndexOf(_classType.Variables, Variable); return(gettables[index]); }
public override void AddObjectVariablesToAssigner(ToWorkshop toWorkshop, IWorkshopTree reference, VarIndexAssigner assigner) { foreach (var p in Properties) { if (p.Value.Value != null) { assigner.Add(p.Var, p.Value.Value); } else { assigner.Add(p.Var, Element.Null()); } } }
public MethodClassRelations(ToWorkshop toWorkshop, DefinedMethodInstance method) { Method = method; if (method.DefinedInType is ClassType classType) { // Get the class relation. ClassRelation = toWorkshop.ClassInitializer.RelationFromClassType(classType); // Extract the virtual functions. Overriders = ClassRelation.ExtractOverridenElements <DefinedMethodInstance>(extender => DoesOverride(method, extender)) .ToArray(); } else { Overriders = new DefinedMethodInstance[0]; } }
public UserFunctionController(ToWorkshop toWorkshop, DefinedMethodInstance function, InstanceAnonymousTypeLinker typeArgs) { _toWorkshop = toWorkshop; _function = function; _typeArgLinker = typeArgs; _allVirtualOptions.Add(function); Attributes.IsRecursive = function.Attributes.Recursive; // If the function is defined in a type. if (function.DefinedInType != null) { Attributes.IsInstance = true; var relations = new MethodClassRelations(toWorkshop, function); // Get the class relation. _classRelation = relations.ClassRelation; // Extract the virtual functions. _allVirtualOptions.AddRange(relations.Overriders); } }
public UserConstructorController(DefinedConstructorInstance instance, ToWorkshop toWorkshop) { _instance = instance; _toWorkshop = toWorkshop; }
/// <summary>Adds the ObjectVariable to a variable assigner.</summary> public void AddToAssigner(VarIndexAssigner assigner, ToWorkshop toWorkshop, IWorkshopTree reference) => assigner.Add(Variable.Provider, GetGettable(toWorkshop, reference));
/// <summary>Gets the value from an object reference.</summary> public Element Get(ToWorkshop toWorkshop, IWorkshopTree reference) => (Element)GetGettable(toWorkshop, reference).GetVariable();
public override void AddObjectVariablesToAssigner(ToWorkshop toWorkshop, IWorkshopTree reference, VarIndexAssigner assigner) { assigner.Add(_length, Element.Part("String Length", reference)); }
/// <summary>Adds the class objects to the index assigner.</summary> /// <param name="source">The source of the type.</param> /// <param name="assigner">The assigner that the object variables will be added to.</param> public virtual void AddObjectVariablesToAssigner(ToWorkshop toWorkshop, IWorkshopTree reference, VarIndexAssigner assigner) { }
void ToWorkshop(Func <VarCollection, Rule[]> addRules) { // Set up the variable collection. VarCollection.Setup(); WorkshopConverter = new ToWorkshop(this); // Set up initial global and player rules. InitialGlobal = new TranslateRule(this, "Initial Global", RuleEvent.OngoingGlobal); InitialPlayer = new TranslateRule(this, "Initial Player", RuleEvent.OngoingPlayer); WorkshopRules = new List <Rule>(); WorkshopConverter.InitStatic(); // Init called types. foreach (var workshopInit in _workshopInit) { workshopInit.WorkshopInit(this); } // Assign variables at the rule-set level. foreach (var variable in rulesetVariables) { var addToInitialRule = GetInitialRule(variable.VariableType == VariableType.Global); // Assign the variable an index. IGettable value = variable .GetDefaultInstance(null) .GetAssigner(new(addToInitialRule.ActionSet)) .GetValue(new GettableAssignerValueInfo(addToInitialRule.ActionSet) { SetInitialValue = SetInitialValue.SetIfExists }); DefaultIndexAssigner.Add(variable, value); if (value is IndexReference indexReference) { DebugVariables.Add(variable, indexReference); } } // Parse the rules. foreach (var rule in rules) { var translate = new TranslateRule(this, rule); Rule newRule = GetRule(translate.GetRule()); WorkshopRules.Add(newRule); rule.ElementCountLens.RuleParsed(newRule); } // Add built-in rules. // Initial player if (InitialPlayer.Actions.Count > 0) { WorkshopRules.Insert(0, GetRule(InitialPlayer.GetRule())); } // Initial global if (InitialGlobal.Actions.Count > 0) { WorkshopRules.Insert(0, GetRule(InitialGlobal.GetRule())); } // Additional if (addRules != null) { WorkshopRules.AddRange(addRules.Invoke(VarCollection).Where(rule => rule != null)); } // Complete portable functions WorkshopConverter.LambdaBuilder.Complete(); // Order the workshop rules by priority. WorkshopRules = WorkshopRules.OrderBy(wr => wr.Priority).ToList(); // Get the final workshop string. WorkshopBuilder result = new WorkshopBuilder(Language); LanguageInfo.I18nWarningMessage(result, Language); // Get the custom game settings. if (Importer.MergedLobbySettings != null) { Ruleset settings = Ruleset.Parse(Importer.MergedLobbySettings); settings.ToWorkshop(result); result.AppendLine(); } // Get the variables. VarCollection.ToWorkshop(result); result.AppendLine(); // Get the subroutines. SubroutineCollection.ToWorkshop(result); // Get the rules. for (int i = 0; i < WorkshopRules.Count; i++) { WorkshopRules[i].ToWorkshop(result); ElementCount += WorkshopRules[i].ElementCount(); if (i != WorkshopRules.Count - 1) { result.AppendLine(); } } WorkshopCode = result.GetResult(); }