protected override MySyncEntity OnCreateSync() { var sync = new MySyncPistonBase(this); sync.SyncPosition = OnSyncPosition; return sync; }
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); }
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); }
static void OnSetMin(MySyncPistonBase sync, ref MinMsg msg, MyNetworkClient sender) { sync.Entity.MinLimit = msg.Min; }
static void OnSetMax(MySyncPistonBase sync, ref MaxMsg msg, MyNetworkClient sender) { sync.Entity.MaxLimit = msg.Max; }
static void OnSetVelocity(MySyncPistonBase sync, ref VelocityMsg msg, MyNetworkClient sender) { sync.Entity.Velocity = msg.Velocity; }
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); } }
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); } }
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); } }
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); } }