public PathmapClassConstructor(PathmapClass pathMapClass) : base(pathMapClass, null, AccessLevel.Public) { Parameters = new CodeParameter[] { new PathmapFileParameter("pathmapFile", "File path of the pathmap to use. Must be a `.pathmap` file.") }; Documentation = "Creates a pathmap from a `.pathmap` file."; }
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 Element Get(ResolveInfoComponent resolveInfo, ActionSet actionSet, Element target) { ActionSet = actionSet; ResolveInfo = resolveInfo; Target = target; PathmapInstance = actionSet.Translate.DeltinScript.Types.GetInstance <PathmapClass>(); // Lookahead status IndexReference result = actionSet.VarCollection.Assign("Lookahead: Result", actionSet.IsGlobal, true); actionSet.AddAction(result.SetVariable(new V_False())); // The lookhead controller Look = actionSet.VarCollection.Assign("Pathfind: Lookahead", actionSet.IsGlobal, true); actionSet.AddAction(Look.SetVariable(resolveInfo.Current.Get(target))); // The loop actionSet.AddAction(Element.Part <A_While>(Element.Part <V_And>( !result.Get(), LoopCondition() ))); // Set the result. actionSet.AddAction(result.SetVariable(SetResult())); // End actionSet.AddAction(Look.SetVariable(Next)); actionSet.AddAction(new A_End()); return(result.Get()); }
} // The function used to get the closest node to the player. public void Init() { 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); } // Get the PathResolve instance and the Pathmap instance. PathResolveInstance = DeltinScript.Types.GetInstance <PathResolveClass>(); PathmapInstance = DeltinScript.Types.GetInstance <PathmapClass>(); // Get the resolve subroutine. GetResolveRoutine(); }
public NodeFromInvocable(ActionSet actionSet, PathmapClass pathmapClass, Element pathmapObject, ILambdaInvocable invocable) { _actionSet = actionSet; _pathmapClass = pathmapClass; _pathmapObject = pathmapObject; _invocable = invocable; }
public Element Get(ResolveInfoComponent resolveInfo, ActionSet actionSet, Element target) { ActionSet = actionSet; ResolveInfo = resolveInfo; Target = target; PathmapInstance = actionSet.DeltinScript.GetComponent <PathfinderTypesComponent>().Pathmap; // Lookahead status IndexReference result = actionSet.VarCollection.Assign("Lookahead: Result", actionSet.IsGlobal, true); actionSet.AddAction(result.SetVariable(Element.False())); // The lookhead controller Look = actionSet.VarCollection.Assign("Pathfind: Lookahead", actionSet.IsGlobal, true); actionSet.AddAction(Look.SetVariable(resolveInfo.Current.Get(target))); // The loop actionSet.AddAction(Element.While(Element.And( !result.Get(), LoopCondition() ))); // Set the result. actionSet.AddAction(result.SetVariable(SetResult())); // End actionSet.AddAction(Look.SetVariable(Next)); actionSet.AddAction(Element.End()); return(result.Get()); }
public void Init(DeltinScript deltinScript) { Pathmap = new PathmapClass(deltinScript); PathResolve = new PathResolveClass(deltinScript); Bakemap = new BakemapClass(deltinScript); deltinScript.Types.AddType(Pathmap.Provider); deltinScript.Types.AddType(PathResolve.Provider); deltinScript.Types.AddType(Bakemap.Provider); }
public PathmapBake(ActionSet actionSet, Element pathmapObject, Element attributes, ILambdaInvocable onLoop) { ActionSet = actionSet; var pathfinderClasses = actionSet.DeltinScript.GetComponent <PathfinderTypesComponent>(); _pathmapClass = pathfinderClasses.Pathmap; _bakemapClass = pathfinderClasses.Bakemap; _pathmapObject = pathmapObject; EnabledAttributes = attributes; _onLoop = onLoop; }
public DijkstraBase(ActionSet actionSet, Element pathmapObject, Element position, bool reversed) { this.actionSet = actionSet; this.pathmapObject = pathmapObject; this.position = position; this.reversed = reversed; PathmapClass pathmapClass = actionSet.Translate.DeltinScript.GetCodeType <PathmapClass>(); Nodes = ((Element)pathmapClass.Nodes.GetVariable())[pathmapObject]; Segments = ((Element)pathmapClass.Segments.GetVariable())[pathmapObject]; }
public PathmapPathfinderInfo(Element position, SharedPathfinderInfoValues pathfinderValues) { ActionSet = pathfinderValues.ActionSet; InitialNode = pathfinderValues.NodeFromPosition.NodeFromPosition(position); EnabledAttributes = pathfinderValues.Attributes; _onLoop = pathfinderValues.OnLoop; _onConnectLoop = pathfinderValues.OnConnectLoop; _pathmapClass = ActionSet.DeltinScript.GetComponent <PathfinderTypesComponent>().Pathmap; _nodeFromPosition = pathfinderValues.NodeFromPosition; OriginalPosition = position; PathmapObject = pathfinderValues.PathmapObject; ResolveInfo = ActionSet.DeltinScript.GetComponent <ResolveInfoComponent>(); }
public DijkstraBase(ActionSet actionSet, Element pathmapObject, Element position, Element attributes) { this.actionSet = actionSet; this.pathmapObject = pathmapObject; this.Source = position; this.attributes = attributes; this.useAttributes = attributes != null; // Set closest node determiner. GetClosestNode = (actionSet, nodes, position) => ClosestNodeToPosition(nodes, position, resolveInfo.PotentiallyNullNodes); // Get the pathmap class instance. PathmapClass pathmapClass = actionSet.Translate.DeltinScript.Types.GetCodeType <PathmapClass>(); // Set nodes and segments. Nodes = pathmapClass.Nodes.Get()[pathmapObject]; Segments = pathmapClass.Segments.Get()[pathmapObject]; // Get the resolve info component. resolveInfo = actionSet.Translate.DeltinScript.GetComponent <ResolveInfoComponent>(); }
public ClosestNodeFromPosition(ActionSet actionSet, PathmapClass pathmapClass, Element pathmapObject) { _actionSet = actionSet; _pathmapClass = pathmapClass; _pathmapObject = pathmapObject; }