/// <summary>
        ///     Loads mod's scripting features.
        ///     Returns true if successful.
        /// </summary>
        public static bool LoadEngine(bool verbose = false)
        {
            if (PythonEnvironment.LoadPythonAssembly())
            {
                try
                {
                    PythonEnvironment.InitializeEngine();
                    CreateScriptingEnvironment();
                    _component = Mod.Controller.AddComponent <ScriptComponent>();

                    if (verbose)
                    {
                        ModConsole.AddMessage(LogType.Log, $"[LenchScripterMod]: {Python.Execute("sys.version")}");
                    }

                    Mod.LoadedScripter = true;
                }
                catch (Exception e)
                {
                    if (verbose)
                    {
                        ModConsole.AddMessage(LogType.Log, "[LenchScripterMod]: Error while initializing python engine:", e.ToString());
                    }
                    Mod.LoadedScripter = false;
                }
            }
            else
            {
                Mod.LoadedScripter = false;
            }
            return(Mod.LoadedScripter);
        }
        protected override void ReplaceScript(ScriptComponent scriptComponent, ReloadedScriptEntry reloadedScript)
        {
            // Create new script instance
            var newScript = DeserializeScript(reloadedScript);

            // Dispose and unregister old script (and their MicroThread, if any)
            var oldScript = scriptComponent.Scripts[reloadedScript.ScriptIndex];

            // Flag scripts as being live reloaded
            if (game != null)
            {
                game.Script.LiveReload(oldScript, newScript);
            }

            // Replace with new script
            // TODO: Remove script before serializing it, so cancellation code can run
            scriptComponent.Scripts[reloadedScript.ScriptIndex] = newScript;

            oldScript.Dispose();

            if (oldScript.MicroThread != null && !oldScript.MicroThread.IsOver)
            {
                // Force the script to be cancelled
                oldScript.MicroThread.RaiseException(new MicroThreadCancelledException());
            }
        }
        private void CloseWebView()
        {
            if (_webView2Control != null)
            {
                _webView2Control.Close();
                _webView2Control.EnvironmentCreated -= webView2Control1_EnvironmentCreated;
                _webView2Control.BrowserCreated     -= _webView2Control_BrowserCreated;
                _webView2Control.ContainsFullScreenElementChanged -= _webView2Control_ContainsFullScreenElementChanged;
                _webView2Control.NewWindowRequested -= _webView2Control_NewWindowRequested;

                _environment.UnregisterNewVersionAvailable(_newVersionToken);

                _settingsComponent.CleanUp();
                _settingsComponent = null;

                _fileComponent.CleanUp();
                _fileComponent = null;

                _processComponent.CleanUp();
                _processComponent = null;

                _scriptComponent.CleanUp();
                _scriptComponent = null;

                _controlComponent.CleanUp();
                _controlComponent = null;

                _viewComponent.CleanUp();
                _viewComponent = null;

                tableLayoutPanel1.Controls.Remove(_webView2Control);
                _webView2Control.Dispose();
                _webView2Control = null;
            }
        }
        private void _webView2Control_BrowserCreated(object sender, EventArgs e)
        {
            _settingsComponent = new SettingsComponent(_environment, _webView2Control);
            _fileComponent     = new FileComponent(this, _webView2Control);
            _processComponent  = new ProcessComponent(this, _webView2Control);
            _scriptComponent   = new ScriptComponent(this, _webView2Control);
            _controlComponent  = new ControlComponent(this, navigationToolBar, _webView2Control);
            _viewComponent     = new ViewComponent(this, _webView2Control);

            if (_onWebViewFirstInitialized != null)
            {
                _onWebViewFirstInitialized.Invoke();
                _onWebViewFirstInitialized = null;
            }

            if (!string.IsNullOrEmpty(_initialUrl))
            {
                _webView2Control.Navigate(_initialUrl);
            }

            if (_newWindowRequestedEventArgs != null)
            {
                _newWindowRequestedEventArgs.NewWindow = _webView2Control.InnerWebView2WebView;
                _newWindowRequestedEventArgs.Handled   = true;
                _newWindowDeferral.Complete();
                _newWindowRequestedEventArgs = null;
                _newWindowDeferral           = null;
            }
        }
Exemple #5
0
 public ZapClient(string host, int port, Protocols protocol = Protocols.http)
 {
     Protocol          = protocol;
     Host              = host;
     Port              = port;
     Acsrf             = new AcsrfComponent(this);
     AjaxSpider        = new AjaxSpiderComponent(this);
     Ascan             = new AscanComponent(this);
     Authentication    = new AuthenticationComponent(this);
     Authorization     = new AuthorizationComponent(this);
     Autoupdate        = new AutoupdateComponent(this);
     Break             = new BreakComponent(this);
     Context           = new ContextComponent(this);
     Core              = new CoreComponent(this);
     ForcedUser        = new ForcedUserComponent(this);
     HttpSessions      = new HttpSessionsComponent(this);
     Params            = new ParamsComponent(this);
     Pscan             = new PscanComponent(this);
     Reveal            = new RevealComponent(this);
     Script            = new ScriptComponent(this);
     Search            = new SearchComponent(this);
     Selenium          = new SeleniumComponent(this);
     SessionManagement = new SessionManagementComponent(this);
     Spider            = new SpiderComponent(this);
     Users             = new UsersComponent(this);
 }
Exemple #6
0
        public RouteNodeTool(RouteNode node,
                             ScriptComponent parent,
                             ScriptComponent undoRedoRecordObject,
                             Func <RouteNode> getSelected,
                             Action <RouteNode> setSelected,
                             Predicate <RouteNode> hasNode,
                             Func <float> radius,
                             Func <RouteNode, Color> color)
        {
            Node   = node;
            Parent = parent;
            AddChild(new FrameTool(node)
            {
                OnChangeDirtyTarget   = Parent,
                TransformHandleActive = false,
                UndoRedoRecordObject  = undoRedoRecordObject
            });

            m_getSelected = getSelected;
            m_setSelected = setSelected;
            m_hasNode     = hasNode;
            m_radius      = radius ?? new Func <float>(() => { return(0.05f); });
            m_color       = color;

            Visual.Color          = m_color(Node);
            Visual.MouseOverColor = new Color(0.1f, 0.96f, 0.15f, 1.0f);
            Visual.OnMouseClick  += OnClick;
        }
Exemple #7
0
        /// <summary>
        /// Remove the provided script from the script system.
        /// </summary>
        /// <param name="script">The script to remove</param>
        public void Remove(ScriptComponent script)
        {
            // Make sure it's not registered in any pending list
            var startWasPending = scriptsToStart.Remove(script);
            var wasRegistered   = registeredScripts.Remove(script);

            if (!startWasPending && wasRegistered)
            {
                // Cancel scripts that were already started
                try
                {
                    script.Cancel();
                }
                catch (Exception e)
                {
                    HandleSynchronousException(script, e);
                }

                var asyncScript = script as AsyncScript;
                asyncScript?.MicroThread.Cancel();
            }

            var syncScript = script as SyncScript;

            if (syncScript != null)
            {
                syncScripts.Remove(syncScript);
                syncScript.UpdateSchedulerNode = null;
            }
        }
Exemple #8
0
        public static Mesh GenerateLineMesh(this ScriptComponent script, Vector3 positionA, Vector3 positionB)
        {
            var pointA = new Vector3(positionA.X, 0f, positionA.Z);
            var pointB = new Vector3(positionB.X, 0f, positionB.Z);

            var vertices = new VertexPositionTexture[3];

            vertices[0].Position = pointA;
            vertices[1].Position = pointB;
            var vertexBuffer = Stride.Graphics.Buffer.Vertex.New(script.GraphicsDevice, vertices,
                                                                 GraphicsResourceUsage.Dynamic);

            int[] indices     = { 0, 1 };
            var   indexBuffer = Stride.Graphics.Buffer.Index.New(script.GraphicsDevice, indices);
            var   mesh        = new Mesh
            {
                //Draw = GeometricPrimitive.Cylinder.New(GraphicsDevice).ToMeshDraw()
                Draw = new MeshDraw
                {
                    PrimitiveType = PrimitiveType.LineList,
                    DrawCount     = indices.Length,
                    IndexBuffer   = new IndexBufferBinding(indexBuffer, true, indices.Length),
                    VertexBuffers = new[] { new VertexBufferBinding(vertexBuffer,
                                                                    VertexPositionTexture.Layout, vertexBuffer.ElementCount) },
                }
            };

            return(mesh);
        }
Exemple #9
0
        public static void SpawnPrefabModel(this ScriptComponent script, Prefab source, Entity attachEntity, Matrix localMatrix, Vector3 forceImpulse)
        {
            if (source == null)
            {
                return;
            }

            // Clone
            var spawnedEntities = source.Instantiate();

            // Add
            foreach (var prefabEntity in spawnedEntities)
            {
                prefabEntity.Transform.UpdateLocalMatrix();
                var entityMatrix = prefabEntity.Transform.LocalMatrix * localMatrix;
                entityMatrix.Decompose(out prefabEntity.Transform.Scale, out prefabEntity.Transform.Rotation, out prefabEntity.Transform.Position);

                if (attachEntity != null)
                {
                    attachEntity.AddChild(prefabEntity);
                }
                else
                {
                    script.SceneSystem.SceneInstance.RootScene.Entities.Add(prefabEntity);
                }

                var physComp = prefabEntity.Get <RigidbodyComponent>();
                if (physComp != null)
                {
                    physComp.ApplyImpulse(forceImpulse);
                }
            }
        }
        private void AddScriptToObject()
        {
            List <IScript> scriptList = new List <IScript>();
            String         key        = null;

            Object[] objArray = m_PostOffice.GetMessageObjects(m_ModuleID, Constant.enumMessage.ADD_SCRIPT_TO_OBJECT);

            foreach (Object[] obj in objArray)
            {
                scriptList.AddRange(Methods.GetObjectArrayOf <IScript>(obj));
                if (key == null)
                {
                    key = Methods.GetObjectOf <string>(obj);
                }
            }
            try
            {
                m_ScriptController.AddScript(m_GameObjectList[key].m_GameObjectId, scriptList.ToArray());
                foreach (IScript script in scriptList)
                {
                    IScriptComponent scriptComponent = new ScriptComponent(m_GameObjectList[key].m_GameObjectId, key, script);
                    script.m_ScriptController = m_ScriptController;
                    script.m_GameObject       = m_GameObjectList[key];
                    m_GameObjectList[key].AddComponent(scriptComponent);
                }
            }
            catch (Exception e)
            {
                System.Console.WriteLine("GameObject AddScriptToObject Error :" + e.ToString());
            }
        }
Exemple #11
0
        public void LoadScript(
            [Frozen] Mock <IHttpClient> httpClientMock,
            [Greedy] ScriptComponent sut,
            string name,
            string type,
            string engine,
            string path,
            string description)
        {
            // ARRANGE
            httpClientMock.SetupApiCall(sut, CallType.Action, "load",
                                        new Parameters
            {
                { "scriptName", name },
                { "scriptType", type },
                { "scriptEngine", engine },
                { "fileName", path },
                { "scriptDescription", description }
            })
            .ReturnsOkResult()
            .Verifiable();

            // ACT
            sut.LoadScript(name, type, engine, path, description);

            // ASSERT
            httpClientMock.Verify();
        }
Exemple #12
0
    public static GameEntity CreatePlayer(this GameContext context, float x, float y)
    {
        GameEntity entity = context.CreateEntity();

        entity.AddPosition(x, y);
        entity.AddRenderable(new RenderableInfo
        {
            Reference    = PlayerSprites.PlayerRun,
            RenderOffset = new Vector2(-50 / 2, -50 / 2)
        });
        entity.AddScript(ScriptComponent.GetLuaScript(entity, "/Assets/Scripts/Player.lua"));
        entity.AddVelocity(Vector2.Zero);

        /*
         * 0, -70
         * 50, -50
         * 50,  50
         * 0,  75
         * -50,  50
         * -50, -50
         */
        entity.AddCollision(new Polygon(entity.position, 50 / 2, 50 / 2), null);
        entity.isStaticBody = false;

        return(entity);
    }
        public static ScriptComponent AddScriptComponent(this IGameObject gameObject, params Type[] scriptActionTypes)
        {
            var component = new ScriptComponent(scriptActionTypes.Select(type => type?.FullName).ToArray());

            gameObject.AddComponent(component);
            return(component);
        }
Exemple #14
0
        /// <summary>
        /// Called by a live scripting debugger to notify the ScriptSystem about reloaded scripts.
        /// </summary>
        /// <param name="oldScript">The old script</param>
        /// <param name="newScript">The new script</param>
        public void LiveReload(ScriptComponent oldScript, ScriptComponent newScript)
        {
            // Set live reloading mode for the rest of it's lifetime
            oldScript.IsLiveReloading = true;

            // Set live reloading mode until after being started
            newScript.IsLiveReloading = true;
        }
Exemple #15
0
 public void Update(float deltaTime)
 {
     foreach (Entity entity in _entities.ToArray())
     {
         ScriptComponent scriptComponent = (ScriptComponent)entity.GetComponentOfType(typeof(ScriptComponent));
         scriptComponent.Script.Update();
     }
 }
Exemple #16
0
        public static void SpawnPrefabInstance(this ScriptComponent script, Prefab source, Entity attachEntity, float timeout, Matrix localMatrix)
        {
            if (source == null)
            {
                return;
            }

            Func <Task> spawnTask = async() =>
            {
                // Clone
                var spawnedEntities = source.Instantiate();

                // Add
                foreach (var prefabEntity in spawnedEntities)
                {
                    prefabEntity.Transform.UpdateLocalMatrix();
                    var entityMatrix = prefabEntity.Transform.LocalMatrix * localMatrix;
                    entityMatrix.Decompose(out prefabEntity.Transform.Scale, out prefabEntity.Transform.Rotation, out prefabEntity.Transform.Position);

                    if (attachEntity != null)
                    {
                        attachEntity.AddChild(prefabEntity);
                    }
                    else
                    {
                        script.SceneSystem.SceneInstance.RootScene.Entities.Add(prefabEntity);
                    }
                }

                // Countdown
                var secondsCountdown = timeout;
                while (secondsCountdown > 0f)
                {
                    await script.Script.NextFrame();

                    secondsCountdown -= (float)script.Game.UpdateTime.Elapsed.TotalSeconds;
                }

                // Remove
                foreach (var clonedEntity in spawnedEntities)
                {
                    if (attachEntity != null)
                    {
                        attachEntity.RemoveChild(clonedEntity);
                    }
                    else
                    {
                        script.SceneSystem.SceneInstance.RootScene.Entities.Remove(clonedEntity);
                    }
                }

                // Cleanup
                spawnedEntities.Clear();
            };

            script.Script.AddTask(spawnTask);
        }
Exemple #17
0
        public void ComponentName(
            [Greedy] ScriptComponent sut)
        {
            // ACT
            var result = sut.ComponentName;

            // ASSERT
            result.Should().Be("script");
        }
 public void attachScript(ScriptComponent scriptToAttach)
 {
     attachedScript = scriptToAttach;
     scriptToAttach.objectAttachedTo = this;
     scriptToAttach.worldTransform   = worldTransform;
     AttachedComponents.Add(scriptToAttach);
     scriptToAttach.objectAttachedTo = this;
     scriptToAttach.worldTransform   = worldTransform;
 }
Exemple #19
0
 public SegmentSpawner(ScriptComponent parentComponent, string prefabObjectPath, string separateFirstObjectPath = "")
 {
     m_parentComponent  = parentComponent;
     m_prefabObjectPath = prefabObjectPath;
     if (separateFirstObjectPath != "")
     {
         m_separateFirstObjectPrefabPath = separateFirstObjectPath;
     }
 }
Exemple #20
0
    public static void AddComponent(GameObject obj, ScriptTable table)
    {
        if (obj == null)
        {
            return;
        }
        ScriptComponent com = obj.AddComponent <ScriptComponent>();

        com.Initialize(Launch.Script, table);
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        ScriptComponent script = (ScriptComponent)target;

        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(650f), GUILayout.ExpandWidth(true));
        EditorGUILayout.TextArea(script.TranslatedScript, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
        EditorGUILayout.EndScrollView();
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        ScriptComponent script = (ScriptComponent)target;
        Script          s      = script.script;

        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(650f), GUILayout.ExpandWidth(true));
        EditorGUILayout.TextArea(script.TranslatedScript, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
        EditorGUILayout.EndScrollView();

        if (s.behaviorOrMacro is Behavior)
        {
            var referencedBy = (s.behaviorOrMacro as Behavior).referencedBy;
            if (referencedBy?.Count > 0)
            {
                GUILayout.Label("The behavior this script belongs to is referenced by");
                refScrollPos = GUILayout.BeginScrollView(refScrollPos, GUILayout.MaxHeight(300));
                referencedBy.ForEach(r =>
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label($"{r.behaviorOrMacro.aiModel.name} - {r.behaviorOrMacro}");
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Show"))
                    {
                        GameObject found = null;

                        foreach (var v in Object.FindObjectsOfType <ScriptComponent>())
                        {
                            if (v.script == r)
                            {
                                found = v.gameObject;
                                break;
                            }
                        }

                        if (found != null)
                        {
                            EditorGUIUtility.PingObject(found);
                        }
                        else
                        {
                            Debug.LogWarning("Could not find object that uses script " + r);
                        }
                    }
                    GUILayout.EndHorizontal();
                });
                GUILayout.EndScrollView();
            }
            else
            {
                GUILayout.Label("The behavior this script belongs to is not referenced by any script in this map");
            }
        }
    }
Exemple #23
0
        public void LoadComponent(Entity currentEntity, XElement component)
        {
            //Component
            switch (component.Attribute("Type")?.Value)
            {
            case "Physics":
                PhysicsComponent physicsComponent = new PhysicsComponent();
                physicsComponent.masse              = int.Parse(component.Element("masse")?.Value);
                physicsComponent.useGravity         = bool.Parse(component.Element("useGravity")?.Value);
                physicsComponent.useAirFriction     = bool.Parse(component.Element("useAirFriction")?.Value);
                physicsComponent.airFrictionTweaker = float.Parse(component.Element("airFrictionTweaker")?.Value, CultureInfo.InvariantCulture);
                currentEntity.AddComponent(physicsComponent);
                break;

            case "BoxCollision":
                BoxCollisionComponent boxCollisionComponent = new BoxCollisionComponent();
                boxCollisionComponent.size.X    = float.Parse(component.Element("sizeX")?.Value);
                boxCollisionComponent.size.Y    = float.Parse(component.Element("sizeY")?.Value);
                boxCollisionComponent.isTrigger = bool.Parse(component.Element("isTrigger")?.Value);
                currentEntity.AddComponent(boxCollisionComponent);
                break;

            case "Position":
                PositionComponent positionComponent = new PositionComponent();
                positionComponent.position.X  = float.Parse(component.Element("posX")?.Value);
                positionComponent.position.Y  = float.Parse(component.Element("posY")?.Value);
                positionComponent.orientation = float.Parse(component.Element("orientation")?.Value);
                currentEntity.AddComponent(positionComponent);
                break;

            case "Velocity":
                VelocityComponent velocityComponent = new VelocityComponent();
                velocityComponent.maxVelocity = float.Parse(component.Element("maxVelocity")?.Value);
                currentEntity.AddComponent(velocityComponent);
                break;

            case "Render":
                RenderComponent renderComponent = new RenderComponent();
                renderComponent.image  = component.Element("image")?.Value;
                renderComponent.size.X = int.Parse(component.Element("sizeX")?.Value);
                renderComponent.size.Y = int.Parse(component.Element("sizeY")?.Value);
                currentEntity.AddComponent(renderComponent);
                break;

            case "Script":
                ScriptComponent scriptComponent = new ScriptComponent();
                scriptComponent.Script = CreateScriptInstance(component.Element("scriptName")?.Value);
                currentEntity.AddComponent(scriptComponent);
                break;

            default:
                throw new Exception("Undefined Component");
            }
        }
        public static List <dynamic> GetRegisteredCalloutNames()
        {
            List <dynamic> RegisteredCalloutNames = new List <dynamic>();

            Game.LogTrivial("Adding callout names! ");
            foreach (Callout callout in ScriptComponent.GetAllByType <Callout>())
            {
                Game.LogTrivial("Adding callout name: " + callout.ScriptInfo.Name);
                RegisteredCalloutNames.Add(callout.ScriptInfo.Name);
            }
            return(RegisteredCalloutNames);
        }
    public void DelComponent(GameObject gameObject)
    {
        if (gameObject == null)
        {
            return;
        }
        ScriptComponent component = gameObject.GetComponent <ScriptComponent>();

        if (component == null)
        {
            return;
        }
        Object.Destroy(component);
    }
    public ScriptTable GetComponent(GameObject gameObject)
    {
        if (gameObject == null)
        {
            return(null);
        }
        ScriptComponent component = gameObject.GetComponent <ScriptComponent>();

        if (component == null)
        {
            return(null);
        }
        return(component.Table);
    }
Exemple #27
0
        private void AddSelectionProxy(GameObject instance)
        {
            // Handling old version where this object was used by the Wire only and
            // m_parentComponent wasn't present. I.e., if m_parenComponent == null
            // it has to be a Wire present.
            if (m_parentComponent == null)
            {
                m_parentComponent = m_segments.transform.parent.GetComponent <Wire>();
            }

            instance.GetOrCreateComponent <OnSelectionProxy>().Component = m_parentComponent;
            foreach (Transform child in instance.transform)
            {
                child.gameObject.GetOrCreateComponent <OnSelectionProxy>().Component = m_parentComponent;
            }
        }
        protected override void TransformObjectAfterRead(ref ObjectContext objectContext)
        {
            if (isSerializingAsReference)
            {
                // Transform the deserialized reference into a fake Entity, EntityComponent, etc...
                // Fake objects will later be fixed later with EntityAnalysis.FixupEntityReferences()
                if (!objectContext.SerializerContext.IsSerializing)
                {
                    var entityComponentReference = objectContext.Instance as EntityComponentReference;
                    var entityScriptReference    = objectContext.Instance as EntityScriptReference;
                    if (entityComponentReference != null)
                    {
                        var entityReference = new Entity {
                            Id = entityComponentReference.Entity.Id
                        };
                        var entityComponent = (EntityComponent)Activator.CreateInstance(entityComponentReference.ComponentType);
                        entityComponent.Entity = entityReference;

                        objectContext.Instance = entityComponent;
                    }
                    else if (entityScriptReference != null)
                    {
                        var entityReference = new Entity {
                            Id = entityScriptReference.Entity.Id
                        };
                        var scriptComponent = new ScriptComponent();
                        entityReference.Add(scriptComponent);

                        var entityScript = (Script)Activator.CreateInstance(entityScriptReference.ScriptType);
                        entityScript.Id = entityScriptReference.Id;
                        scriptComponent.Scripts.Add(entityScript);

                        objectContext.Instance = entityScript;
                    }
                    else if (objectContext.Instance is EntityReference)
                    {
                        objectContext.Instance = new Entity {
                            Id = ((EntityReference)objectContext.Instance).Id
                        };
                    }
                    else
                    {
                        base.TransformObjectAfterRead(ref objectContext);
                    }
                }
            }
        }
Exemple #29
0
        public static Entity SpawnModel(this ScriptComponent script, Entity source, Matrix localMatrix)
        {
            if (source == null)
            {
                return(null);
            }

            var sourceClone = source.Clone();

            var entityMatrix = source.Transform.LocalMatrix * localMatrix;

            entityMatrix.Decompose(out sourceClone.Transform.Scale, out sourceClone.Transform.Rotation, out sourceClone.Transform.Position);

            script.SceneSystem.SceneInstance.RootScene.Entities.Add(sourceClone);

            return(sourceClone);
        }
Exemple #30
0
        /// <summary>
        ///   Add the provided script to the script system.
        /// </summary>
        /// <param name="script">The script to add.</param>
        public void Add(ScriptComponent script)
        {
            script.Initialize(Services);
            registeredScripts.Add(script);

            // Register script for Start() and possibly async Execute()
            scriptsToStart.Add(script);

            // If it's a synchronous script, add it to the list as well
            if (script is SyncScript syncScript)
            {
                syncScript.UpdateSchedulerNode                    = Scheduler.Create(syncScript.Update, syncScript.Priority | UpdateBit);
                syncScript.UpdateSchedulerNode.Value.Token        = syncScript;
                syncScript.UpdateSchedulerNode.Value.ProfilingKey = syncScript.ProfilingKey;
                syncScripts.Add(syncScript);
            }
        }
            public void ReturnsExistingProperties()
            {
                var value = new object();

                var component = new ScriptComponent();
                component.SetScriptPropertyValue("test", value);

                Assert.AreSame(value, component.GetScriptPropertyValue("test"));
            }
 public void ReturnsNullWhenAPropertyDoesntExist()
 {
     var component = new ScriptComponent();
     Assert.IsNull(component.GetScriptPropertyValue("doesntExist"));
 }
            public void CallsShutdownOrSavingDependingOnContext(
				[Values(Component.ShutdownContext.Saving, Component.ShutdownContext.Deactivate)]Component.ShutdownContext context,
				[Values(false, true)]bool expectedShutdownResult,
				[Values(true, false)]bool expectedSavingResult)
            {
                var component = new ScriptComponent { Script = TestScriptFactory.CreateScriptResource(TestScriptWithShutdown) };

                component.OnInit(Component.InitContext.Activate);
                component.SetScriptPropertyValue("ShutdownCalled", false);
                component.SetScriptPropertyValue("SavingCalled", false);
                component.OnShutdown(context);

                ((ICmpEditorUpdatable)component).OnUpdate();

                Assert.AreEqual(expectedShutdownResult, (bool)component.ScriptPropertyValues["ShutdownCalled"]);
                Assert.AreEqual(expectedSavingResult, (bool)component.ScriptPropertyValues["SavingCalled"]);
            }
            public void ReturnsAValidCoroutineInstance()
            {
                var component = new ScriptComponent {Script = TestScriptFactory.CreateScriptResource(TestScriptWithCoroutine)};

                component.OnInit(Component.InitContext.Activate);
                var factory = Create.NewFactory();
                var coroutine = component.StartCoroutine<object>("Coroutine", factory);

                Assert.IsNotNull(coroutine);

                coroutine.Step();
                factory.Kernel.Step();
                Assert.AreEqual(1, coroutine.Value);

                factory.Kernel.Step();
                Assert.AreEqual(2, coroutine.Value);

                factory.Kernel.Step();
                Assert.AreEqual(3, coroutine.Value);
            }
 public void DoesntThrow()
 {
     var scriptComponent = new ScriptComponent();
     Assert.DoesNotThrow(() => scriptComponent.OnScriptReloaded(null, null));
 }
 public void SetUp()
 {
     Component = CreateScriptComponent();
 }