public override void Init(AABB worldBox)
		{
			m_vmST.VMDefine(typeof(IAccounting), typeof(ConstrainedAccounting));
			base.Init(worldBox);

			RegisterAction(2, "transfer");
			RegisterAction(3, "collision");
			RegisterAction(4, "nextpresent");
		}
		public override void Init(AABB worldBox)
		{
			m_vmST.VMDefine(typeof(IAccounting), typeof(ConstrainedAccounting));
			base.Init(worldBox);

			RegisterAction(2, "init");
			RegisterAction(2, "kickoff");
			RegisterAction(4, "nextpresent");
		}
Exemple #3
0
 public void Init(AABB worldBox)
 {
     for (int i = 0; i < 64; i++)
     {
         Particle p = new Particle();
         p.Position = new Vector2((float)rand.NextDouble() * 2 - 1, (float)rand.NextDouble() * 2 - 1);
         p.Color.R = (float)rand.NextDouble();
         p.Color.G = (float)rand.NextDouble();
         p.Color.B = (float)rand.NextDouble();
         Particles.Add(p);
     }
 }
Exemple #4
0
        public static void Move(Particle body, float dt, AABB worldBox)
        {
            body.pt += body.velocity * dt;

            // naive implementation, flip if hits border
			if (body.pt.X < worldBox.Min.X || body.pt.X > worldBox.Max.X)
				body.velocity.X *= -1;
			if (body.pt.Y < worldBox.Min.Y || body.pt.Y > worldBox.Max.Y)
				body.velocity.Y *= -1;
			if (body.pt.Z < worldBox.Min.Z || body.pt.Z > worldBox.Max.Z)
				body.velocity.Z *= -1;
        }
		public override void Init(AABB worldBox)
		{
			m_worldBox = worldBox;

			if (!m_vmST.VMExist(typeof(IAccounting)))
				throw new ApplicationException("Accounting functions are not declared in VM yet");

			// --- init demo objects ---

			{
				var idFactory = ServiceManager.ComputeNode.HIdFactory;
				var initialST = new Spacetime(idFactory.CreateFromRoot(), ITCEvent.CreateZero(), idFactory);
				var secondST = new Spacetime(idFactory.CreateFromRoot(), ITCEvent.CreateZero(), idFactory);
				m_spacetimes.AddRange(new[] { initialST, secondST });
			}

			// fake the globally existing SyncManager
			foreach (var ST in m_spacetimes)
				ServiceManager.LocatingService.RegisterSpaceTime(ST, null);

			// must pull new VM to use IAccounting
			foreach (var ST in m_spacetimes)
				ServiceManager.SyncService.PullFromVmSt(ST.ID);


			// create 2 accounts
			for (int ii = 0; ii < 2; ++ii)
			{
				// firstly create into same ST then we migrate one to another ST
				var newAccount = m_spacetimes[0].CreateState((st, stamp) => AccountFactory(st, stamp, ii));
				//m_namingSvc.RegisterObject(newAccount.StateId.ToString(), newAccount.GetType().ToString(), newAccount);
				m_accountStates.Add(newAccount);
				m_accounts.Add(new ScopedStateRef(newAccount.StateId, newAccount.GetType().ToString()));
			}

			m_spacetimes[1].Immigrate(m_accounts[1].StateId, m_spacetimes[0].ID);

			// deposit some initial money
			using (new WithIn(m_spacetimes[0]))
			{
				foreach (var acc in m_accounts)
					m_accountingInvoker.Deposit(acc, 900.0f);
			}

			// initial chronon
			SyncSpacetimes();
		}
Exemple #6
0
        public void Init(AABB worldBox)
        {
            m_worldBox = worldBox;
            //for (int ii = 0; ii < 10; ++ii )
            //    m_particles.Add(new Particle(new ITCTimestamp()) { pt = worldBox.RandomPoint(m_rand) });

            // declare a function form for an event, which also means binding an event to one or a few state types
            kernel.Declare("GodPush"
                            , FunctionForm.From(typeof(NewtonPhysics).GetMethod("GodPush")));

            //foreach (var p in m_particles)
            //{
            //    kernel.AwareOf("GodPush"
            //                   , typeof(NewtonPhysics).GetMethod("GodPush")
            //                   , new Action<Particle, Vector3>(NewtonPhysics.GodPush)
            //                   , p);
            //    //kernel.AwareOf("Collide", typeof(NewtonPhysics).GetMethod("Collide"), new Action<Particle,Particle>(NewtonPhysics.Collide) );
            //}
        }
		public override void Init(AABB worldBox)
		{
			m_vmST.VMDefine(typeof(IAccounting), typeof(Accounting));
			base.Init(worldBox);
		}
			public Present(StateSnapshot[] accounts, AABB worldBox)
			{
				m_accounts = accounts;
				m_worldbox = worldBox;
			}
Exemple #9
0
		public override void Init(AABB worldBox)
		{
			m_worldBox = worldBox;
			CollectAllModel();
			RegisterAction(1, "next");
		}
Exemple #10
0
		public virtual void Init(AABB worldBox) { }