Beispiel #1
0
        public Script(ImaginaryObject scriptBase, HierarchyObject attachedTo = null)
        {
            if (!IsScript(((IGeneralImaginaryObject)scriptBase).TypeData.GetConstructionType()))
            {
                throw new ArgumentException("ScriptBase is not a Script!");
            }

            ScriptInstance = scriptBase.CreateInstance();

            ScriptType = ((IGeneralImaginaryObject)scriptBase).TypeData.GetConstructionType();

            if (ScriptType.IsHierarchyScript())
            {
                HierarchyScript.SetUp(ScriptInstance, attachedTo);
            }

            EventSystem.EventSystem.SubscribeEvents(ScriptType, ScriptInstance);
        }