bool IEnumerator.MoveNext()
            {
                switch (this.__1__state)
                {
                case 0:
                    this.__1__state = -1;
                    goto IL_17A;

                case 2:
                    this.__1__state = -1;
                    if (!this._busy_5__a)
                    {
                        goto IL_149;
                    }
                    goto IL_79;

                case 3:
                    this.__1__state = -1;
                    goto IL_179;
                }
                bool result = false;

                return(result);

IL_79:
                try
                {
                    Profiler.BeginSample("ApplyCombinedMesh_" + this._step_5__b++);
                    this._busy_5__a = this._current_5__9.Value.MoveNext();
                    Profiler.EndSample();
                }
                catch (Exception ex)
                {
                    Log.LogException(this.__4__this, ex);
                    ComponentExtensions.DestroyIfInstance(this._current_5__9.Key.Mesh);
                    ComponentExtensions.DestroyIfInstance(this._current_5__9.Key.Atlas);
                    this._current_5__9.Key.Mesh  = null;
                    this._current_5__9.Key.Atlas = null;
                    goto IL_149;
                }
                this.__2__current = true;
                this.__1__state   = 2;
                result            = true;
                return(result);

IL_149:
                this._current_5__9.Key.Finished = true;
IL_179:
IL_17A:
                if (this.__4__this.queue.Count > 0)
                {
                    this._current_5__9 = this.__4__this.queue.Dequeue();
                    this._step_5__b    = 0;
                    goto IL_79;
                }
                this.__2__current = false;
                this.__1__state   = 3;
                result            = true;
                return(result);
            }
        private void modifyMaterials(Color bodyColor)
        {
            Shader   shader   = Shader.Find("CpRemix/Particles/Unlit Color");
            Material material = new Material(shader);

            material.color = bodyColor;
            SkinnedMeshRenderer[] componentsInChildren = penguin.GetComponentsInChildren <SkinnedMeshRenderer>();
            for (int i = 0; i < componentsInChildren.Length; i++)
            {
                Material sharedMaterial = componentsInChildren[i].sharedMaterial;
                if (sharedMaterial != null)
                {
                    if (sharedMaterial.shader.name == AvatarService.EquipmentPreviewShader.name)
                    {
                        sharedMaterial.shader = AvatarService.EquipmentScreenshotShader;
                    }
                    else
                    {
                        ComponentExtensions.DestroyIfInstance(componentsInChildren[i].sharedMaterial);
                        componentsInChildren[i].sharedMaterial = material;
                    }
                }
                else
                {
                    Log.LogErrorFormatted(this, "Null material in {0}", componentsInChildren[i].name);
                }
                componentsInChildren[i].updateWhenOffscreen = true;
            }
        }
Exemple #3
0
        public unsafe void Execute <TCtx>(TCtx ctx, InputTriggerPort port) where TCtx : IGraphInstance
        {
            var entity = ctx.ReadEntity(Entity);

            if (entity == Unity.Entities.Entity.Null)
            {
                return;
            }

            if (!ctx.EntityManager.HasComponent <PhysicsMass>(entity) || !ctx.EntityManager.HasComponent <PhysicsVelocity>(entity))
            {
                return;
            }

            PhysicsMass     physicsMass     = ctx.EntityManager.GetComponentData <PhysicsMass>(entity);
            PhysicsVelocity physicsVelocity = ctx.EntityManager.GetComponentData <PhysicsVelocity>(entity);

            if (LinearOnly)
            {
                physicsVelocity.ApplyLinearImpulse(physicsMass, ctx.ReadFloat3(Value));
            }
            else
            {
                Translation t = ctx.EntityManager.GetComponentData <Translation>(entity);
                Rotation    r = ctx.EntityManager.GetComponentData <Rotation>(entity);

                ComponentExtensions.ApplyImpulse(ref physicsVelocity, physicsMass, t, r, ctx.ReadFloat3(Value), ctx.ReadFloat3(Point));
            }

            ctx.EntityManager.SetComponentData(entity, physicsVelocity);
        }
Exemple #4
0
 private void setupRenderer()
 {
     ComponentExtensions.DestroyIfInstance(rend.sharedMaterial);
     rend.sharedMaterial = meshDef.CreateCombinedMaterial(combineRequest.Atlas);
     meshDef.ApplyMesh(base.gameObject, combineRequest.Mesh);
     rend.enabled = true;
 }
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        float dt = Time.DeltaTime;

        JobHandle myJob = Entities.ForEach((ref PhysicsVelocity vel, in PhysicsMass mass, in MotionComponent motion) => {
            ComponentExtensions.ApplyLinearImpulse(ref vel, mass, motion.direction * motion.speed * dt);
        }).Schedule(inputDeps);
Exemple #6
0
 public static void DefaultReleaseDelegate(T value, List <UnityEngine.Object> subObjects)
 {
     ComponentExtensions.DestroyResource(value);
     foreach (UnityEngine.Object subObject in subObjects)
     {
         ComponentExtensions.DestroyResource(subObject);
     }
 }
 public void OnDestroy()
 {
     if (m_Material != null)
     {
         ComponentExtensions.DestroyIfInstance(m_Material);
         m_Material = null;
     }
 }
Exemple #8
0
        public void Release(TKey key)
        {
            Item item = cache[key];

            item.RefCount--;
            if (!item.Permanent && item.RefCount <= 0 && ValueReleaser(key, item.Value))
            {
                ComponentExtensions.DestroyResource(item.Value);
                cache.Remove(key);
            }
        }
Exemple #9
0
        protected override void OnLevelLoaded(int levelIndex)
        {
            base.OnLevelLoaded(levelIndex);

            BrandAdElements.Clear();
            BrandAdElements = ComponentExtensions.FindObjectsOfTypeIncludingInactive <BrandAdElement>();

            if (AutoInitialize)
            {
                Initialize();
            }
        }
Exemple #10
0
 private void adjustSkybox()
 {
     if (SkyboxMaterialKey != null && !string.IsNullOrEmpty(SkyboxMaterialKey.Key))
     {
         Texture mainTexture = RenderSettings.skybox.mainTexture;
         RenderSettings.skybox.mainTexture = null;
         ComponentExtensions.DestroyResource(mainTexture);
         Content.LoadAsync(delegate(string path, Material material)
         {
             onScheduledSkyboxLoaded(material);
         }, SkyboxMaterialKey);
     }
 }
        public void CleanUp(GameObject go)
        {
            Renderer component = go.GetComponent <Renderer>();

            if (component != null)
            {
                ComponentExtensions.DestroyIfInstance(component.sharedMaterial);
                if (this.MeshDef != null)
                {
                    this.MeshDef.CleanUp(go);
                }
            }
        }
Exemple #12
0
        public void SetupRenderer(GameObject gameObject, DceModel model, ref Renderer rend)
        {
            if (rend == null)
            {
                rend = MeshDef.CreateRenderer(gameObject);
            }
            Material material = GetMaterial();

            ApplyMaterialProperties(material);
            ComponentExtensions.DestroyIfInstance(rend.sharedMaterial);
            rend.sharedMaterial = material;
            MeshDef.ApplyMesh(gameObject);
        }
Exemple #13
0
        private bool isAssociatedControl = false;    // Controlを指定したインスタンス化を実施したかどうか

        // FIXED
        /// <summary>
        /// 新しい AutoCompleteBox インスタンスを生成します。
        /// </summary>
        public AutoCompleteBox()
        {
            this.CompareOptions = this.defaultCompareOptions;

            if (ComponentExtensions.IsDesignMode(this))
            {
                return;
            }

            // 必要なイベントを設定
            this.candidateBox.SelectedValueChanged += CandidateBox_SelectedValueChanged;
            this.candidateBox.CandidateBoxClosed   += CandidateBox_CandidateBoxClosed;
        }
        private void InitializeScenes()
        {
            //get all initializers
            var allInitializers = new List <INIT001_Initialize>(ComponentExtensions.FindAllComponentsOfType <INIT001_Initialize>());

            //initialize all initializers
            foreach (var initializer in allInitializers)
            {
                if (initializer.initOn == INIT001_Initialize.InitOn.SceneStart)
                {
                    initializer.StartInitialization();
                }
            }
        }
Exemple #15
0
 private void swapMaterials()
 {
     materialsToSwap = new List <ScheduledSwapMaterialData>();
     ScheduledSwapMaterialData[] swapMaterialData = SwapMaterialData;
     foreach (ScheduledSwapMaterialData scheduledSwapMaterialData in swapMaterialData)
     {
         Renderer component = scheduledSwapMaterialData.SwapTarget.GetComponent <Renderer>();
         if (component != null)
         {
             if (scheduledSwapMaterialData.SwapMaterialKey != null && !string.IsNullOrEmpty(scheduledSwapMaterialData.SwapMaterialKey.Key))
             {
                 materialsToSwap.Add(scheduledSwapMaterialData);
             }
             else
             {
                 Log.LogError(this, $"Error: {base.gameObject.GetPath()} has a Swap Material data field with a null material entry");
             }
         }
         else
         {
             Log.LogError(this, $"Error: {base.gameObject.GetPath()} has a no renderer component attached");
         }
     }
     if (materialsToSwap.Count <= 0)
     {
         return;
     }
     Service.Get <LoadingController>().AddLoadingSystem(this);
     swapMaterialsLoadTimer = new Stopwatch();
     swapMaterialsLoadTimer.Start();
     foreach (ScheduledSwapMaterialData item in materialsToSwap)
     {
         Renderer component   = item.SwapTarget.GetComponent <Renderer>();
         Material material    = component.material;
         Texture  mainTexture = component.material.mainTexture;
         component.material.mainTexture = null;
         component.material             = null;
         if (item.DestroyTexture)
         {
             ComponentExtensions.DestroyResource(mainTexture);
         }
         ComponentExtensions.DestroyResource(material);
         if (Content.TryLoadImmediate(out var result, item.SwapMaterialKey))
         {
             component.material = result;
         }
     }
     Service.Get <LoadingController>().RemoveLoadingSystem(this);
     swapMaterialsLoadTimer.Stop();
 }
Exemple #16
0
        public IEnumerator StartingTaskOnDisabledComponentThrows()
        {
            var go   = new GameObject("TestGameObject");
            var comp = go.AddComponent <MockComponent>();

            // Disable the component.
            comp.enabled = false;

            Assert.Throws <InactiveComponentException>(() => ComponentExtensions.StartTask(comp, () => Task.CompletedTask));

            // Cleanup.
            yield return(null);

            Object.Destroy(go);
        }
Exemple #17
0
        public IEnumerator CreatingRunnerOnDestroyedComponentThrows()
        {
            var go   = new GameObject("TestGameObject");
            var comp = go.AddComponent <MockComponent>();

            Object.DestroyImmediate(comp);

            Assert.Throws <MissingReferenceException>(() => ComponentExtensions.GetTaskRunner(comp));
            Assert.Throws <MissingReferenceException>(() => ComponentExtensions.StartTask(comp, () => Task.CompletedTask));

            // Cleanup.
            yield return(null);

            Object.Destroy(go);
        }
        public override void CleanUp(GameObject go)
        {
            ComponentExtensions.DestroyIfInstance(getSharedMesh(go));
            setSharedMesh(go, null);
            Material sharedMaterial = getSharedMaterial(go);

            if ((bool)sharedMaterial)
            {
                if (sharedMaterial.HasProperty("_MainTex"))
                {
                    ComponentExtensions.DestroyIfInstance(sharedMaterial.mainTexture);
                }
                ComponentExtensions.DestroyIfInstance(sharedMaterial);
                setSharedMaterial(go, null);
            }
        }
 private void setSkybox(MaterialContentKey skyboxMaterialKey)
 {
     if (skyboxMaterialKey != null && !string.IsNullOrEmpty(skyboxMaterialKey.Key))
     {
         Texture mainTexture = RenderSettings.skybox.mainTexture;
         if (mainTexture != null)
         {
             RenderSettings.skybox.mainTexture = null;
             ComponentExtensions.DestroyResource(mainTexture);
         }
         Content.LoadAsync(delegate(string path, Material material)
         {
             onSkyboxLoaded(material);
         }, skyboxMaterialKey);
     }
 }
        public void SetupRenderer(GameObject gameObject, AvatarModel model, ref Renderer rend)
        {
            if (rend == null)
            {
                rend = this.MeshDef.CreateRenderer(gameObject);
                model.Definition.RenderProperties.Apply(rend);
            }
            Material material = this.GetMaterial(false);
            BodyColorMaterialProperties bodyColorMaterialProperties = new BodyColorMaterialProperties(model.BeakColor, model.BellyColor, model.BodyColor);

            bodyColorMaterialProperties.Apply(material);
            this.ApplyMaterialProperties(material);
            ComponentExtensions.DestroyIfInstance(rend.sharedMaterial);
            rend.sharedMaterial = material;
            this.MeshDef.ApplyMesh(gameObject, null);
        }
Exemple #21
0
        public void LoadGameState()
        {
            Debug.Log("Start loading game @ frame #" + Time.frameCount + " / time: " + DateTime.Now.TimeOfDay);

            // Clean up & prepare
            loadingPrepared = false;
            loadedBodyData  = new SaveFile_BodyData();
            initializers.Clear();

            // 0. Read file and convert Json
            string fileContent = System.IO.File.ReadAllText(saveGameFilePath); // read file from disk

            // 1. Deserialize
            SaveFileSerializer.Deserialize("Head", fileContent, encryptSaveFile, ref HeadData);
            SaveFileSerializer.Deserialize("Body", fileContent, encryptSaveFile, ref loadedBodyData);

            // 2. Create ScriptableObject Instances and load data into them
            foreach (var data in loadedBodyData.scriptableObjectDatas)
            {
                LoadScriptableObject(data);
            }

            Debug.Log("Loaded all scriptableObjects @ frame #" + Time.frameCount + " / time: " + DateTime.Now.TimeOfDay);

            // 3. All Guids auf bestehenden Objekten initialisieren
            GuidManager.InitializeGuidComponents();
            Debug.Log("Initialized all GuidComponents @ frame #" + Time.frameCount + " / time: " + DateTime.Now.TimeOfDay);

            // 4. Load Components
            List <SaveableComponent> components = ComponentExtensions.FindAllComponentsOfType <SaveableComponent>();

            foreach (var componentData in loadedBodyData.componentDatas)
            {
                var component = FindSaveableComponentByGuid(componentData.Id, components);
                if (component != null)
                {
                    component.RestoreData(componentData);
                }
            }

            // 5. Cleanup
            Resources.UnloadUnusedAssets();

            // 6. Loading complete
            Debug.Log("Loading complete @ frame #" + Time.frameCount + " / time: " + DateTime.Now.TimeOfDay);
        }
Exemple #22
0
    protected override void OnUpdate()
    {
        if (GameManager.Instance.IsRunning())
        {
            var dt        = Time.DeltaTime;
            var inputData = EntityManager.GetComponentData <CharacterControllerInput>(GetSingletonEntity <CharacterControllerInput>());

            var move = new float3(inputData.Movement.x, inputData.Jumped ? 1 : 0, inputData.Movement.y);
            move *= multiplier * dt;
            inputData.Movement = float2.zero;
            Entities.WithAll <PlayerTagComponent>().ForEach(
                (ref PhysicsVelocity _physicsVelocity, ref PhysicsMass _physicsMass) =>
            {
                ComponentExtensions.ApplyLinearImpulse(ref _physicsVelocity, _physicsMass, move);
            });
        }
    }
Exemple #23
0
        private static void LoadExtensions(RazorProjectEngineBuilder builder, IReadOnlyList <RazorExtension> extensions)
        {
            for (var i = 0; i < extensions.Count; i++)
            {
                // For now we only handle AssemblyExtension - which is not user-constructable. We're keeping a tight
                // lid on how things work until we add official support for extensibility everywhere. So, this is
                // intentionally inflexible for the time being.
                if (extensions[i] is AssemblyExtension extension)
                {
                    var initializer = extension.CreateInitializer();
                    initializer?.Initialize(builder);
                }
            }

            // Default extensions.
            ComponentExtensions.Register(builder);
        }
Exemple #24
0
 protected override void cleanup()
 {
     meshDef.CleanUp(base.gameObject);
     ComponentExtensions.DestroyIfInstance(rend.sharedMaterial);
     rend.enabled = false;
     if (partsRequest != null)
     {
         outfitService.Unload(partsRequest);
         partsRequest = null;
     }
     if (decalsRequest != null)
     {
         outfitService.Unload(decalsRequest);
         decalsRequest = null;
     }
     combineRequest = null;
 }
Exemple #25
0
        public void ReleaseAll()
        {
            List <TKey> list = new List <TKey>();

            foreach (KeyValuePair <TKey, Item> item in cache)
            {
                if (!item.Value.Permanent && item.Value.RefCount <= 0 && ValueReleaser(item.Key, item.Value.Value))
                {
                    ComponentExtensions.DestroyResource(item.Value.Value);
                    list.Add(item.Key);
                }
            }
            for (int i = 0; i < list.Count; i++)
            {
                cache.Remove(list[i]);
            }
        }
Exemple #26
0
 protected override void cleanup()
 {
     this.meshDef.CleanUp(base.gameObject);
     ComponentExtensions.DestroyIfInstance(this.rend.sharedMaterial);
     this.rend.enabled = false;
     if (this.partsRequest != null)
     {
         this.outfitService.Unload <EquipmentViewDefinition>(this.partsRequest);
         this.partsRequest = null;
     }
     if (this.decalsRequest != null)
     {
         this.outfitService.Unload <Texture2D>(this.decalsRequest);
         this.decalsRequest = null;
     }
     this.combineRequest = null;
 }
Exemple #27
0
        // FIXED
        /// <summary>
        /// 新しい AutoCompleteBox インスタンスを生成します。
        /// </summary>
        /// <param name="control">利用するコントロール。</param>
        public AutoCompleteBox(Control control)
        {
            this.CompareOptions = this.defaultCompareOptions;

            // 紐づくコントロールを保持
            this.TargetControl       = control;
            this.isAssociatedControl = true;

            if (ComponentExtensions.IsDesignMode(this))
            {
                return;
            }

            // 必要なイベントを設定
            this.candidateBox.SelectedValueChanged += CandidateBox_SelectedValueChanged;
            this.candidateBox.CandidateBoxOpened   += CandidateBox_CandidateBoxOpened;
            this.candidateBox.CandidateBoxClosed   += CandidateBox_CandidateBoxClosed;
        }
        private static void WriteErrorsFromJob(IBuildQueueJob job)
        {
            var componentEnvoy = job.AssociatedEnvoy;
            IEnumerable <MessageInfo> errors;

            if (ComponentExtensions.ComponentHasBuildOrCompileErrors(componentEnvoy, out errors))
            {
                CommandLineInterfaceApplication.WriteError(CreateComponentBuildErrorMessage(componentEnvoy.Name.Last, errors.ToList()));
            }
            else
            {
                CommandLineInterfaceApplication.WriteError(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        LocalizedStrings.BuildComponentTool_BuildFailedWithoutErrorMessages,
                        componentEnvoy.Name.Last));
            }
        }
Exemple #29
0
 private IEnumerator <bool> fibre()
 {
     while (true)
     {
         if (queue.Count > 0)
         {
             KeyValuePair <Request, IEnumerator> current = queue.Dequeue();
             int  step = 0;
             bool busy;
             do
             {
                 try
                 {
                     int num;
                     step = (num = step) + 1;
                     Profiler.BeginSample("ApplyCombinedMesh_" + num);
                     busy = current.Value.MoveNext();
                     Profiler.EndSample();
                 }
                 catch (Exception ex)
                 {
                     Log.LogException(this, ex);
                     ComponentExtensions.DestroyIfInstance(current.Key.Mesh);
                     ComponentExtensions.DestroyIfInstance(current.Key.Atlas);
                     current.Key.Mesh  = null;
                     current.Key.Atlas = null;
                     break;
                 }
                 yield return(true);
             }while (busy);
             current.Key.Finished = true;
         }
         else
         {
             yield return(false);
         }
     }
 }
Exemple #30
0
        public void DestroyPhone()
        {
            if (LinphoneCore != null)
            {
                RegistrationStateChangedEvent?.Invoke(LinphoneRegistrationState.LinphoneRegistrationProgress);

                CallModule.linphone_core_terminate_all_calls(LinphoneCore);

                var proxySetDownTask = ComponentExtensions.ExecuteWithDelay(() =>
                {
                    if (ProxieModule.linphone_proxy_config_is_registered(ProxyCfg))
                    {
                        ProxieModule.linphone_proxy_config_edit(ProxyCfg);
                        ProxieModule.linphone_proxy_config_enable_register(ProxyCfg, false);
                        ProxieModule.linphone_proxy_config_done(ProxyCfg);
                    }
                }, Constants.LC_CORE_PROXY_DISABLE_TIMEOUT);

                proxySetDownTask.Wait(Constants.LC_CORE_PROXY_DISABLE_TIMEOUT);

                IsRunning = ProxieModule.linphone_proxy_config_is_registered(ProxyCfg);
            }
        }