示例#1
0
        public override void SimulateFixedUpdateAlways()
        {
            if (!StatMaster.isClient)
            {
                SetParams(Vector3.Lerp(displacement, Rigidbody.position, 0.2f), Vector3.Lerp(velocity, Rigidbody.velocity, 0.2f), Vector3.Lerp(rotation, Rigidbody.rotation.eulerAngles, 0.2f));
            }
            if (StatMaster.isMP && StatMaster.isHosting)
            {
                Message syncc = Messages.PilotPanelSync.CreateMessage(Block.From(this), displacement, velocity, rotation);
                ModNetworking.SendTo(Machine.Player, syncc);
            }
            direction  = transform.forward;
            horizontal = new Vector3(-direction.z / direction.x, 0f, 1f).normalized;

            T1 = Time.time;
            dt = Time.fixedDeltaTime;

            if (disp)
            {
                vel0     = vel1;
                vel1     = velocity;
                acce     = (vel1.magnitude - vel0.magnitude) / dt;
                overload = (Vector3.Dot((vel1 - vel0), this.transform.up) / dt + (float)38.5 * Vector3.Dot(Vector3.up, this.transform.up)) / (float)38.5;

                alt       = displacement.y;
                climbrate = velocity.y;

                pitch = 90 - Mathf.Acos((2 - (direction - Vector3.up).magnitude * (direction - Vector3.up).magnitude) / 2) / Mathf.PI * 180;
                yaw   = rotation.y;
                roll  = Mathf.Sign(direction.x) * (Mathf.Acos((2 - (horizontal - this.transform.up).magnitude * (horizontal - this.transform.up).magnitude) / 2) / Mathf.PI * 180 - 90);
            }
        }
示例#2
0
 private void SendClientTargetNull()
 {
     if (StatMaster.isHosting)
     {
         Message rocketTargetNullMsg = Messages.rocketTargetNullMsg.CreateMessage(parentBlock);
         Player  player1             = Player.GetAllPlayers().Find(player => player.NetworkId == parentBlock.ParentMachine.PlayerID);
         if (player1 != null)
         {
             ModNetworking.SendTo(player1, rocketTargetNullMsg);
         }
         ModNetworking.SendToAll(Messages.rocketLostTargetMsg.CreateMessage(parentBlock));
     }
     RocketsController.Instance.RemoveRocketTarget(parentBlock);
 }
示例#3
0
        public JsValue Print(JsValue thiz, JsValue[] x)
        {
            if (x.Length == 0)
            {
                return(null);
            }

            if (Time.time - lastPrint < 1)
            {
                if (printCount >= 50)
                {
                    if (printCount == 50)
                    {
                        ++printCount;
                        Debug.LogWarning($"Warning: cpu is emitting too may log lines, cool down");
                    }
                    return(null);
                }
            }
            else
            {
                printCount = 0;
                lastPrint  = Time.time;
            }
            ++printCount;
            var logLine     = PrintObject(x[0], 0);
            var blockPlayer = BlockBehaviour.ParentMachine == null ? null : Player.From(BlockBehaviour.ParentMachine.PlayerID);

            if (blockPlayer == null || blockPlayer.IsHost)
            {
                LogMessage(logLine);
            }
            else
            {
                // send log to client's machine
                var message = ModContext.CpuLogMessage.CreateMessage(
                    BlockBehaviour,
                    logLine
                    );
                ModNetworking.SendTo(blockPlayer, message);
            }
            return(null);
        }
 public void SendRocketFired()
 {
     if (!removedFromGroup)
     {
         if (StatMaster.isHosting)
         {
             Message rocketFiredMsg = Messages.rocketFiredMsg.CreateMessage(BB);
             ModNetworking.SendTo(Player.GetAllPlayers().Find(player => player.NetworkId == rocket.ParentMachine.PlayerID), rocketFiredMsg);
         }
         if (RocketsController.Instance.playerGroupedRockets.TryGetValue(StatMaster.isMP ? rocket.ParentMachine.PlayerID : 0, out Dictionary <KeyCode, HashSet <TimedRocket> > groupedRockets))
         {
             if (groupedRockets.TryGetValue(GroupFireKey.GetKey(0), out HashSet <TimedRocket> rockets))
             {
                 rockets.Remove(rocket);
             }
         }
         removedFromGroup = true;
     }
 }