コード例 #1
0
ファイル: LSLScriptInstance.cs プロジェクト: thoys/simian
 public void Init(LSLScriptWrapper scriptWrapper)
 {
     m_state = "default";
     m_scriptWrapper = scriptWrapper;
     m_eventQueue = new Queue<EventParams>();
 }
コード例 #2
0
ファイル: LSLScriptInstance.cs プロジェクト: thoys/simian
 public void Init(LSLScriptWrapper wrapper)
 {
     m_scriptWrapper = wrapper;
 }
コード例 #3
0
ファイル: LSLScriptInstance.cs プロジェクト: jhurliman/simian
 public void Init(LSLScriptWrapper wrapper)
 {
     m_scriptWrapper = wrapper;
 }
コード例 #4
0
ファイル: LSLScriptInstance.cs プロジェクト: jhurliman/simian
 public void Init(LSLScriptWrapper scriptWrapper)
 {
     m_state         = "default";
     m_scriptWrapper = scriptWrapper;
     m_eventQueue    = new Queue <EventParams>();
 }
コード例 #5
0
        private void StartScript(UUID sourceItemID, UUID sourceAssetID, ISceneEntity hostObject, byte[] scriptBinary)
        {
            // Create a new AppDomain for this script
            AppDomainSetup domainSetup = new AppDomainSetup();

            domainSetup.LoaderOptimization = LoaderOptimization.SingleDomain;
            AppDomain scriptDomain = AppDomain.CreateDomain(sourceItemID + ".lsl", null, domainSetup);

            // Create an instance (that lives in this AppDomain) and a wrapper
            // (that lives in the script AppDomain) for this script
            LSLScriptInstance instance = new LSLScriptInstance(sourceItemID, sourceAssetID, hostObject, scriptDomain);
            LSLScriptWrapper  wrapper  = (LSLScriptWrapper)scriptDomain.CreateInstanceAndUnwrap(
                Assembly.GetExecutingAssembly().FullName, "Simian.Scripting.Linden.LSLScriptWrapper");

            wrapper.Init(scriptBinary, instance);
            instance.Init(wrapper);

            lock (m_syncRoot)
            {
                // If this script is already running, shut it down
                StopScript(sourceItemID, false);

                // Keep track of this script
                m_scripts[sourceItemID] = instance;

                // Keep track of the entity containing this script
                Dictionary <UUID, LSLScriptInstance> entityScripts;
                if (!m_scriptedEntities.TryGetValue(hostObject.ID, out entityScripts))
                {
                    entityScripts = new Dictionary <UUID, LSLScriptInstance>();
                    m_scriptedEntities[hostObject.ID] = entityScripts;
                }
                entityScripts[instance.ID] = instance;
            }

            if (hostObject is LLPrimitive)
            {
                // Update the PrimFlags for the containing LLPrimitive
                LLPrimitive obj = (LLPrimitive)hostObject;
                bool        hasCollisionEvents;

                PrimFlags     oldFlags   = obj.Prim.Flags;
                LSLEventFlags eventFlags = wrapper.GetEventsForState("default");

                PrimFlags newFlags = oldFlags;
                newFlags &= ~(PrimFlags.Touch | PrimFlags.Money);
                newFlags |= PrimFlags.Scripted | LSLEventFlagsToPrimFlags(eventFlags, out hasCollisionEvents);

                // FIXME: Do something with hasCollisionEvents

                // Either update the PrimFlags for this prim or just schedule
                // it for serialization (since it has a new script)
                if (newFlags != oldFlags)
                {
                    obj.Prim.Flags = newFlags;
                    m_scene.EntityAddOrUpdate(this, obj, 0, (uint)LLUpdateFlags.PrimFlags);
                }
                else
                {
                    m_scene.EntityAddOrUpdate(this, obj, UpdateFlags.Serialize, 0);
                }
            }

            // Fire the state_entry event to get this script started
            PostScriptEvent(new EventParams(sourceItemID, "state_entry", new object[0], new DetectParams[0]));
        }