Exemplo n.º 1
0
 private static void ToggleBeamAnimation(Workbench workbench, bool active)
 {
     workbench.GetData().animatingBeams = active;
     try
     {
         workbench.workingLight.SetActive(active);
         workbench.animator.SetBool(AnimatorHashID.working, active);
         var sparks = (GameObject[])sparksField.GetValue(workbench);
         var beams  = workbench.fxLaserBeam;
         for (var i = 0; i < beams.Length; i++)
         {
             beams[i].SetActive(active);
             var ps = sparks[i].GetComponent <ParticleSystem>();
             if (active)
             {
                 ps.Play();
             }
             else
             {
                 ps.Stop();
             }
         }
     }
     catch (Exception e) { AGLogger.ExceptionOnce(e); }
 }
Exemplo n.º 2
0
 private static bool TryCreateModParticleParams(Fabricator fabricator)
 {
     if (modParticlesParams != null)
     {
         return(true);
     }
     try
     {
         var sparksL = ((GameObject)sparksLFieldInfo.GetValue(fabricator)).GetComponent <ParticleSystem>();
         originParticlesParams = new ParticleSystemParameters()
         {
             startColor = sparksL.main.startColor
         };
         modParticlesParams = new ParticleSystemParameters()
         {
             startColor = Config.BeamAlphaColor
         };
         return(true);
     }
     catch (Exception e)
     {
         AGLogger.Exception(e);
         return(false);
     }
 }
Exemplo n.º 3
0
 private static bool TryCreateModParticleParams(Workbench workbench)
 {
     if (modParticlesParams != null)
     {
         return(true);
     }
     try
     {
         var sparks = ((GameObject[])sparksField.GetValue(workbench))[0].GetComponent <ParticleSystem>();
         originParticlesParams = new ParticleSystemParameters()
         {
             startColor = sparks.main.startColor
         };
         modParticlesParams = new ParticleSystemParameters()
         {
             startColor = Config.BeamAlphaColor
         };
         return(true);
     }
     catch (Exception e)
     {
         AGLogger.Exception(e);
         return(false);
     }
 }
Exemplo n.º 4
0
 private static void SetWorkbenchLightColor(Workbench workbench, Color color)
 {
     try
     {
         workbench.workingLight.GetComponent <Light>().color = color;
     }
     catch (Exception e) { AGLogger.Exception(e); }
 }
Exemplo n.º 5
0
 private static void SetFabricatorLightColor(Fabricator fabricator, Color color)
 {
     try
     {
         fabricator.fabLight.color = color;
     }
     catch (Exception e) { AGLogger.Exception(e); }
 }
Exemplo n.º 6
0
 private static void SetFabricatorBeamsMaterial(Fabricator fabricator, Material material)
 {
     try
     {
         fabricator.leftBeam.GetComponent <Renderer>().material  = material;
         fabricator.rightBeam.GetComponent <Renderer>().material = material;
     }
     catch (Exception e) { AGLogger.Exception(e); }
 }
Exemplo n.º 7
0
 private static void SetWorkbenchBeamsMaterial(Workbench workbench, Material material)
 {
     try
     {
         foreach (var beam in workbench.fxLaserBeam)
         {
             beam.GetComponent <Renderer>().material = material;
         }
     }
     catch (Exception e) { AGLogger.Exception(e); }
 }
Exemplo n.º 8
0
 private static void SetFabricatorParticlesParams(Fabricator fabricator, ParticleSystemParameters @params)
 {
     try
     {
         var sparksL = ((GameObject)sparksLFieldInfo.GetValue(fabricator)).GetComponent <ParticleSystem>();
         var sparksR = ((GameObject)sparksRFieldInfo.GetValue(fabricator)).GetComponent <ParticleSystem>();
         @params.Apply(sparksL);
         @params.Apply(sparksR);
     }
     catch (Exception e) { AGLogger.Exception(e); }
 }
Exemplo n.º 9
0
 private static void SetWorkbenchParticlesParams(Workbench workbench, ParticleSystemParameters @params)
 {
     try
     {
         var sparks = (GameObject[])sparksField.GetValue(workbench);
         foreach (var spark in sparks)
         {
             @params.Apply(spark.GetComponent <ParticleSystem>());
         }
     }
     catch (Exception e) { AGLogger.Exception(e); }
 }
Exemplo n.º 10
0
 static MaterialFix()
 {
     try
     {
         //var prefab = CraftData.GetPrefabForTechType(TechType.Workbench, true);
         var workbench = Resources.Load <GameObject>("Submarine/Build/Workbench").GetComponent <Workbench>();
         var material  = workbench.fxLaserBeam[0].GetComponent <Renderer>().sharedMaterial;
         var func      = AnimationFuncs.SinusoidalColor(min, max, frequency);
         var anim      = new ShaderColorPropertyAnimation(ShaderPropertyID._Color, func);
         anim.Play(material);
     }
     catch (Exception e) { AGLogger.Exception(e); }
 }
Exemplo n.º 11
0
                static BeamMaterial()
                {
                    try
                    {
                        var prefab = CraftData.GetPrefabForTechType(TechType.Workbench);
                        original = prefab.GetComponent <Workbench>().fxLaserBeam[0].GetComponent <Renderer>().sharedMaterial;
                        custom   = new Material(original);

                        var func = AnimationFuncs.SinusoidalColor(Config.BeamColor, Config.BeamAlphaColor, Config.BeamFrequency);
                        var anim = new ShaderColorPropertyAnimation(ShaderPropertyID._Color, func);
                        anim.Play(custom);
                    }
                    catch (Exception e) { AGLogger.Exception(e); }
                }
Exemplo n.º 12
0
 private static void UpdateAnimation(Workbench workbench)
 {
     try
     {
         var light = workbench.workingLight.GetComponent <Light>();
         light.intensity *= 2;
         var sparks     = (GameObject[])sparksField.GetValue(workbench);
         var beams      = workbench.fxLaserBeam;
         var spawnPoint = workbench.ghost.itemSpawnPoint;
         for (var i = 0; i < sparks.Length; i++)
         {
             var laser = beams[i].transform;
             sparks[i].transform.position = GetBeamEnd(laser.position, laser.forward, spawnPoint.position, spawnPoint.up);
         }
     }
     catch (Exception e) { AGLogger.ExceptionOnce(e); }
 }
Exemplo n.º 13
0
 private static bool TryCreateModLightColor(Workbench workbench)
 {
     if (originLightColor != null)
     {
         return(true);
     }
     try
     {
         originLightColor = workbench.workingLight.GetComponent <Light>().color;
         modLightColor    = Config.BeamColor;
         return(true);
     }
     catch (Exception e)
     {
         AGLogger.Exception(e);
         return(false);
     }
 }
Exemplo n.º 14
0
 private static bool TryCreateModLightColor(Fabricator fabricator)
 {
     if (originLightColor != null)
     {
         return(true);
     }
     try
     {
         originLightColor = fabricator.fabLight.color;
         modLightColor    = Config.BeamColor;
         return(true);
     }
     catch (Exception e)
     {
         AGLogger.Exception(e);
         return(false);
     }
 }
Exemplo n.º 15
0
            public void OnConsoleCommand_lgfind(NotificationCenter.Notification note)
            {
                if (note == null || note.data == null || note.data.Count == 0)
                {
                    return;
                }
                var pattern = (string)note.data[0];

                if (string.IsNullOrEmpty(pattern))
                {
                    return;
                }
                pattern = pattern.Replace('_', ' ');
                int maxTextSize = 128;

                if (note.data.Count > 1)
                {
                    int.TryParse((string)note.data[1], out maxTextSize);
                }

                ErrorMessage.AddMessage($"Searching for '{pattern}'...");
                var regex        = pattern == "-eng" ? onlyASCIIRegex : new Regex($"{Regex.Escape(pattern)}", RegexOptions.IgnoreCase);
                var searchResult = LanguageWrapper.FindAll(x => regex.IsMatch(x.Value));

                if (searchResult.Count > 0)
                {
                    ErrorMessage.AddMessage($"Found <color=#00FF00FF>{searchResult.Count}</color> strings. Check log for details.");
                    AGLogger.Message($"Searched '{pattern}'. Found {searchResult.Count} strings:");
                    ReportSearch(searchResult, maxTextSize);
                }
                else
                {
                    ErrorMessage.AddMessage($"Nothing found.");
                    AGLogger.Message($"Searched '{pattern}'. Nothing found.");
                }
            }