public Player( int id ) { _id = id; // Default to acting as the player. _coralState = new Coral.State(); Coral.Runner r = new Coral.Runner( _coralState ); r.pushSecurityContext( new SecurityContext( "base", _id ) ); // If we're anon, make a mob for it. if( id == Mob.Anon.id ) { _anonWorld = new AnonWorld(); _anonMob = new AnonMob( _anonWorld, this ); _anonWorld.anonMob = _anonMob; } }
/// <summary> /// Pushes an actor context onto the Coral state. Do this before running code. /// </summary> public void actorContextPush( string name, int id ) { Coral.Runner r = new Coral.Runner( _coralState ); r.pushSecurityContext( new SecurityContext( name, id ) ); }
public void Passthrough() { PtTest pt = new PtTest(); Passthrough pter = new Passthrough( pt ); string program = @" pt.test(5, ""bob"", [""1"", ""2""], true, pt) pt.property = ""bar"" a = pt.property b = pt.arbitrary c = pt.other pt.arbitrary = ""new value"" d = pt.arbitrary pt.test2(1, 2, ""3"") e = """" def func(x): e += x pt.complex(1, func) f = pt.complex(2) g = pt.complex(3) h = pt.complex(4) i = pt.complex(5) j = pt.dumpcontext() k = 0 try: pt.complex(6) except e: k = e l = 0 try: l = pt.throwme except e: l = e m = 0 try: pt.throwme = ""foo"" except e: m = e n = 0 try: pt.callnthrow() except e: n = e "; Runner r = new Runner(); r.pushSecurityContext( new TestSC( "Base Context" ) ); pter.registerConst( r.state.constScope, "pt" ); runAndDump( "Passthrough", r, program, () => "object dump: {0} {1} {2} {3} {4} {5}\r\n".FormatI( dumpObject( pt._a ), dumpObject( pt._b ), dumpObject( pt._c ), dumpObject( pt._d ), dumpObject( pt._e ), dumpObject( pt._f ) ) ); }