Esempio n. 1
0
        public override void SimulateFixedUpdateAlways()
        {
            // Things that are really need to be synced
            ReactivationTimer += Time.fixedDeltaTime * (flashing && DirectionVisualization.IsActive? 5 : 1);

            FieldSize = 2 * CloakFieldSize.Value;

            if (Activated)
            {
                size = FieldSize * Mathf.Min(ReactivationTimer, CloakExtendingTime.Value) / CloakExtendingTime.Value;
            }
            else
            {
                size = FieldSize * (1 - Mathf.Min(ReactivationTimer, CloakExtendingTime.Value) / CloakExtendingTime.Value);
            }

            if (flashing && DirectionVisualization.IsActive && ReactivationTimer >= CloakExtendingTime.Value)
            {
                flashing          = false;
                ReactivationTimer = 0;
            }

            CloakSizeModifier(size, flashing);
            // Bumped here to reduce network cost
            if (bumpFixedUpdate)
            {
                Message cloakInfoP = Messages.CloakProgress.CreateMessage(Block.From(this), size, Activated, ReactivationTimer, this.transform.position, flashing);
                ModNetworking.SendInSimulation(cloakInfoP);
            }
            bumpFixedUpdate = !bumpFixedUpdate;
        }
Esempio n. 2
0
        public override void OnSimulateStart()
        {
            // This will be execute on host's BlockScript
            Initialization();
            // Therefore message will be sent from here to let all other clients' cloak block to initialize
            Message cloakStarted = Messages.CloakSimuStart.CreateMessage(Block.From(this));

            ModNetworking.SendInSimulation(cloakStarted);
        }
Esempio n. 3
0
 public override void SimulateUpdateAlways()
 {
     if (!StatMaster.isClient)
     {
         laserAtOff = HoldingToEmit.IsActive ? !LaserOnOffKey.IsDown : laserAtOff;
         if (LaserOnOffKey.IsReleased)
         {
             laserAtOff = HoldingToEmit.IsActive ? true : !laserAtOff;
         }
         laserFX = EffectActivateKey.IsDown;
     }
     UpdateThingy();
     if (StatMaster.isMP && !StatMaster.isClient)
     {
         Message laserInfoP = Messages.LaserProgress.CreateMessage(Block.From(this), laserAtOff, laserFX, LaserLength, BeamHitAnything, this.Rigidbody.velocity);
         ModNetworking.SendInSimulation(laserInfoP);
     }
 }
Esempio n. 4
0
        public override void OnSimulateStart()
        {
            string ShaderString = UseNotTrans.IsActive ? "Legacy Shaders/Reflective/Bumped Specular" : "Particles/Additive";

            rHInfos = new List <RHInfo>();

            Especially = new GameObject("TheThings");

            if (!UseLegacy.IsActive)
            {
                CINU  = new CheckIfNeeeeeeedsUpdate(CheckIfNeedsUpdate);
                CTRGO = new GameObject("CubeTube");

                if (CTR == null)
                {
                    CTR = CTRGO.AddComponent <CustomTubeRenderer>();
                    //CTR.material = new Material(Shader.Find("Particles/Alpha Blended"));
                    //CTR.crossSegments = 1;
                    CTR.flatAtDistance = 1;
                    CTR.maxRebuildTime = 0.01f;
                }


                CTRGO.transform.SetParent(transform);
                CTRGO.transform.localPosition = Vector3.forward * 1.1f;
                CTRGO.transform.rotation      = transform.rotation;
            }
            else
            {
                CINU = new CheckIfNeeeeeeedsUpdate(LegacyCheckIfNeedsUpdate);
                if (lr == null)
                {
                    lr = this.gameObject.AddComponent <LineRenderer>();
                }
                lr.material          = new Material(Shader.Find(ShaderString));
                lr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                lr.SetWidth(0.08f, 0.08f);

                Color ArgColour = LaserColourSlider.Value;

                lr.SetColors(Color.Lerp(ArgColour, Color.black, 0.45f),
                             Color.Lerp(ArgColour, Color.clear, 0.2f));
                lr.SetVertexCount(0);
            }

            Especially.transform.SetParent(this.transform);
            Especially.transform.localPosition = Vector3.forward * 1.1f;
            Especially.transform.LookAt(this.transform.position);

            //lr.material.SetColors(Color.Lerp(ArgColour, Color.black, 0.45f),
            //    Color.Lerp(ArgColour, Color.clear, 0.2f));



            laserAtOff = !LaserOnOffToggle.IsActive;

            PointLight            = Especially.AddComponent <Light>();
            PointLight.color      = LaserColourSlider.Value;
            PointLight.intensity  = 3 * Math.Max(0.25f, PenetrativeLengthMultiplier.Value);
            PointLight.range      = Mathf.Max(this.transform.localScale.x, this.transform.localScale.y) * LaserWidth.Value * 3f;
            PointLight.shadows    = LightShadows.Soft;
            TheToggleProvideLight = LightOptionToggle.IsActive ? 1 : 0;
            if (ShrinkEffectToggle.IsActive && !PSR)
            {
                PS = Especially.AddComponent <ParticleSystem>();
                ParticleSystem.Particle NewParticle = new ParticleSystem.Particle();
                PS.startSize     = 0.2f;
                PS.startColor    = new Color(LaserColourSlider.Value.r, LaserColourSlider.Value.g, LaserColourSlider.Value.b, 0.5f);
                PS.startLifetime = ChargeHoldGasp.Value * 0.45f;
                PS.startSpeed    = -0.5f;
                PS.scalingMode   = ParticleSystemScalingMode.Shape;
                PS.SetParticles(new ParticleSystem.Particle[] { NewParticle }, 1);

                ParticleSystem.ColorOverLifetimeModule PSCOLM = PS.colorOverLifetime;
                PSCOLM.color = new Gradient()
                {
                    alphaKeys = new GradientAlphaKey[] { new GradientAlphaKey(0, 0), new GradientAlphaKey(0.8f, 0.2f), new GradientAlphaKey(1, 1) }, colorKeys = new GradientColorKey[] { new GradientColorKey(PS.startColor, 0), new GradientColorKey(PS.startColor, 1) }
                };
                PSCOLM.enabled = true;

                PS.simulationSpace = ParticleSystemSimulationSpace.World;

                //ParticleSystem.Burst BUTS = new ParticleSystem.Burst(10, 10, 1000);

                PSR = Especially.GetComponent <ParticleSystemRenderer>();
                //PSR.material = new Material(Shader.Find("Particles/Alpha Blended"));
                PSR.material             = new Material(Shader.Find(ShaderString));
                PSR.material.mainTexture = (ModResource.GetTexture("LaserParticle.png"));
            }
            if (StatMaster.isMP && !StatMaster.isClient)
            {
                Message laserSimu = Messages.LaserSimuStart.CreateMessage(Block.From(this));
                ModNetworking.SendInSimulation(laserSimu);
            }
        }