Beispiel #1
0
 protected void SetInteractiveState(ChemicalElementEntity e, ChemicalMaterialEntity m, PhysicalStateEntity p)
 {
     this.status.state   = p;
     this.status.element = e;
     this.material       = m;
 }
        public void WarmUp()
        {
            this.ClearAll();

            Type t;

            Type[] types;

            ChemicalElementEntity     element;
            PhysicalInteractionEntity interaction;
            InteractiveStatus         status;

            ChemicalElementEntity[]  elements;
            ChemicalMaterialEntity[] materials;
            PhysicalStateEntity[]    states;

            object[] parameters;



            t     = typeof(ChemicalElementEntity);
            types = Assembly.GetAssembly(t).GetExportedTypes().Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(t)).ToArray();

            parameters = new object[] { 0f };

            elements = new ChemicalElementEntity[types.Length];
            for (int i = 0; i < elements.Length; ++i)
            {
                elements[i] = Activator.CreateInstance(types[i], parameters) as ChemicalElementEntity;
            }



            t     = typeof(ChemicalMaterialEntity);
            types = Assembly.GetAssembly(t).GetTypes().Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(t)).ToArray();

            materials = new ChemicalMaterialEntity[types.Length];
            for (int i = 0; i < materials.Length; ++i)
            {
                materials[i] = t.GetField(types[i].Name.ToLower()).GetValue(null) as ChemicalMaterialEntity;
            }


            t     = typeof(PhysicalStateEntity);
            types = Assembly.GetAssembly(t).GetTypes().Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(t)).ToArray();

            states = new PhysicalStateEntity[types.Length];
            for (int i = 0; i < states.Length; ++i)
            {
                states[i] = t.GetField(types[i].Name.ToLower()).GetValue(null) as PhysicalStateEntity;
            }



            float start = Time.realtimeSinceStartup;

            // ELEMENT * ELEMENT
            for (int i = 0; i < elements.Length; ++i)
            {
                for (int j = i; j < elements.Length; ++j)
                {
                    element = elements[i] * elements[j];
                }
            }

            // ELEMENT * MATERIAL
            for (int i = 0; i < elements.Length; ++i)
            {
                for (int j = 0; j < materials.Length; ++j)
                {
                    element = elements[i] * materials[j];
                }
            }

            // ELEMENT * STATE
            for (int i = 0; i < elements.Length; ++i)
            {
                for (int j = 0; j < states.Length; ++j)
                {
                    status = elements[i] * states[j];
                }
            }


            // STATE * STATE
            for (int i = 0; i < states.Length; ++i)
            {
                for (int j = i; j < states.Length; ++j)
                {
                    interaction = states[i] * states[j];
                }
            }

            Debug.Log($"Took {Time.realtimeSinceStartup - start} seconds");

            // INSPECTOR
            this.inspector_showDetails = new bool[this.primaries.Count];
        }