Ejemplo n.º 1
0
 public void ExecuteSubroutine(ActionSet actionSet, Subroutine subroutine) => Builder.ExecuteSubroutine.Execute(actionSet, subroutine);
 public ClosestNodeFromPosition(ActionSet actionSet, PathmapClass pathmapClass, Element pathmapObject)
 {
     _actionSet     = actionSet;
     _pathmapClass  = pathmapClass;
     _pathmapObject = pathmapObject;
 }
 public IWorkshopTree Parse(ActionSet actionSet) => _macroVar.Expression.Parse(actionSet);
 public virtual void AssignParameters()
 {
     ActionSet = ActionSet.PackThis();
 }
Ejemplo n.º 5
0
 public IWorkshopTree Invoke(ActionSet actionSet, params IWorkshopTree[] parameterValues) => _method.Parse(actionSet, new MethodCall(parameterValues));
 public MacroBuilder(ActionSet actionSet, DefinedMacro macro, MethodCall call) : base(actionSet)
 {
     _macro = macro;
     _call  = call;
 }
Ejemplo n.º 7
0
 public IWorkshopTree Invoke(ActionSet actionSet, params IWorkshopTree[] parameterValues)
 => Action.Invoke(Assigner, actionSet, parameterValues);
Ejemplo n.º 8
0
        public void Update(GameTime gameTime, ActionSet actionSet)
        {
            delta = (float)gameTime.ElapsedGameTime.TotalSeconds;
            character.currentAnimRestartCounter -= (float)gameTime.ElapsedGameTime.TotalMilliseconds;

            if (IsFacingRight())
            {
                TrapPlacementPos = new Vector2(BoundingBox.X + (BoundingBox.Width / 2) + 10, BoundingBox.Y + BoundingBox.Height + 20);
            }
            else
            {
                TrapPlacementPos = new Vector2(BoundingBox.X + (BoundingBox.Width / 2) - 65, BoundingBox.Y + BoundingBox.Height + 20);
            }

            if ((!IsStunned && !IsLayingTrap) || (IsInAir && !IsClimbing))
            {
                CheckForCollisions();

                UpdatePlayerPosition(actionSet);
            }
            else
            {
                stunTimeCounter += delta;

                //Make player drop treasure if he carries one
                if (!IsLayingTrap && character.InvTreasure != null)
                {
                    if (IsClimbing)
                    {
                        character.LooseTreasure(new Vector2(position.X, climbableYMax));
                    }
                    else
                    {
                        character.LooseTreasure(new Vector2(position.X, BoundingBox.Bottom));
                    }
                }

                if (stunTimeCounter > CurrentStunTime)
                {
                    IsStunned       = false;
                    IsLayingTrap    = false;
                    stunTimeCounter = 0f;
                }

                /*if (playerIndex > -1 && !IsLayingTrap)
                 * {
                 *  if (stunTimeCounter > 0 && stunTimeCounter < CurrentStunTime/3)
                 *      GamePad.SetVibration(playerIndex, 1.0f, 1.0f);
                 *  else
                 *      GamePad.SetVibration(playerIndex, 0.0f, 0.0f);
                 * }*/

                if (facingRight)
                {
                    ((Spritesheet)character.getRepresentation()).PlayAnimation("stunned");
                }
                else
                {
                    ((Spritesheet)character.getRepresentation()).PlayAnimation("stunned", 1F, true);
                }
            }

            UpdateBullets(gameTime);

            if (scene.CurrWeatherSystem.IsRaining || contactFoliage)
            {
                FootstepEffectManager.Paused = true;
            }
        }
Ejemplo n.º 9
0
 public virtual void Update(GameTime gameTime, ActionSet actions)
 {
     base.Update(gameTime);
 }
Ejemplo n.º 10
0
 public LambdaActionWorkshopInstance(ActionSet actionSet, LambdaAction action)
 {
     Assigner = actionSet.IndexAssigner;
     Action   = action;
 }
Ejemplo n.º 11
0
        public override PlanningResult GetPlan(DomainState startState, DomainState goalState, ActionSet actions)
        {
            Plan GetOptions(IPlanNode node) => RegressivePlanner.GetOptions(node, actions, startState);

            var start = new PlanNode(goalState, null, null, 0);

            var(path, graph) = FindPlan(start, startState.IsSuperstateOf, GetOptions);

            return(new PlanningResult
            {
                Plan = GetActions(path),
                SearchTree = graph
            });
        }
Ejemplo n.º 12
0
 public IWorkshopTree Parse(ActionSet actionSet, IWorkshopTree[] parameters) => new StringElement(String, true, ParameterValues.Select(pv => (Element)pv.Parse(actionSet, parameters)).ToArray());
Ejemplo n.º 13
0
 /// <summary>
 /// Non-blocking method of getting the web resource stream. Only use immediate IActions.
 /// </summary>
 public void GetStream(IAction <Stream, Lock> onStream)
 {
     _lock.TryLock(ActionSet.New(OnGetStream, onStream), null, false);
 }
Ejemplo n.º 14
0
 public abstract IWorkshopTree Parse(ActionSet actionSet, MethodCall methodCall);
Ejemplo n.º 15
0
 public MethodContentBuilder(ActionSet actionSet, IEnumerable <IVirtualMethodHandler> functions) : base(actionSet, functions)
 {
 }
Ejemplo n.º 16
0
        /// <summary>
        /// On socket data being received.
        /// </summary>
        private unsafe void OnReceiveSocketData(IAsyncResult ar)
        {
            int count = 0;

            try {
                // end the receive
                count = Socket.EndReceiveFrom(ar, ref _receiveEndPoint);
            } catch (Exception ex) {
                // release the read lock
                _syncLock.ReleaseRead();

                ProcessError(ex);
                return;
            }

            if (count > 0)
            {
                // is the received buffer chunked?
                byte flag = _receiveBuffer[0];
                if (flag < 60 || flag >= 188)
                {
                    count -= ChunkHeaderSize;

                    int chunkId;
                    int chunkIndex;
                    int chunkCount;

                    // sanity check for correct number of bytes received
                    if (count < 0)
                    {
                        _syncLock.ReleaseRead();
                        ProcessError("Socket didn't receive enough data for chunked information.");
                        return;
                    }

                    // yes, read the chunk details
                    fixed(byte *intP = &_receiveBuffer[1])
                    {
                        chunkId = *(int *)intP;
                    }

                    fixed(byte *intP = &_receiveBuffer[5])
                    {
                        chunkIndex = *(int *)intP;
                    }

                    fixed(byte *intP = &_receiveBuffer[9])
                    {
                        chunkCount = *(int *)intP;
                    }

                    // sanity check for the chunk data being valid
                    if (chunkIndex >= chunkCount)
                    {
                        _syncLock.ReleaseRead();
                        ProcessError("Socket received invalid chunk index and count information.");
                        return;
                    }

                    // write
                    ChunkedGram chunkedGram;
                    if (_receivedChunks.TryGetValue(chunkId, out chunkedGram))
                    {
                        chunkedGram.Length += count;
                        chunkedGram.Chunks.Insert(Teple.New(count, _receiveBuffer), chunkIndex);

                        // have all chunks been added?
                        if (chunkedGram.Chunks.Count == chunkCount)
                        {
                            // yes, remove from the collection
                            _receivedChunks.Remove(chunkId);

                            // create a byte buffer for the entire message
                            byte[] result = new byte[chunkedGram.Length];
                            int    index  = 0;
                            foreach (var chunk in chunkedGram.Chunks)
                            {
                                int length = chunk.ArgA;
                                Micron.CopyMemory(chunk.ArgB, ChunkHeaderSize, result, index, length);
                                index += length;
                            }

                            // reference the endpoint from which the data was received
                            IPEndPoint endpoint = (IPEndPoint)_receiveEndPoint;

                            // run the callback
                            _onReceive.AddRun(ActionSet.New(OnReceive,
                                                            endpoint,
                                                            result,
                                                            chunkedGram.Length));
                        }
                        else
                        {
                            // no, create a new receive buffer
                            _receiveBuffer = BufferCache.Get();
                        }
                    }
                    else
                    {
                        chunkedGram = new ChunkedGram {
                            Chunks    = new ArrayRig <Teple <int, byte[]> >(chunkCount),
                            Timestamp = Time.Timestamp
                        };

                        _receivedChunks.Add(chunkId, chunkedGram);

                        chunkedGram.Chunks.Add(Teple.New(count, _receiveBuffer));
                        chunkedGram.Length += count;

                        // create a new receive buffer
                        _receiveBuffer = BufferCache.Get();
                    }
                }
                else
                {
                    // no, copy the received buffer
                    --count;
                    byte[] buffer = BufferCache.Get(count);
                    Micron.CopyMemory(_receiveBuffer, 1, buffer, 0, count);

                    // reference the endpoint from which the data was received
                    IPEndPoint endpoint = (IPEndPoint)_receiveEndPoint;

                    // run the callback
                    _onReceive.AddRun(ActionSet.New(OnReceive,
                                                    endpoint,
                                                    buffer,
                                                    count));
                }
            }

            if (_receivedChunks.Count > 0)
            {
                // check for any chunked data timeouts
                ArrayRig <int> toRemove = null;
                foreach (var chunkedGram in _receivedChunks)
                {
                    if (Time.Timestamp - chunkedGram.Value.Timestamp > ChunkedGramTimeout)
                    {
                        if (toRemove == null)
                        {
                            toRemove = new ArrayRig <int>();
                        }
                        toRemove.Add(chunkedGram.Key);
                    }
                }
                if (toRemove != null)
                {
                    foreach (var chunkId in toRemove)
                    {
                        ChunkedGram chunked;
                        if (_receivedChunks.TryGetValue(chunkId, out chunked))
                        {
                            _receivedChunks.Remove(chunkId);
                            chunked.Chunks.Dispose();
                        }
                    }
                }
            }

            // release the read lock
            _syncLock.ReleaseRead();

            // create the endpoint for receiving data
            _receiveEndPoint = new IPEndPoint(RemoteEndPoint.Address, RemoteEndPoint.Port);

            try {
                // start receiving again
                Socket.BeginReceiveFrom(_receiveBuffer, 0, Global.BufferSizeLocal, SocketFlags.None,
                                        ref _receiveEndPoint, OnReceiveSocketData, null);
            } catch (Exception ex) {
                ProcessError(ex);
                return;
            }
        }
Ejemplo n.º 17
0
 protected override void InitiateNewOption(ActionSet optionSet, int classIdentifier) => AddToCurrentOption(classIdentifier);
Ejemplo n.º 18
0
        private void UpdatePlayerPosition(ActionSet actionSet)
        {
            position += speed * delta;

            character.SetPosition(position);
            BoundingBox = new Rectangle((int)(position.X + hitboxOffset.X), (int)(position.Y + hitboxOffset.Y),
                                        BoundingBox.Width, BoundingBox.Height);
            var moveRequest = false;

            FootstepEffectManager.Paused = true;

            //lower character's speed, if he is carrying treasure or walking on undergrowth
            if (contactFoliage && character.InvTreasure == null)
            {
                accX      = CharacterConfig.FOLIAGE_ACC_X;
                maxSpeedX = CharacterConfig.MAX_SPEED_X_FOLIAGE;
                jumpSpeed = CharacterConfig.FOLIAGE_JUMP_SPEED_Y;
            }
            else if (contactFoliage && character.InvTreasure != null)
            {
                accX      = CharacterConfig.FOLIAGE_AND_CARRY_ACC_X;
                maxSpeedX = CharacterConfig.MAX_SPEED_X_FOLIAGE;
                jumpSpeed = CharacterConfig.FOLIAGE_AND_CARRY_JUMP_SPEED_Y;
            }
            else if (!contactFoliage && character.InvTreasure != null)
            {
                accX      = CharacterConfig.CARRY_ACC_X;
                maxSpeedX = CharacterConfig.MAX_SPEED_X_CARRY;
                jumpSpeed = CharacterConfig.CARRY_JUMP_SPEED_Y;
            }
            else
            {
                accX      = CharacterConfig.BASE_ACC_X;
                maxSpeedX = CharacterConfig.MAX_SPEED_X;
                jumpSpeed = CharacterConfig.JUMP_START_SPEED_Y;
            }

            //Handle axisinputs
            foreach (var t in actionSet.axisActions)
            {
                var movement = t.Item2;

                if (t.Item1 == InputConfig.Actions.MOVE_DIRECTION)
                {
                    if (movement.X < -CharacterConfig.INPUT_X_SENS)
                    {
                        //move left
                        moveRequest = true;
                        facingRight = false;
                        if (IsClimbing)
                        {
                            speed.X = -CharacterConfig.CLIMB_SPEED_X;
                            ((Spritesheet)character.getRepresentation()).PlayAnimation("climb", 1F, true);
                        }
                        else
                        {
                            FootstepEffectManager.Paused = false;
                            speed.X = -maxSpeedX;//accX * delta;
                            ((Spritesheet)character.getRepresentation()).PlayAnimation("run", 1F, true);
                            CreateFootstepParticles();
                        }
                    }
                    if (movement.X > CharacterConfig.INPUT_X_SENS)
                    {
                        //move right
                        moveRequest = true;
                        facingRight = true;
                        if (IsClimbing)
                        {
                            speed.X = CharacterConfig.CLIMB_SPEED_X;
                            ((Spritesheet)character.getRepresentation()).PlayAnimation("climb");
                        }
                        else
                        {
                            FootstepEffectManager.Paused = false;
                            speed.X = maxSpeedX; //accX * delta;
                            ((Spritesheet)character.getRepresentation()).PlayAnimation("run");
                            CreateFootstepParticles();
                        }
                    }

                    if (movement.Y < -CharacterConfig.INPUT_Y_SENS && isInClimbingArea)
                    {
                        IsClimbing = true;
                        //climb down
                        speed.Y     = 2f * CharacterConfig.CLIMB_SPEED_Y;
                        moveRequest = true;
                        if (facingRight)
                        {
                            ((Spritesheet)character.getRepresentation()).PlayAnimation("climb");
                        }
                        else
                        {
                            ((Spritesheet)character.getRepresentation()).PlayAnimation("climb", 1F, true);
                        }
                    }

                    if (movement.Y > CharacterConfig.INPUT_X_SENS && isInClimbingArea)
                    {
                        IsClimbing = true;
                        //climb up
                        speed.Y     = -CharacterConfig.CLIMB_SPEED_Y;
                        moveRequest = true;
                        if (facingRight)
                        {
                            ((Spritesheet)character.getRepresentation()).PlayAnimation("climb");
                        }
                        else
                        {
                            ((Spritesheet)character.getRepresentation()).PlayAnimation("climb", 1F, true);
                        }
                    }
                }
            }

            //Handle actions

            if (actionSet.actions.Contains(InputConfig.Actions.JUMP) && !IsClimbing && !jumpKeyDown && !IsInAir)
            {
                //jump
                moveRequest = true;
                jumping     = true;
                jumpKeyDown = true;
                speed.Y     = -jumpSpeed;
                if (facingRight)
                {
                    ((Spritesheet)character.getRepresentation()).PlayAnimation("jump");
                }
                else
                {
                    ((Spritesheet)character.getRepresentation()).PlayAnimation("jump", 1F, true);
                }
                actionSet.actions.Remove(InputConfig.Actions.JUMP);
            }

            //Allow player to fall while climbing , if the JUMP Button is pressed
            if (actionSet.actions.Contains(InputConfig.Actions.JUMP) && IsClimbing)
            {
                if (climableYCenter > 0f && BoundingBox.Bottom < climableYCenter - 20)
                {
                    position.Y += 100;
                }
                jumping     = false;
                IsClimbing  = false;
                moveRequest = true;
            }

            if (IsInAir && !IsClimbing && speed.Y > 0f) //&& speed.Y > 0f && jumping
            {
                moveRequest = true;
                if (facingRight)
                {
                    ((Spritesheet)character.getRepresentation()).PlayAnimation("fall");
                }
                else
                {
                    ((Spritesheet)character.getRepresentation()).PlayAnimation("fall", 1F, true);
                }
            }

            if (IsInAir)
            {
                FootstepEffectManager.Paused = true;
            }

            if (actionSet.actions.Count == 0)
            {
                jumpKeyDown = false;
            }

            actionSet.axisActions.Clear();

            // Apply the force of gravity
            if (!IsClimbing)
            {
                speed.Y += accY * delta;
            }

            // Limit the sideways acceleration of the player
            if (speed.X > maxSpeedX)
            {
                speed.X = maxSpeedX;
            }
            if (speed.X < -maxSpeedX)
            {
                speed.X = -maxSpeedX;
            }
            // Limit the force of gravity (terminal velocity) if (speedY > maxSpeedY) speedY = maxSpeedY;
            if (speed.Y < -CharacterConfig.MAX_SPEED_Y)
            {
                speed.Y = -CharacterConfig.MAX_SPEED_Y;
            }

            // Decelerate the player's sideways movement if left or right wasn't pressed
            if (!moveRequest)
            {
                if (!IsClimbing)
                {
                    if (character.currentAnimRestartCounter <= 0f)
                    {
                        if (facingRight)
                        {
                            ((Spritesheet)character.getRepresentation()).PlayAnimation("idle");
                        }
                        else
                        {
                            ((Spritesheet)character.getRepresentation()).PlayAnimation("idle", 1F, true);
                        }
                    }
                }
                else
                {
                    speed.Y = 0;
                    if (character.currentAnimRestartCounter <= 0f)
                    {
                        if (facingRight)
                        {
                            ((Spritesheet)character.getRepresentation()).PlayAnimation("climbidle");
                        }
                        else
                        {
                            ((Spritesheet)character.getRepresentation()).PlayAnimation("climbidle", 1F, true);
                        }
                    }
                }



                if (speed.X < 0)
                {
                    speed.X += decX * delta;
                }
                if (speed.X > 0)
                {
                    speed.X -= decX * delta;
                }

                // Deceleration may produce a speed that is greater than zero but
                // smaller than the smallest unit of deceleration. These lines ensure
                // that the player does not keep travelling at slow speed forever after
                // decelerating.
                if (speed.X > 0 && speed.X < decX)
                {
                    speed.X = 0;
                }
                if (speed.X < 0 && speed.X > -decX)
                {
                    speed.X = 0;
                }

                FootstepEffectManager.Paused = true;
            }
        }
Ejemplo n.º 19
0
 // Build the function of the current option.
 protected override void FinalizeCurrentOption(ActionSet optionSet) => Current.Build(optionSet);
Ejemplo n.º 20
0
 public virtual void UpdateAction(ActionSet actions)
 {
 }
 private static void SetInitialDistances(ActionSet actionSet, IndexReference distancesVar, Element currentIndex)
 {
     actionSet.AddAction(distancesVar.SetVariable(LeastNot0, null, currentIndex));
 }
 public MacroVarBuilder(ActionSet builderSet, MacroVar macro) : base(builderSet)
 {
     _macro = macro;
 }
 public DijkstraNormal(ActionSet actionSet, Element pathmapObject, Element position, Element destination) : base(actionSet, pathmapObject, position, false)
 {
     this.destination = destination;
 }
 public AbstractMacroBuilder(ActionSet actionSet)
 {
     this.ActionSet = actionSet;
 }
 public DijkstraMultiSource(ActionSet actionSet, PathfinderInfo pathfinderInfo, Element pathmapObject, Element players, Element destination) : base(actionSet, pathmapObject, destination, true)
 {
     this.pathfinderInfo = pathfinderInfo;
     this.players        = players;
 }
Ejemplo n.º 26
0
 void Awake()
 {
     renderer = GetComponent <Renderer>();
     holderBe = transform.parent.GetComponent <SecondHolderBe>();
     call     = gameObject.AddComponent(typeof(ActionSet)) as ActionSet;
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Initialize components of the data manager.
        /// </summary>
        protected override void Setup(Node configuration)
        {
            string cassandraPath = null;
            int    cassandraPid  = 0;

            if (configuration.Contains("CassandraPath"))
            {
                cassandraPath = configuration["CassandraPath"].String;
            }
            if (configuration.Contains("CassandraPID"))
            {
                cassandraPid = configuration["CassandraPID"].Int32;
            }

            ManagerUpdate.OnStart.Add("Cassandra Process Joined", ActionSet.New(OnStart, cassandraPath, cassandraPid));

            // initialize the default endpoints
            var defaultEndPoints = new ArrayRig <IPEndPoint>();

            // if the default MetaCluster config has been defined
            if (configuration.DictionarySet)
            {
                // get the configuration of the default cluster
                Node cluster = configuration["DefaultCluster"];
                if (cluster["EntryPoints"].ArraySet)
                {
                    foreach (Node entryPoint in cluster["EntryPoints"].Array)
                    {
                        string[] components = entryPoint.String.Split(Chars.Colon);
                        if (components.Length != 2)
                        {
                            Log.Warning("A configuration address was incorrect '" + entryPoint.String + "'.");
                            continue;
                        }

                        IPAddress address;
                        if (!IPAddress.TryParse(components[0], out address))
                        {
                            Log.Warning("An ip address could not be parsed : '" + components[0] + "'.");
                            continue;
                        }
                        int port;
                        if (!int.TryParse(components[1], out port))
                        {
                            Log.Warning("A port could not be parsed : '" + components[1] + "'.");
                            continue;
                        }

                        // add an endpoint
                        defaultEndPoints.Add(new IPEndPoint(address, port));
                    }

                    // initialize the default cluster
                    AddCluster(defaultEndPoints, cluster["username"].String, cluster["password"].String);
                }

                // read the default keyspace name
                DefaultKeyspaceName = cluster.Default <string>("Efz", "DefaultKeyspace");
            }
            else
            {
                DefaultKeyspaceName = "Efz";
            }
        }
 public override IWorkshopTree Parse(ActionSet actionSet, IExpression expression, object additionalParameterData)
 {
     return(base.Parse(actionSet, expression, additionalParameterData));
 }
        public override IWorkshopTree Get(ActionSet actionSet, IWorkshopTree[] parameterValues)
        {
            var a      = actionSet.VarCollection.Assign("_angleOfVectors_a", actionSet.IsGlobal, true);
            var b      = actionSet.VarCollection.Assign("_angleOfVectors_b", actionSet.IsGlobal, true);
            var c      = actionSet.VarCollection.Assign("_angleOfVectors_c", actionSet.IsGlobal, true);
            var ab     = actionSet.VarCollection.Assign("_angleOfVectors_ab", actionSet.IsGlobal, true);
            var bc     = actionSet.VarCollection.Assign("_angleOfVectors_bc", actionSet.IsGlobal, true);
            var abVec  = actionSet.VarCollection.Assign("_angleOfVectors_abVec", actionSet.IsGlobal, true);
            var bcVec  = actionSet.VarCollection.Assign("_angleOfVectors_bcVec", actionSet.IsGlobal, true);
            var abNorm = actionSet.VarCollection.Assign("_angleOfVectors_abNorm", actionSet.IsGlobal, true);
            var bcNorm = actionSet.VarCollection.Assign("_angleOfVectors_bcNorm", actionSet.IsGlobal, true);

            Element zeroVec = Element.Part <V_Vector>(new V_Number(0), new V_Number(0), new V_Number(0));

            actionSet.AddAction(ArrayBuilder <Element> .Build(
                                    // Save A
                                    a.SetVariable((Element)parameterValues[0]),
                                    // Save B
                                    b.SetVariable((Element)parameterValues[1]),
                                    // save C
                                    c.SetVariable((Element)parameterValues[2]),

                                    // get ab
                                    // ab[3] = { b[0] - a[0], b[1] - a[1], b[2] - a[2] };
                                    ab.SetVariable(Element.Part <V_Vector>(
                                                       Element.Part <V_XOf>(b.GetVariable()) - Element.Part <V_XOf>(a.GetVariable()),
                                                       Element.Part <V_YOf>(b.GetVariable()) - Element.Part <V_YOf>(a.GetVariable()),
                                                       Element.Part <V_ZOf>(b.GetVariable()) - Element.Part <V_ZOf>(a.GetVariable())
                                                       )),

                                    // get bc
                                    // bc[3] = { c[0] - b[0], c[1] - b[1], c[2] - b[2] };
                                    bc.SetVariable(Element.Part <V_Vector>(
                                                       Element.Part <V_XOf>(c.GetVariable()) - Element.Part <V_XOf>(b.GetVariable()),
                                                       Element.Part <V_YOf>(c.GetVariable()) - Element.Part <V_YOf>(b.GetVariable()),
                                                       Element.Part <V_ZOf>(c.GetVariable()) - Element.Part <V_ZOf>(b.GetVariable())
                                                       )),

                                    // get abVec
                                    // abVec = sqrt(ab[0] * ab[0] + ab[1] * ab[1] + ab[2] * ab[2]);
                                    abVec.SetVariable(Element.Part <V_DistanceBetween>(
                                                          ab.GetVariable(),
                                                          zeroVec
                                                          )),

                                    // get bcVec
                                    // bcVec = sqrt(bc[0] * bc[0] + bc[1] * bc[1] + bc[2] * bc[2]);
                                    bcVec.SetVariable(Element.Part <V_DistanceBetween>(
                                                          bc.GetVariable(),
                                                          zeroVec
                                                          )),

                                    // get abNorm
                                    // abNorm[3] = {ab[0] / abVec, ab[1] / abVec, ab[2] / abVec};
                                    abNorm.SetVariable(Element.Part <V_Vector>(
                                                           Element.Part <V_XOf>(ab.GetVariable()) / (Element)abVec.GetVariable(),
                                                           Element.Part <V_YOf>(ab.GetVariable()) / (Element)abVec.GetVariable(),
                                                           Element.Part <V_ZOf>(ab.GetVariable()) / (Element)abVec.GetVariable()
                                                           )),

                                    // get bcNorm
                                    // bcNorm[3] = {bc[0] / bcVec, bc[1] / bcVec, bc[2] / bcVec};
                                    bcNorm.SetVariable(Element.Part <V_Vector>(
                                                           Element.Part <V_XOf>(bc.GetVariable()) / (Element)bcVec.GetVariable(),
                                                           Element.Part <V_YOf>(bc.GetVariable()) / (Element)bcVec.GetVariable(),
                                                           Element.Part <V_ZOf>(bc.GetVariable()) / (Element)bcVec.GetVariable()
                                                           ))
                                    ));

            Element result = (Element.Part <V_ArccosineInRadians>(
                                  // get res
                                  // res = abNorm[0] * bcNorm[0] + abNorm[1] * bcNorm[1] + abNorm[2] * bcNorm[2];
                                  //target.SetVariable(
                                  Element.Part <V_XOf>(abNorm.GetVariable()) * Element.Part <V_XOf>(bcNorm.GetVariable()) +
                                  Element.Part <V_YOf>(abNorm.GetVariable()) * Element.Part <V_YOf>(bcNorm.GetVariable()) +
                                  Element.Part <V_ZOf>(abNorm.GetVariable()) * Element.Part <V_ZOf>(bcNorm.GetVariable())
                                  ) * 180) / Math.PI;

            return(result);
        }
Ejemplo n.º 30
0
		public void TestActionModelStore()
		{
			_actionSetup = new string[,]
			{
				{ "ClearCanvas.ImageViewer.Tools.Standard.StackTool:activate", "imageviewer-contextmenu/MenuToolsStandardStack", "Tools.Image.Manipulation.Stacking.Standard" }, 
				{ "ClearCanvas.ImageViewer.Tools.Standard.WindowLevelTool:activate", "imageviewer-contextmenu/MenuToolsStandardWindowLevel", "Tools.Image.Manipulation.Lut.WindowLevel"}, 
				{ "ClearCanvas.ImageViewer.Tools.Standard.LutPresetTool:auto", "imageviewer-contextmenu/MenuToolsStandardLutPresets/auto", "Tools.Image.Manipulation.Lut.Presets" }, 
				{ "BogusDefault", "imageviewer-contextmenu/BogusDefault", "" }, 
				{ "ClearCanvas.ImageViewer.Tools.Standard.PanTool:activate", "imageviewer-contextmenu/MenuToolsStandardPan", "Tools.Image.Manipulation.Pan" },
				{ "test1", "imageviewer-contextmenu/Tools.Image.Manipulation.SomethingNew", "Tools.Image.Manipulation.SomethingNew" },
                { "ClearCanvas.ImageViewer.Tools.Standard.ZoomTool:activate", "imageviewer-contextmenu/MenuToolsStandardZoom", "Tools.Image.Manipulation.Zoom" } ,
				{ "ClearCanvas.ImageViewer.Tools.Standard.ProbeTool:activate", "imageviewer-contextmenu/MenuToolsStandardProbe", "Tools.Image.Interrogation.Probe" },
				{ "test2", "imageviewer-contextmenu/Tools.Image.SomethingNew", "Tools.Image.SomethingNew" },
				{ "ClearCanvas.ImageViewer.Tools.Volume.ZoomVolumeTool:activate", "imageviewer-contextmenu/Zoom Volume", "Tools.VolumeImage.Manipulation.Zoom" },
				{ "ClearCanvas.ImageViewer.Tools.Volume.RotateVolumeTool:activate", "imageviewer-contextmenu/Rotate Volume", "Tools.VolumeImage.Manipulation.Rotate"},
				{ "ClearCanvas.ImageViewer.Tools.Measurement.RulerTool:activate", "imageviewer-contextmenu/ToolsMeasurementRuler", "Tools.Measurement.Basic.ROI.Linear" },
				{ "ClearCanvas.ImageViewer.DefaultInsertionPoint", "imageviewer-contextmenu/DefaultInsertionPoint", "" },
				{ "test3", "imageviewer-contextmenu/DefaultInsertionPointTest", "" },
				{ "test4", "imageviewer-contextmenu/DefaultInsertionPointTest2", "Something.Completely.New" },
				{ "ClearCanvas.ImageViewer.Layout.Basic.ContextMenuLayoutTool:display0", "imageviewer-contextmenu/DisplaySets", "DisplaySets"},
				{ "test5", "imageviewer-contextmenu/DisplaySets.DisplaySet1", "DisplaySets" },
				{ "test6", "imageviewer-contextmenu/DisplaySets.DisplaySet2", "DisplaySets" },
				{ "test7", "imageviewer-contextmenu/DisplaySets.DisplaySet3", "DisplaySets.DisplaySet3" }
			};

			CreateActionSet();

			CreateDefaultXmlDocument();

			ActionSet allActions = new ActionSet(_allActions);

			ActionModelSettings.Default.BuildAndSynchronize(this.GetType().FullName, MENUNAME, allActions);

			VerifyXmlDocument();
		}
Ejemplo n.º 31
0
            public override IWorkshopTree Parse(ActionSet actionSet, MethodCall methodCall)
            {
                var lambda = (LambdaAction)methodCall.ParameterValues[0];

                return(Element.Part <T>(actionSet.CurrentObject, lambda.Invoke(actionSet, new V_ArrayElement())));
            }