private static void OnStatActionRequest(ref StatActionRequestMsg msg, MyNetworkClient sender) { Debug.Assert(Sync.IsServer); MyEntity entity = null; if (!MyEntities.TryGetEntityById(msg.EntityId, out entity)) { return; } MyEntityStatComponent statComponent = null; if (!entity.Components.TryGet <MyEntityStatComponent>(out statComponent)) { return; } StatActionMsg actionMsg = new StatActionMsg() { EntityId = msg.EntityId, StatActions = new Dictionary <string, MyStatLogic.MyStatAction>(), }; foreach (var script in statComponent.m_scripts) { foreach (var actionPair in script.StatActions) { actionMsg.StatActions.Add(actionPair.Key, actionPair.Value); } } MySession.Static.SyncLayer.SendMessage(ref actionMsg, sender.SteamUserId, MyTransportMessageEnum.Success); }
private void RequestStatActions() { StatActionRequestMsg msg = new StatActionRequestMsg() { EntityId = Entity.EntityId, }; MySession.Static.SyncLayer.SendMessageToServer(ref msg, MyTransportMessageEnum.Request); }
private static void OnStatActionRequest(ref StatActionRequestMsg msg, MyNetworkClient sender) { Debug.Assert(Sync.IsServer); MyEntity entity = null; if(!MyEntities.TryGetEntityById(msg.EntityId, out entity)) return; MyEntityStatComponent statComponent = null; if (!entity.Components.TryGet<MyEntityStatComponent>(out statComponent)) return; StatActionMsg actionMsg = new StatActionMsg() { EntityId = msg.EntityId, StatActions = new Dictionary<string, MyStatLogic.MyStatAction>(), }; foreach(var script in statComponent.m_scripts) { foreach(var actionPair in script.StatActions) { actionMsg.StatActions.Add(actionPair.Key, actionPair.Value); } } MySession.Static.SyncLayer.SendMessage(ref actionMsg, sender.SteamUserId, MyTransportMessageEnum.Success); }