示例#1
0
        override protected MethodResult Get()
        {
            if (((VarRef)Parameters[0]).Var is ModelVar == false)
            {
                throw SyntaxErrorException.InvalidVarRefType(((VarRef)Parameters[0]).Var.Name, VarType.Model, ParameterLocations[0]);
            }

            //throw new SyntaxErrorException("Variable must reference a model.", ParameterLocations[0]);

            ModelVar   modelVar  = (ModelVar)((VarRef)Parameters[0]).Var;
            Element    visibleTo = (Element)Parameters[1];
            Element    location  = (Element)Parameters[2];
            Element    scale     = (Element)Parameters[3];
            EnumMember effectRev = (EnumMember)Parameters[4];
            bool       getIds    = (bool)((ConstantObject)Parameters[5]).Value;

            List <Element> actions = new List <Element>();

            IndexedVar effects = null;

            if (getIds)
            {
                effects = TranslateContext.VarCollection.AssignVar(Scope, "Model Effects", TranslateContext.IsGlobal, null);
                actions.AddRange(effects.SetVariable(new V_EmptyArray()));
            }

            actions.AddRange(RenderModel(modelVar.Model, visibleTo, location, scale, effectRev, effects));

            return(new MethodResult(actions.ToArray(), effects?.GetVariable()));
        }
        protected override MethodResult Get()
        {
            if (((VarRef)Parameters[0]).Var is PathMapVar == false)
            {
                throw SyntaxErrorException.InvalidVarRefType(((VarRef)Parameters[0]).Var.Name, VarType.PathMap, ParameterLocations[0]);
            }

            PathMapVar pathmap     = (PathMapVar)((VarRef)Parameters[0]).Var;
            Element    position    = (Element)Parameters[1];
            Element    destination = (Element)Parameters[2];

            DijkstraNormal algorithm = new DijkstraNormal(TranslateContext, pathmap, position, destination);

            algorithm.Get();
            return(new MethodResult(
                       null,
                       Element.Part <V_Append>(algorithm.finalPath.GetVariable(), destination)
                       ));
        }
        override protected MethodResult Get(PathfinderInfo info)
        {
            if (((VarRef)Parameters[1]).Var is PathMapVar == false)
            {
                throw SyntaxErrorException.InvalidVarRefType(((VarRef)Parameters[1]).Var.Name, VarType.PathMap, ParameterLocations[1]);
            }

            Element    player  = (Element)Parameters[0];
            PathMapVar pathmap = (PathMapVar)((VarRef)Parameters[1]).Var;

            IndexedVar destination = IndexedVar.AssignInternalVarExt(TranslateContext.VarCollection, Scope, "Destination", TranslateContext.IsGlobal);

            TranslateContext.Actions.AddRange(destination.SetVariable((Element)Parameters[2]));

            DijkstraNormal algorithm = new DijkstraNormal(TranslateContext, pathmap, Element.Part <V_PositionOf>(player), destination.GetVariable());

            algorithm.Get();
            DijkstraBase.Pathfind(TranslateContext, info, algorithm.finalPath.GetVariable(), player, destination.GetVariable());
            return(new MethodResult(null, null));
        }
        protected override MethodResult Get()
        {
            VarRef targetVariable = (VarRef)Parameters[0];

            if (targetVariable.Var is IndexedVar == false)
            {
                throw SyntaxErrorException.InvalidVarRefType(targetVariable.Var.Name, VarType.Indexed, ParameterLocations[0]);
            }

            IndexedVar var = (IndexedVar)targetVariable.Var;

            VariableChaseData chaseData = GetChaseData(var, TranslateContext);

            Element[] actions = ArrayBuilder <Element> .Build
                                (
                chaseData.Rate.SetVariable(new V_Number(0), targetVariable.Target)
                                );

            return(new MethodResult(actions, null));
        }
        protected override MethodResult Get(PathfinderInfo info)
        {
            if (((VarRef)Parameters[1]).Var is PathMapVar == false)
            {
                throw SyntaxErrorException.InvalidVarRefType(((VarRef)Parameters[1]).Var.Name, VarType.PathMap, ParameterLocations[1]);
            }

            IndexedVar players = IndexedVar.AssignInternalVarExt(TranslateContext.VarCollection, Scope, "Players", TranslateContext.IsGlobal);

            TranslateContext.Actions.AddRange(players.SetVariable((Element)Parameters[0]));

            PathMapVar pathmap = (PathMapVar)((VarRef)Parameters[1]).Var;

            IndexedVar destination = IndexedVar.AssignInternalVarExt(TranslateContext.VarCollection, Scope, "Destination", TranslateContext.IsGlobal);

            TranslateContext.Actions.AddRange(destination.SetVariable((Element)Parameters[2]));

            DijkstraMultiSource algorithm = new DijkstraMultiSource(TranslateContext, info, pathmap, players.GetVariable(), destination.GetVariable());

            algorithm.Get();
            return(new MethodResult(null, null));
        }