Exemplo n.º 1
0
        private static void OnAttach(MySyncPistonBase sync, ref AttachMsg msg, MyNetworkClient sender)
        {
            MyPistonBase pistonBase  = (MyPistonBase)sync.Entity;
            MyEntity     rotorEntity = null;

            if (!MyEntities.TryGetEntityById(msg.TopEntityId, out rotorEntity))
            {
                pistonBase.RetryAttach(msg.TopEntityId);
                Debug.Assert(false, "Could not find top entity to attach to base");
                return;
            }
            MyPistonTop top = (MyPistonTop)rotorEntity;

            Debug.Assert(pistonBase.CubeGrid != top.CubeGrid, "Trying to attach top to base on the same grid");

            if (top.CubeGrid.InScene == false)
            {
                pistonBase.RetryAttach(msg.TopEntityId);
            }
            else
            {
                pistonBase.Attach(top, false);
            }

            if (Sync.IsServer)
            {
                Sync.Layer.SendMessageToAllButOne(ref msg, sender.SteamUserId);
            }
        }
Exemplo n.º 2
0
        private static void OnAttach(MySyncPistonBase sync, ref AttachMsg msg, MyNetworkClient sender)
        {
            MyPistonBase pistonBase  = (MyPistonBase)sync.Entity;
            MyEntity     rotorEntity = null;

            if (!MyEntities.TryGetEntityById(msg.TopEntityId, out rotorEntity))
            {
                Debug.Assert(false, "Could not find top entity to attach to base");
                return;
            }
            MyPistonTop top = (MyPistonTop)rotorEntity;

            Debug.Assert(pistonBase.CubeGrid != top.CubeGrid, "Trying to attach top to base on the same grid");

            pistonBase.Attach(top);
        }