예제 #1
0
        void AlertVerbose(string alertFormat, IPEndPoint endpoint, MyEventEnum eventType)
        {
            var    player     = MyMultiplayerPeers.Static[endpoint];
            string playerInfo = String.Format(" UserId: {0}, GameUserId: {1}, EndPoint: {2}", player.UserId, player.GameId, player.EndPoint);

            MyTrace.Send(TraceWindow.MultiplayerAlerts, eventType.ToString() + ": " + alertFormat + playerInfo);
        }
예제 #2
0
 public void place()
 {
     tapAction(currentPos.position, currentPos.rotation);
     MyTrace.trace(new List <string> {
         "place function executed"
     }, true);
 }
예제 #3
0
        private void UpdateTrace()
        {
            for (int i = 0; i < m_consumerDataByPriority.Length; ++i)
            {
                var data  = m_consumerDataByPriority[i];
                var group = (MyConsumerGroupEnum)i;
                MyTrace.Watch(String.Format("Data[{0}].AvailablePower", group), data.AvailablePower);
            }
            for (int i = 0; i < m_consumerDataByPriority.Length; ++i)
            {
                var data  = m_consumerDataByPriority[i];
                var group = (MyConsumerGroupEnum)i;
                MyTrace.Watch(String.Format("Data[{0}].RequiredInput", group), data.RequiredInput);
            }
            for (int i = 0; i < m_consumerDataByPriority.Length; ++i)
            {
                var data  = m_consumerDataByPriority[i];
                var group = (MyConsumerGroupEnum)i;
                MyTrace.Watch(String.Format("Data[{0}].IsPowerAdaptible", group), data.IsPowerAdaptible);
            }

            int j = 0;

            foreach (var group in m_producersByPriority)
            {
                foreach (var producer in group)
                {
                    ++j;
                    MyTrace.Watch(String.Format("Producer[{0}].IsTurnedOn", j), producer.Enabled);
                    MyTrace.Watch(String.Format("Producer[{0}].HasRemainingCapacity", j), producer.HasCapacityRemaining);
                    MyTrace.Watch(String.Format("Producer[{0}].CurrentPowerOutput", j), producer.CurrentPowerOutput);
                }
            }
        }
예제 #4
0
        private static void PackMothership()
        {
            MyTrace.Send(TraceWindow.Saving, "Player packing mothership");
            MyPrefabHangar hangar = MySession.Static.Player.Ship.GetNearMotherShipContainer();

            if (hangar == null)
            { //We are traveling in solar map but madelyn is far away. Assume we are travelling with Madelyn by default
                MyEntity madelynHangar;
                MyEntities.TryGetEntityByName(MyMission.MyMissionLocation.MADELYN_HANGAR, out madelynHangar);
                hangar = madelynHangar as MyPrefabHangar;
            }

            if (hangar != null)
            {
                // Move player start location dummy, so that next time player starts on same position
                UpdateStartDummy(MyDummyPointFlags.PLAYER_START, MySession.PlayerShip.WorldMatrix);

                // Move mothership start location dummy, so that next time mothership starts on same position
                UpdateStartDummy(MyDummyPointFlags.MOTHERSHIP_START, hangar.Parent.WorldMatrix);

                var             container = hangar.Parent;
                MyInventoryItem item      = MyInventory.CreateInventoryItemFromObjectBuilder(container.GetObjectBuilder(true));
                MySession.Static.Inventory.AddInventoryItem(item);

                container.MarkForClose();

                MyTrace.Send(TraceWindow.Saving, "Player mothership found and packed");
            }
        }
예제 #5
0
        private void AabbPhantom_CollidableRemoved(ref Havok.HkpCollidableRemovedEvent eventData)
        {
            var rb = eventData.RigidBody;

            if (rb == null) // ignore phantoms
            {
                return;
            }
            var entities = rb.GetAllEntities();

            foreach (var entity in entities)
            {
                var grid      = entity.Physics as MyGridPhysics;
                var character = entity.Physics as MyPhysicsBody;
                if (IsDynamicGrid(rb, grid) ||
                    IsCharacter(rb, character))
                {
                    using (m_nearbyEntitiesLock.AcquireExclusiveUsing())
                    {
                        if (character != null)
                        {
                            MyTrace.Send(TraceWindow.Analytics, string.Format("{0} Removed character", character.Entity.EntityId));
                        }
                        //unreliable
                        //Debug.Assert(m_nearbyEntities.Contains(entity), "Removing entity which was not added");
                        m_nearbyEntities.Remove(entity);
                    }
                }
            }
            entities.Clear();
        }
예제 #6
0
        static void Main(string[] args)
        {
            //Add listener by code. See App.config for configuration in XML.
            //Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
            //Debug.AutoFlush = true;

            //To add listeners for default tracing methods, config "listeners"
            //element under "trace" element in App.config.
            Trace.WriteLine("Call Trace.WriteLine");
            Console.WriteLine("I'm main!");
            Trace.TraceInformation("Call Trace.TraceInformation");
            Trace.TraceError("Call Trace.TraceError");

            //Trace with TraceSource in code. "MyTraceSource" is configed in
            //App.config.
            TraceSource ts = new TraceSource("MyTraceSource");

            ts.TraceEvent(TraceEventType.Information, 123, "My trace event.");
            ts.TraceEvent(TraceEventType.Error, 123, "My trace error event.");
            ts.Flush();
            ts.Close();

            //MyTrace uses the same "MyTraceSource" as above code. Attention:
            //there has to be <trace autoflush="true" ...> in App.config to
            //see the output from MyTrace.TraceInfo/Error, though it uses the
            //same "MyTraceSource" like the above code.
            MyTrace.TraceInfo("MyTrace works!");
            MyTrace.TraceError("MyTrace(error) works!");
        }
예제 #7
0
        void MyMultiplayerClient_ClientLeft(ulong user, ChatMemberStateChangeEnum stateChange)
        {
            if (user == ServerId)
            {
                RaiseHostLeft();
                return;
            }

            if (m_members.Contains(user))
            {
                m_members.Remove(user);

                MySandboxGame.Log.WriteLineAndConsole("Player disconnected: " + MySteam.API.Friends.GetPersonaName(user) + " (" + user + ")");

                MyTrace.Send(TraceWindow.Multiplayer, "Player disconnected: " + stateChange.ToString());

                if (MySandboxGame.IsGameReady && Sync.MyId != user)
                {
                    var clientLeft = new MyHudNotification(MyCommonTexts.NotificationClientDisconnected, 5000, level: MyNotificationLevel.Important);
                    clientLeft.SetTextFormatArguments(MySteam.API.Friends.GetPersonaName(user));
                    MyHud.Notifications.Add(clientLeft);
                }

                //Peer2Peer.CloseSession(user);
            }

            m_memberData.Remove(user);
        }
예제 #8
0
        public void UpdateOnServer()
        {
            if (!Sync.IsServer)
            {
                return;
            }

            RefreshHasRemainingCapacity();
            if (HasCapacityRemaining || PowerReceiver.RequiredInput > 0.0f)
            {
                int timePassed = MySandboxGame.TotalGamePlayTimeInMilliseconds - m_lastUpdateTime;
                m_lastUpdateTime = MySandboxGame.TotalGamePlayTimeInMilliseconds;
                float consumptionPerMillisecond = CurrentPowerOutput / (60 * 60 * 1000);
                float rechargePerMillisecond    = (MyFakes.ENABLE_BATTERY_SELF_RECHARGE ? PowerReceiver.MaxRequiredInput : PowerReceiver.CurrentInput) / (60 * 60 * 1000);
                float consumedEnergy            = (MySession.Static.CreativeMode) ? 0 : timePassed * consumptionPerMillisecond;
                float rechargedEnergy           = timePassed * rechargePerMillisecond;
                float newCapacity = RemainingCapacity;
                newCapacity      -= consumedEnergy;
                newCapacity      += rechargedEnergy;
                RemainingCapacity = MathHelper.Clamp(newCapacity, 0f, MyEnergyConstants.BATTERY_MAX_CAPACITY);
            }

            RefreshHasRemainingCapacity();
            //Moved to HudWarnings
            SyncObject.SendCapacitySync(m_owner, RemainingCapacity);

            if (false)
            {
                MyTrace.Watch("MyBattery.RequiredPowerInput", PowerReceiver.RequiredInput);
                MyTrace.Watch("MyBattery.CurrentPowerOutput", this.CurrentPowerOutput);
                MyTrace.Watch("MyBattery.CurrentPowerInput", PowerReceiver.CurrentInput);
                MyTrace.Watch("MyBattery.CurrentCapacity", this.RemainingCapacity);
            }
        }
예제 #9
0
        public static MyMultiplayerHostResult HostLobby(LobbyTypeEnum lobbyType, int maxPlayers, MySyncLayer syncLayer)
        {
            System.Diagnostics.Debug.Assert(syncLayer != null);
            MyTrace.Send(TraceWindow.Multiplayer, "Host game");

            MyMultiplayerHostResult ret = new MyMultiplayerHostResult();

#if !XB1
            SteamSDK.Lobby.Create(lobbyType, maxPlayers, (lobby, result) =>
            {
                if (!ret.Cancelled)
                {
                    if (result == Result.OK && lobby.GetOwner() != Sync.MyId)
                    {
                        result = Result.Fail;
                        lobby.Leave();
                    }

                    MyTrace.Send(TraceWindow.Multiplayer, "Lobby created");
                    lobby.SetLobbyType(lobbyType);
                    ret.RaiseDone(result, result == Result.OK ? MyMultiplayer.Static = new MyMultiplayerLobby(lobby, syncLayer) : null);
                }
            });
#endif
            return(ret);
        }
예제 #10
0
    public override void updateInternal()
    {
        MyTrace.trace(new List <string> {
            "Update"
        }, true);

        raycastManager.Raycast(new Vector2(Screen.width / 2, Screen.height / 2), m_hits_handle, TrackableType.Planes);

        Vector3 newCameraPos = camera1.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2, camera1.nearClipPlane));

        //cameraPos = Vector3.SmoothDamp(cameraPos, newCameraPos, ref velocity, smoothTime);

        cameraPos = newCameraPos;
        cameraPos = newCameraPos - camera1.transform.up * 0.1f;
        //cameraPos = newCameraPos + Vector3.back * 0.1f;

        float newShadowYpos = shadow.transform.position.y;

        if (m_hits_handle.Count > 0)
        {
            newShadowYpos = m_hits_handle[0].pose.position.y + 0.001f;
            newPos        = ((currentScroll / MaximumScrolls) * m_hits_handle[0].pose.position) + ((1.0f - (currentScroll / MaximumScrolls)) * cameraPos);
        }

        Vector3 newShadowPos = new Vector3(newPos.x, newShadowYpos, newPos.z);

        cubeHandle.transform.position = Vector3.SmoothDamp(cubeHandle.transform.position, newPos, ref velocity, smoothTime);
        shadow.transform.position     = Vector3.SmoothDamp(shadow.transform.position, newShadowPos, ref velocity2, smoothTime);

        Vector3 midpoint = cameraPos + ((cubeHandle.transform.position - cameraPos) / 2.0f) + (velocity * 0.1f);

        drawCurve(cameraPos, midpoint, cubeHandle.transform.position);

        currentPos = cubeHandle.transform;
    }
예제 #11
0
        private void CloseClient()
        {
            MyTrace.Send(TraceWindow.Multiplayer, "Multiplayer client closed");

            if (m_clientJoined)
            {
                MyControlDisconnectedMsg msg = new MyControlDisconnectedMsg();
                msg.Client = MySteam.UserId;

                SendControlMessage(ServerId, ref msg);
            }
            OnJoin = null;

            //TODO: Any better way? P2P needs to be closed from both sides. If closed right after Send, message
            //can stay not sent.
            Thread.Sleep(200);

            //WARN: If closed here, previous control message probably not come
            Peer2Peer.CloseSession(ServerId);

            CloseMemberSessions();

            Peer2Peer.ConnectionFailed -= Peer2Peer_ConnectionFailed;
            Peer2Peer.SessionRequest   -= Peer2Peer_SessionRequest;
        }
예제 #12
0
        private void AabbPhantom_CollidableRemoved(ref HkpCollidableRemovedEvent eventData)
        {
            var rb = eventData.RigidBody;

            if (rb == null) // ignore phantoms
            {
                return;
            }
            var entities = rb.GetAllEntities();

            foreach (var entity in entities)
            {
                var grid      = entity.Physics as MyGridPhysics;
                var character = entity.Physics as MyPhysicsBody;
                // RK: IsDynamicGrid(rb, grid) commented out because body can be changed to static after added to m_nearbyEntities, see method MyGridShape.UpdateShape,
                // before CreateConnectionToWorld(destructionBody) it can be static = false but after true!
                if ((grid != null && grid.RigidBody == rb) /*IsDynamicGrid(rb, grid)*/ ||
                    IsCharacter(rb, character))
                {
                    using (m_nearbyEntitiesLock.AcquireExclusiveUsing())
                    {
                        if (character != null)
                        {
                            MyTrace.Send(TraceWindow.Analytics, string.Format("{0} Removed character", character.Entity.EntityId));
                        }
                        //unreliable
                        //Debug.Assert(m_nearbyEntities.Contains(entity), "Removing entity which was not added");
                        m_nearbyEntities.Remove(entity);
                    }
                }
            }
            entities.Clear();
        }
예제 #13
0
        public static MyMultiplayerJoinResult JoinLobby(ulong lobbyId)
        {
            MyTrace.Send(TraceWindow.Multiplayer, "Join game");
            MyMultiplayerJoinResult ret = new MyMultiplayerJoinResult();

#if !XB1
            Lobby.Join(lobbyId, (info, result) =>
            {
                if (!ret.Cancelled)
                {
                    if (result == Result.OK && info.EnterState == LobbyEnterResponseEnum.Success && info.Lobby.GetOwner() == Sync.MyId)
                    {
                        // Joining lobby as server is dead-end, nobody has world. It's considered doesn't exists
                        info.EnterState = LobbyEnterResponseEnum.DoesntExist;
                        info.Lobby.Leave();
                    }

                    MyTrace.Send(TraceWindow.Multiplayer, "Lobby joined");
                    bool success = result == Result.OK && info.EnterState == LobbyEnterResponseEnum.Success;
                    ret.RaiseJoined(result, info, success ? MyMultiplayer.Static = new MyMultiplayerLobbyClient(info.Lobby, new MySyncLayer(new MyTransportLayer(MyMultiplayer.GameEventChannel))) : null);
                }
            });
#endif

            return(ret);
        }
예제 #14
0
        private void AabbPhantom_CollidableRemoved(ref Havok.HkpCollidableRemovedEvent eventData)
        {
            var rb = eventData.RigidBody;

            if (rb == null) // ignore phantoms
            {
                return;
            }

            var grid      = rb.UserObject as MyGridPhysics;
            var character = rb.UserObject as MyPhysicsBody;

            if (IsDynamicGrid(rb, grid) ||
                IsCharacter(rb, character))
            {
                using (m_nearbyEntitiesLock.AcquireExclusiveUsing())
                {
                    if (character != null)
                    {
                        MyTrace.Send(TraceWindow.Analytics, string.Format("{0} Removed character", character.Entity.EntityId));
                    }
                    IMyEntity entity = grid == null ? character.Entity : grid.Entity;
                    Debug.Assert(m_nearbyEntities.Contains(entity), "Removing entity which was not added");
                    m_nearbyEntities.Remove(entity);
                }
            }
        }
예제 #15
0
        private static void UnpackMothership()
        {
            MyTrace.Send(TraceWindow.Saving, "Player unpacking mothership");
            MyInventoryItem item = MySession.Static.Inventory.GetInventoryItem(MyMwcObjectBuilderTypeEnum.PrefabContainer, null);

            if (item != null)
            {
                //place largeship
                //MyMwcObjectBuilder_LargeShip largeShipObjectBuilder = (MyMwcObjectBuilder_LargeShip)inventoryItems[0].GetObjectBuilder(true);
                MyMwcObjectBuilder_PrefabContainer containerObjectBuilder =
                    (MyMwcObjectBuilder_PrefabContainer)item.GetInventoryItemObjectBuilder(true);

                // We need to remove id's because mothership container could have same entity id in different sector
                containerObjectBuilder.RemapEntityIds(new MyEntityIdRemapContext());

                MyPrefabContainer container = new MyPrefabContainer();
                container.Init(null, containerObjectBuilder, FindMothershipPosition());

                MyEntities.Add(container);

                //CreateFromObjectBuilderAndAdd(null, largeShipObjectBuilder, Matrix.CreateTranslation(MySession.PlayerShip.GetPosition() + new Vector3(100,100,0)));
                MySession.Static.Inventory.RemoveInventoryItem(item);

                container.Link();

                MyTrace.Send(TraceWindow.Saving, "Player mothership found and unpacked");
            }
        }
예제 #16
0
        void MyMultiplayerLobby_ClientLeft(ulong userId, ChatMemberStateChangeEnum stateChange)
        {
            Peer2Peer.CloseSession(userId);

            MySandboxGame.Log.WriteLineAndConsole("Player left: " + GetMemberName(userId) + " (" + userId + ")");
            MyTrace.Send(TraceWindow.Multiplayer, "Player left: " + stateChange.ToString());
        }
예제 #17
0
        private void LogMessage <T>(MyEventEnum eventType, T inst)
            where T : struct, IMyEvent
        {
            MyLoggingTypeEnum loggingType;

            if (m_loggedMessages.TryGetValue((int)eventType, out loggingType))
            {
                switch (loggingType)
                {
                case MyLoggingTypeEnum.NONE:
                    break;

                case MyLoggingTypeEnum.NAME:
                    MyTrace.Send(TraceWindow.Multiplayer, "Received event " + eventType.ToString() + ", from " + (inst.SenderEndpoint != null ? inst.SenderEndpoint.ToString() : "null"));
                    break;

                case MyLoggingTypeEnum.FULL:
                    MyTrace.Send(TraceWindow.Multiplayer, inst.ToString());
                    break;

                default:
                    break;
                }
            }
        }
예제 #18
0
 void Peer2Peer_ConnectionFailed(ulong remoteUserId, P2PSessionErrorEnum error)
 {
     MyTrace.Send(TraceWindow.Multiplayer, "Connection failed");
     State           = MyDownloadWorldStateEnum.ConnectionFailed;
     ConnectionError = error;
     Deregister();
     RaiseProgressChanged();
 }
예제 #19
0
        void Peer2Peer_ConnectionFailed(ulong remoteUserId, P2PSessionErrorEnum error)
        {
            MyTrace.Send(TraceWindow.Multiplayer, "Peer2Peer_ConnectionFailed (" + remoteUserId.ToString() + ")");

            if (remoteUserId == ServerId)
            {
                RaiseHostLeft();
            }
        }
예제 #20
0
        void Matchmaking_LobbyChatUpdate(Lobby lobby, ulong changedUser, ulong makingChangeUser, ChatMemberStateChangeEnum stateChange)
        {
            //System.Diagnostics.Debug.Assert(MySession.Static != null);

            if (lobby.LobbyId == Lobby.LobbyId)
            {
                if (stateChange == ChatMemberStateChangeEnum.Entered)
                {
                    MySandboxGame.Log.WriteLineAndConsole("Player entered: " + MySteam.API.Friends.GetPersonaName(changedUser) + " (" + changedUser + ")");
                    MyTrace.Send(TraceWindow.Multiplayer, "Player entered");
                    Peer2Peer.AcceptSession(changedUser);

                    RaiseClientJoined(changedUser);

                    if (MySandboxGame.IsGameReady && changedUser != ServerId)
                    {
                        var playerJoined = new MyHudNotification(MySpaceTexts.NotificationClientConnected, 5000, level: MyNotificationLevel.Important);
                        playerJoined.SetTextFormatArguments(MySteam.API.Friends.GetPersonaName(changedUser));
                        MyHud.Notifications.Add(playerJoined);
                    }
                }
                else
                {
                    // Kicked client can be already removed from Clients
                    if (Sync.Clients.HasClient(changedUser))
                    {
                        RaiseClientLeft(changedUser, stateChange);
                    }

                    if (changedUser == ServerId)
                    {
                        MyTrace.Send(TraceWindow.Multiplayer, "Host left: " + stateChange.ToString());
                        RaiseHostLeft();

                        MyGuiScreenMainMenu.UnloadAndExitToMenu();
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                   messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                                                   messageText: MyTexts.Get(MySpaceTexts.MultiplayerErrorServerHasLeft)));

                        // Set new server
                        //ServerId = Lobby.GetOwner();

                        //if (ServerId == Sync.MyId)
                        //{
                        //    Lobby.SetLobbyData(HostNameTag, Sync.MyName);
                        //}
                    }
                    else if (MySandboxGame.IsGameReady)
                    {
                        var playerLeft = new MyHudNotification(MySpaceTexts.NotificationClientDisconnected, 5000, level: MyNotificationLevel.Important);
                        playerLeft.SetTextFormatArguments(MySteam.API.Friends.GetPersonaName(changedUser));
                        MyHud.Notifications.Add(playerLeft);
                    }
                }
            }
        }
예제 #21
0
        public virtual void Dispose()
        {
            MyTrace.Send(TraceWindow.Multiplayer, "Multiplayer closed");
            m_voxelMapData = null;
            MyNetworkReader.ClearHandler(MyMultiplayer.ControlChannel);
            SyncLayer.TransportLayer.Clear();
            MyNetworkReader.Clear();

            MyMultiplayer.Static = null;
        }
예제 #22
0
        void AlertVerbose(string alertFormat, IPEndPoint endpoint, MyEventEnum eventType)
        {
            var player = Peers.Players.FirstOrDefault(p => p.Connection.RemoteEndpoint == endpoint);

            if (player != null)
            {
                string playerInfo = String.Format(" UserId: {0}, GameUserId: {1}, EndPoint: {2}", player.UserId, player.PlayerId, player.Connection.RemoteEndpoint);
                MyTrace.Send(TraceWindow.MultiplayerAlerts, eventType.ToString() + ": " + alertFormat + playerInfo);
            }
        }
 void LogPlayers()
 {
     MyMwcLog.WriteLine("PLAYER LOG:");
     foreach (var player in Peers.Players)
     {
         string message = String.Format("User: {0,4} - {1,15}, GameId: {2,3}, EP: {3}, {4}", player.UserId, player.GetDisplayName(), player.PlayerId, player.Connection.RemoteEndpoint, player.Faction);
         MyTrace.Send(TraceWindow.MultiplayerAlerts, message);
         MyMwcLog.WriteLine(message);
     }
 }
예제 #24
0
        public override MyDownloadWorldResult DownloadWorld()
        {
            MyTrace.Send(TraceWindow.Multiplayer, "World request sent");
            MyDownloadWorldResult ret = new MyDownloadWorldResult(MyMultiplayer.WorldDownloadChannel, Lobby.GetOwner(), this);

            MyControlWorldRequestMsg msg = new MyControlWorldRequestMsg();

            SendControlMessage(ServerId, ref msg);
            return(ret);
        }
예제 #25
0
    void TraceDisplayingUpdate()
    {
        // プレイ履歴を再生している状態。

        // 履歴がなくなったら、再生を終了。初期状態(Served)へ戻る。
        if (Trace.Count == 0)
        {
            FinishPlayback();
        }
        else
        {
            // 操作履歴の先頭のデータ(最も古い)を取り出す。
            MyTrace tr = Trace[0];

            // 前回履歴を表示してからの時刻に再生スピードをかけたものと
            // 履歴の中でたった時間を比較。
            while (traceTimeElapsed >= tr.time && Trace.Count > 0)  // time to go?
            {
                tr = Trace[0];
                // Playback用のラケットを移動
                MoveGameObject(playbackRacket, tr.racketPos);
                // Playback用のラケットの方向を変更
                RotateGameObject(playbackRacket, tr.racketDir);
                // Playback用のボールを移動
                MoveGameObject(playbackBall, tr.ballPos);

                // 軌跡の表示
                playbackBallTrace.Add(CreateBallTrace(tr.ballPos));
                if (playbackBallTrace.Count > playbackMaxNumberOfBallTrace)
                {
                    Destroy(playbackBallTrace[0]);
                    playbackBallTrace.RemoveAt(0);
                }
                foreach (GameObject trace in playbackBallTrace)
                {
                    Color    colorFade = new Color(0, 0, 0, 1.0f / playbackMaxNumberOfBallTrace);
                    Renderer renderer  = trace.GetComponent <Renderer>();
                    if (renderer.material.color.a > 0)
                    {
                        renderer.material.color -= colorFade;
                    }
                }

                // ボールとラケットを結ぶ線
                // LineRenderer lr = playbackLine.GetComponent<LineRenderer>();
                // lr.SetPosition(0, tr.ballPos);
                // lr.SetPosition(1, tr.racketCenterPos);

                // 履歴の先頭を削除
                Trace.RemoveAt(0);
            }
            traceTimeElapsed += Time.deltaTime * GetPlayBackSpeed();
        }
    }
예제 #26
0
        void MyDownloadWorldResult_Received(byte[] data, int dataSize, ulong sender, TimeSpan timestamp)
        {
            ProfilerShort.Begin("DownloadWorldChunk");

            Debug.Assert(State == MyDownloadWorldStateEnum.Established || State == MyDownloadWorldStateEnum.InProgress, "This should not be called, find why it's called");
            if (m_sender == sender)
            {
                var status = m_receiveMsg.Compose(data, dataSize);
                switch (status)
                {
                case MyMultipartMessage.Status.InProgress:
                    break;

                case MyMultipartMessage.Status.Finished:
                    Deregister();

                    m_receiveMsg.Stream.Position = 0;
                    if (m_receiveMsg.Stream.Length > 0)
                    {
                        MyObjectBuilder_World worldData;
                        if (Sandbox.Common.ObjectBuilders.Serializer.MyObjectBuilderSerializer.DeserializeGZippedXML(m_receiveMsg.Stream, out worldData))
                        {
                            WorldData = worldData;
                            State     = MyDownloadWorldStateEnum.Success;

                            MySandboxGame.Log.WriteLineAndConsole(String.Format("World download progress status: {0}, {1}", State.ToString(), this.Progress));
                        }
                        else
                        {
                            MySandboxGame.Log.WriteLine("Deserialization failed during world download.");
                            State = MyDownloadWorldStateEnum.DeserializationFailed;
                        }
                    }
                    else
                    {
                        State = MyDownloadWorldStateEnum.WorldNotAvailable;
                    }
                    break;

                case MyMultipartMessage.Status.Error:
                    Deregister();
                    MySandboxGame.Log.WriteLine("Invalid packet header.");
                    State = MyDownloadWorldStateEnum.InvalidMessage;
                    break;
                }

                m_mp.SendAck(sender);

                MyTrace.Send(TraceWindow.Multiplayer, String.Format("World download progress status: {0}, {1}", State.ToString(), this.Progress));
                RaiseProgressChanged();
            }

            ProfilerShort.End();
        }
        public void WriteTrace()
        {
            var smallShips = SectorObjects.OfType <MyMwcObjectBuilder_SmallShip>();

            MyTrace.Indent(TraceWindow.Saving, "SmallShips");
            foreach (var smallShip in smallShips)
            {
                MyTrace.Send(TraceWindow.Saving, smallShip.DisplayName);
            }
            MyTrace.UnIndent(TraceWindow.Saving);
        }
예제 #28
0
 private void DeactivatePhantom()
 {
     if (ENABLE_AABB_PHANTOM)
     {
         MyTrace.Send(TraceWindow.Analytics, "RemovePhantom-before");
         HavokWorld.RemovePhantom(m_aabbPhantom);
         MyTrace.Send(TraceWindow.Analytics, "RemovePhantom-after");
         Debug.Assert(m_nearbyEntities.Count == 0, "Inconsistent entities management");
         m_nearbyEntities.Clear();
     }
 }
예제 #29
0
        public void Receive()
        {
            NetIncomingMessage msg;

            while ((msg = this.ReadMessage()) != null)
            {
                if (msg.MessageType == NetIncomingMessageType.StatusChanged)
                {
                    var status = (NetConnectionStatus)msg.PeekByte();
                    if (status == NetConnectionStatus.Connected)
                    {
                        RaisePeerConnected(msg.SenderConnection);
                        if (msg.SenderConnection.RemoteHailMessage != null)
                        {
                            var hailMsg = msg.SenderConnection.RemoteHailMessage;
                            hailMsg.m_senderConnection = msg.SenderConnection;
                            hailMsg.m_senderEndpoint   = msg.SenderEndpoint;
                            // Recycle hail msg inside
                            OnMessageReceived(hailMsg);
                        }
                        // Process send queue
                        ProcessQueue();
                    }
                    else if (status == NetConnectionStatus.Disconnected)
                    {
                        RaisePeerDisconnected(msg.SenderConnection);
                    }
                    Recycle(msg);
                }
                else if (msg.MessageType == NetIncomingMessageType.NatIntroductionSuccess)
                {
                    RaiseNatIntroductionSuccess(msg.SenderEndpoint, msg.ReadString());
                    Recycle(msg);
                }
                else if (msg.MessageType == NetIncomingMessageType.Data)
                {
                    // Recycle inside
                    OnMessageReceived(msg);
                }
                else if (
                    //msg.MessageType == NetIncomingMessageType.DebugMessage ||
                    msg.MessageType == NetIncomingMessageType.WarningMessage ||
                    msg.MessageType == NetIncomingMessageType.ErrorMessage)
                {
                    var text = msg.ReadString();
                    MyTrace.Send(TraceWindow.MultiplayerAlerts, text);
                    Recycle(msg);
                }
                else
                {
                    Recycle(msg);
                }
            }
        }
예제 #30
0
        public void TravelLeave(MyMwcTravelTypeEnum travelType)
        {
            MyTrace.Send(TraceWindow.Saving, "Player.TravelLeave()");
            var handler = TravelLeaving;

            if (handler != null)
            {
                handler(travelType);
            }

            PackBeforeLeave(travelType);
        }