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);
        }
Exemplo n.º 3
0
        internal void AttachTop(MyPistonTop topBlock)
        {
            var msg = new AttachMsg();

            Debug.Assert(Entity != null, "null entity when attaching piston top !");
            Debug.Assert(topBlock != null, "null topBlock when attaching piston top !");

            if (Entity != null && topBlock != null)
            {
                msg.EntityId    = Entity.EntityId;
                msg.TopEntityId = topBlock.EntityId;

                Sync.Layer.SendMessageToAll(ref msg);
            }
            else
            {
                MySandboxGame.Log.WriteLine(string.Format("Failed to attach piston top ! Entity value :  {0} top block value : {1}", Entity, topBlock));
            }
        }