Ejemplo n.º 1
0
        public override void Action()
        {
            // A: Required.
            if (this.A_SavevalueEntityId == null)
            {
                throw new ModelingException("SAVEVALUE: Operand A is required operand!");
            }
            int entityId = (int)this.A_SavevalueEntityId.GetValue();

            // B: Required.
            // TODO: Savevalues currently operates with strings...
            string value = this.B_Value == null ? null : this.B_Value.GetValue().ToString();

            if (value == null)
            {
                throw new ModelingException("SAVEVALUE: Operand B is required operand!");
            }


            this.CreateEntity(entityId);

            Transaction transaction = this.Simulation.ActiveTransaction;

            this.EntryCount++;

            SavevalueEntity savevalueEntity = (SavevalueEntity)this.Simulation.GetEntity(entityId);

            savevalueEntity.SetValue(value);

            Console.WriteLine("Savevalued\tTime: " + this.Simulation.Clock + transaction, ConsoleColor.White);
            transaction.ChangeOwner(this);
            this.NextSequentialBlock.PassTransaction(transaction);
            this.Simulation.CurrentEventChain.AddAhead(transaction);
        }
Ejemplo n.º 2
0
 public void CreateEntity(int entityId)
 {
     if (!this.Simulation.Entities.ContainsKey(entityId))
     {
         SavevalueEntity savevalueEntity = new SavevalueEntity(this.Simulation, entityId);
         this.Simulation.Entities.Add(entityId, savevalueEntity);
     }
 }