Esempio n. 1
0
 protected override MySyncEntity OnCreateSync()
 {
     var sync = new MySyncPistonBase(this);
     sync.SyncPosition = OnSyncPosition;
     return sync;
 }
Esempio 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);
        }
Esempio n. 3
0
 static void OnSetCurrentPosition(MySyncPistonBase sync, ref CurrentPositionMsg msg, MyNetworkClient sender)
 {
     var grid = sync.Entity.CubeGrid;
     if (grid.Physics == null || grid.MarkedForClose || sync.Entity.MarkedForClose)
         return;
     sync.SyncPosition(msg.CurrentPosition);
 }
Esempio n. 4
0
 static void OnSetMin(MySyncPistonBase sync, ref MinMsg msg, MyNetworkClient sender)
 {
     sync.Entity.MinLimit = msg.Min;
 }
Esempio n. 5
0
 static void OnSetMax(MySyncPistonBase sync, ref MaxMsg msg, MyNetworkClient sender)
 {
     sync.Entity.MaxLimit = msg.Max;
 }
Esempio n. 6
0
 static void OnSetVelocity(MySyncPistonBase sync, ref VelocityMsg msg, MyNetworkClient sender)
 {
     sync.Entity.Velocity = msg.Velocity;
 }
Esempio n. 7
0
        static void OnSetCurrentPosition(MySyncPistonBase sync, ref CurrentPositionMsg msg, MyNetworkClient sender)
        {
            var grid = sync.Entity.CubeGrid;
            if (grid.Physics == null || grid.MarkedForClose || sync.Entity.MarkedForClose)
                return;
            sync.SyncPosition(msg.CurrentPosition);

            if (Sync.IsServer)
            {
                Sync.Layer.SendMessageToAllButOne(ref msg, sender.SteamUserId);
            }
        }
Esempio n. 8
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);
            }
        }
Esempio n. 9
0
 static void OnSetMax(MySyncPistonBase sync, ref MaxMsg msg, MyNetworkClient sender)
 {
     sync.Entity.MaxLimit = msg.Max;
     if (Sync.IsServer)
     {
         Sync.Layer.SendMessageToAllButOne(ref msg, sender.SteamUserId);
     }
 }
Esempio n. 10
0
 static void OnSetVelocity(MySyncPistonBase sync, ref VelocityMsg msg, MyNetworkClient sender)
 {
     sync.Entity.Velocity = msg.Velocity;
     if (Sync.IsServer)
     {
         Sync.Layer.SendMessageToAllButOne(ref msg, sender.SteamUserId);
     }
 }