private static void OnStatActionMessage(ref StatActionMsg msg, MyNetworkClient sender) { if (msg.StatActions == null) { return; } MyEntity entity = null; if (!MyEntities.TryGetEntityById(msg.EntityId, out entity)) { return; } MyEntityStatComponent statComponent = null; if (!entity.Components.TryGet <MyEntityStatComponent>(out statComponent)) { return; } MyStatLogic script = new MyStatLogic(); script.Init(entity as IMyCharacter, statComponent.m_stats, "LocalStatActionScript"); foreach (var actionPair in msg.StatActions) { script.AddAction(actionPair.Key, actionPair.Value); } statComponent.m_scripts.Add(script); }
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 static void OnStatActionMessage(ref StatActionMsg msg, MyNetworkClient sender) { if (msg.StatActions == null) return; MyEntity entity = null; if (!MyEntities.TryGetEntityById(msg.EntityId, out entity)) return; MyEntityStatComponent statComponent = null; if (!entity.Components.TryGet<MyEntityStatComponent>(out statComponent)) return; MyStatLogic script = new MyStatLogic(); script.Init(entity as IMyCharacter, statComponent.m_stats, "LocalStatActionScript"); foreach(var actionPair in msg.StatActions) { script.AddAction(actionPair.Key, actionPair.Value); } statComponent.m_scripts.Add(script); }
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); }