public override void OnInspectorGUI() { base.OnInspectorGUI(); if (!EditorApplication.isPlaying) { EditorGUILayout.HelpBox("Available during runtime only.", MessageType.Info); return; } EventComponent t = (EventComponent)target; if (PrefabUtility.GetPrefabType(t.gameObject) != PrefabType.Prefab) { EditorGUILayout.LabelField("Event Count", t.Count.ToString()); } Repaint(); }
protected override void OnEnter(ProcedureOwner procedureOwner) { base.OnEnter(procedureOwner); // 获取框架事件组件 EventComponent Event = UnityGameFramework.Runtime.GameEntry.GetComponent <EventComponent> (); Event.Subscribe(WebRequestSuccessEventArgs.EventId, OnWebRequestSuccess); Event.Subscribe(WebRequestFailureEventArgs.EventId, OnWebRequestFailure); // 获取框架网络组件 WebRequestComponent WebRequest = UnityGameFramework.Runtime.GameEntry.GetComponent <WebRequestComponent> (); string url = "http://gameframework.cn/starforce/version.txt"; WebRequest.AddWebRequest(url, this); }
public static void CreateEvent(object sender, EventComponent target, T eventArgs) { // Always log the event. Even if it was 'Invalid' LogEvent(sender, target, eventArgs); // We don't create the event if the sender is null if (sender == null) { return; } if (target == null) { CreateGlobalEvent(sender, eventArgs); } else { CreateInstanceEvent(sender, target, eventArgs); } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); if (!EditorApplication.isPlaying) { EditorGUILayout.HelpBox("Available during runtime only.", MessageType.Info); return; } EventComponent t = (EventComponent)target; if (IsPrefabInHierarchy(t.gameObject)) { EditorGUILayout.LabelField("Event Handler Count", t.EventHandlerCount.ToString()); EditorGUILayout.LabelField("Event Count", t.EventCount.ToString()); } Repaint(); }
protected internal override void OnEnter(IFsm <IProcedureManager> procedureOwner) { base.OnEnter(procedureOwner); // 获取框架事件组件 EventComponent Event = UnityGameFramework.Runtime.GameEntry.GetComponent <EventComponent>(); Event.Subscribe(NetworkConnectedEventArgs.EventId, OnConnected); // 获取框架网络组件 NetworkComponent Network = UnityGameFramework.Runtime.GameEntry.GetComponent <NetworkComponent>(); // 创建频道 m_NetworkChannelHelper = new NetworkChannelHelper(); m_Channel = Network.CreateNetworkChannel("testName", ServiceType.Tcp, m_NetworkChannelHelper); // 连接服务器 m_Channel.Connect(IPAddress.Parse("127.0.0.1"), 8098); }
private static void CreateInstanceEvent(object sender, EventComponent target, T eventArgs) { SortedList <int, List <EventCallback> > instance; // Check there are actually listeners registered for this target. // It's okay if there are none. We just don't do anything if (InstanceListeners.TryGetValue(target, out instance)) { foreach (var listenerGroup in instance) { // Cache values so they don't create constant lookups List <EventCallback> callbacks = listenerGroup.Value; int callbackCount = callbacks.Count; // For loop is slightly faster than foreach for (int i = 0; i < callbackCount; i++) { callbacks[i]?.Invoke(eventArgs); } } } }
// Use this for initialization void Start() { _eventComponent = GameEntry.GetComponent <EventComponent>(); _baseComponent = GameEntry.GetComponent <BaseComponent>(); _resourceComponent = GameEntry.GetComponent <ResourceComponent>(); if (!_baseComponent) { Debug.LogError("Base component is invalid."); return; } if (!_baseComponent.EditorResourceMode) { _resourceComponent.SetResourceMode(ResourceMode.Package); var eventArgs = ReferencePool.Acquire <UnityGameFramework.Runtime.ResourceInitCompleteEventArgs>(); _eventComponent.Subscribe(eventArgs.Id, _loadAsset); ReferencePool.Release(eventArgs); _resourceComponent.InitResources(); } else { _load(); } }
public bool CheckAllRequirements(EventComponent ec) { switch (ec.Type) { case EventComponentType.RequiresStatus: if (CheckStatus(ec.StringParams)) { return(true); } break; case EventComponentType.RequiresNotStatus: if (!CheckStatus(ec.StringParams)) { return(true); } break; default: return(true); } return(false); }
public void ClosestEvent(List <EventComponent> oClosestEvents, List <int> oClosestQueueIndices) { oClosestEvents.Clear(); oClosestQueueIndices.Clear(); semaphore.WaitOne(); EventComponent closestEvent = null; //находим ближайший по времени ивент closestEvent = getMinEvent(eventQueue); if (closestEvent != null) { //добавляем ивенты с временен как у ближайшего for (int i = 0; i < eventQueue.Count; i++) { if (eventQueue[i].GetTime() == closestEvent.GetTime()) { oClosestEvents.Add(eventQueue[i]); oClosestQueueIndices.Add(i); } } } semaphore.Release(); }
private static void InitBuiltinComponents() { Base = UnityGameFramework.Runtime.GameEntry.GetComponent <BaseComponent>(); Config = UnityGameFramework.Runtime.GameEntry.GetComponent <ConfigComponent>(); DataNode = UnityGameFramework.Runtime.GameEntry.GetComponent <DataNodeComponent>(); DataTable = UnityGameFramework.Runtime.GameEntry.GetComponent <DataTableComponent>(); Debugger = UnityGameFramework.Runtime.GameEntry.GetComponent <DebuggerComponent>(); Download = UnityGameFramework.Runtime.GameEntry.GetComponent <DownloadComponent>(); Entity = UnityGameFramework.Runtime.GameEntry.GetComponent <EntityComponent>(); Event = UnityGameFramework.Runtime.GameEntry.GetComponent <EventComponent>(); //EventDispatcher.Instance;// Fsm = UnityGameFramework.Runtime.GameEntry.GetComponent <FsmComponent>(); Localization = UnityGameFramework.Runtime.GameEntry.GetComponent <LocalizationComponent>(); Network = UnityGameFramework.Runtime.GameEntry.GetComponent <NetworkComponent>(); ObjectPool = UnityGameFramework.Runtime.GameEntry.GetComponent <ObjectPoolComponent>(); Procedure = UnityGameFramework.Runtime.GameEntry.GetComponent <ProcedureComponent>(); Resource = UnityGameFramework.Runtime.GameEntry.GetComponent <ResourceComponent>(); Scene = UnityGameFramework.Runtime.GameEntry.GetComponent <SceneComponent>(); Setting = UnityGameFramework.Runtime.GameEntry.GetComponent <SettingComponent>(); Sound = UnityGameFramework.Runtime.GameEntry.GetComponent <SoundComponent>(); UI = UnityGameFramework.Runtime.GameEntry.GetComponent <UIComponent>(); WebRequest = UnityGameFramework.Runtime.GameEntry.GetComponent <WebRequestComponent>(); Utils.EventDispatcher.InitEventDefine(); Debug.LogError(ActorEventDefine.Attack); }
protected override void OnEnter(ProcedureOwner procedureOwner) { base.OnEnter(procedureOwner); // 启动服务器(服务端的代码随便找随便改的,大家可以忽略,假设有个服务端就行了) Demo8_SocketServer.Start(); // 获取框架事件组件 EventComponent Event = UnityGameFramework.Runtime.GameEntry.GetComponent <EventComponent> (); Event.Subscribe(NetworkConnectedEventArgs.EventId, OnConnected); // 获取框架网络组件 NetworkComponent Network = UnityGameFramework.Runtime.GameEntry.GetComponent <NetworkComponent> (); // 创建频道 m_NetworkChannelHelper = new NetworkChannelHelper(); m_Channel = Network.CreateNetworkChannel("testName", m_NetworkChannelHelper); // 连接服务器 m_Channel.Connect(IPAddress.Parse("127.0.0.1"), 8098); }
public void AddEvent(EventComponent evt) { semaphore.WaitOne(); eventQueue.Add(evt); semaphore.Release(); }
private void Start() { this.eventComponent = this.GetEventComponent(); TestInstanceEvent.RegisterListener(int.MaxValue, this.eventComponent, this.TestCallback); }
/// <summary> /// updates a given event in the database /// </summary> public void UpdateEvent(Season season, EventComponent anEvent) { throw new NotImplementedException(); }
/// <summary> /// Add components to a given composite. /// </summary> public void AddComponentsToComposite(Season season, EventsComposite composite, EventComponent[] components) { throw new NotImplementedException(); }
public EventsComposite(EventComponent[] eventComponents) { _eventComponents = eventComponents; }
public static void CreateEvent <T>(this MonoBehaviour monoBehaviour, EventComponent target, T eventArgs) { Event <T> .CreateEvent(new MonobehaviourMetadata(monoBehaviour), target, eventArgs); }
/// <summary> /// Adds an EventComponent /// </summary> /// <param name="newEvent">EventComponent</param> public void AddEvent(EventComponent newEvent) { newEvent.TableID = tableID++; events.Add(newEvent); }
public void SetUp() { kim = new Account("Kim", "Kim", "[email protected]", false); ole = new Account("Ole", "Ole", "[email protected]", false); pia = new Account("Pia", "Pia", "[email protected]", false); EventComponent[] events = new EventComponent[5]; events[0] = new EventLeaf("Event1", "A description", DateTime.Parse("11-11-11"), DateTime.Parse("11-11-12"), kim, new Account[] { }, new INotification[] { }); events[1] = new EventLeaf("", "", DateTime.Parse("11-11-10"), DateTime.Parse("11-11-11"), ole, new[] { kim}, new INotification[] { new Notification(DateTime.Parse("11-11-9"), false)}); events[2] = new EventLeaf("Event3", "A description", DateTime.Parse("11-11-11"), DateTime.Parse("11-11-12"), kim, new[] { kim, ole}, new INotification[] { }); events[3] = new EventLeaf("Event4", "A description", DateTime.Parse("11-11-11"), DateTime.Parse("11-11-12"), ole, new[] { kim, ole, pia }, new INotification[] { }); events[4] = new EventLeaf("Event5", "A description", DateTime.Parse("11-11-9"), DateTime.Parse("11-11-13"), pia, new Account[] { }, new INotification[] { new Notification(DateTime.Parse("11-11-9"), false)}); Event1 = events[0]; Event2 = events[1]; EventComposite e1 = new EventComposite("Compo1", "A grup description",kim, new IAccount[0]); e1.eventComponents = new EventComponent[] {events[0], events[1]}; Event3 = e1; EventComposite e2 = new EventComposite("Compo2", "A grup description", ole, new IAccount[0]); e2.eventComponents = new EventComponent[] {}; Event4 = e2; EventComposite e3 = new EventComposite("Compo3", "A grup description", kim, new IAccount[0]); e3.eventComponents = new EventComponent[] { events[0], events[1], events[2], events[3], events[4] }; Event5 = e3; EventComposite e4 = new EventComposite("Compo4", "A grup description2", pia, new IAccount[0]); e4.eventComponents = new EventComponent[] { e1, e3 }; Event6 = e4; }
public string GetSharedEventLink(EventComponent @event) { throw new NotImplementedException(); }
static void Main(string[] args) { // Setting up logging BaseLogger logger; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { logger = new WindowsLogger("RealTimeKql", "RealTimeKql"); } else { logger = new ConsoleLogger(); } if (!logger.Setup()) { Console.WriteLine("Error instantiating logger. Terminating program..."); return; } logger.Log(LogLevel.INFORMATION, "Welcome to Real-Time KQL!"); // Parsing command line arguments var commandLineParser = new CommandLineParser(logger, args); if (!commandLineParser.Parse()) { logger.Log(LogLevel.ERROR, "Problem parsing command line arguments. Terminating program..."); return; } else if (commandLineParser.InputSubcommand == null) { // User called help, terminating program return; } // Setting up output method IOutput output = null; if (commandLineParser.OutputSubcommand == null) { output = new ConsoleJsonOutput(logger); } switch (commandLineParser.OutputSubcommand.Name) { case "json": output = GetJsonOutput(logger, commandLineParser.OutputSubcommand); break; case "table": output = new ConsoleTableOutput(logger); break; case "adx": output = GetAdxOutput(logger, commandLineParser.OutputSubcommand.Options); break; case "blob": output = GetBlobOutput(logger, commandLineParser.OutputSubcommand.Options); break; case "eventlog": output = GetEventLogOutput(logger, commandLineParser.OutputSubcommand.Options); break; default: logger.Log(LogLevel.ERROR, $"ERROR! Problem recognizing output method specified: {commandLineParser.OutputSubcommand.Name}"); return; } // Setting up event component EventComponent eventComponent = null; var arg = commandLineParser.InputSubcommand.Argument?.Value; var options = commandLineParser.InputSubcommand.Options; var queries = commandLineParser.Queries.ToArray(); switch (commandLineParser.InputSubcommand.Name) { case "etw": eventComponent = new EtwSession(arg, output, queries); break; case "etl": eventComponent = new EtlFileReader(arg, output, queries); break; case "winlog": eventComponent = new WinlogRealTime(arg, output, queries); break; case "evtx": eventComponent = new EvtxFileReader(arg, output, queries); break; case "csv": eventComponent = new CsvFileReader(arg, output, queries); break; case "syslog": eventComponent = new SyslogFileReader(arg, output, queries); break; case "syslogserver": eventComponent = GetSyslogServer(options, output, queries); break; default: logger.Log(LogLevel.ERROR, $"Problem recognizing input method specified: {commandLineParser.InputSubcommand.Name}. Terminating program..."); return; } if (!eventComponent.Start()) { logger.Log(LogLevel.ERROR, "Error starting up. Please review usage and examples. Terminating program..."); return; } // Waiting for exit signal var exitEvent = new ManualResetEvent(false); Console.CancelKeyPress += (sender, eventArgs) => { eventArgs.Cancel = false; exitEvent.Set(); }; exitEvent.WaitOne(); }
/// <summary> /// 初始化网络频道辅助器。 /// </summary> /// <param name="networkChannel">网络频道。</param> public void Initialize(INetworkChannel networkChannel) { m_NetworkChannel = networkChannel; // 反射注册包和包处理函数。 Type packetBaseType = typeof(SCPacketBase); Type CSpacketBaseType = typeof(CSPacketBase); Type packetHandlerBaseType = typeof(PacketHandlerBase); Assembly assembly = Assembly.GetExecutingAssembly(); Type[] types = assembly.GetTypes(); for (int i = 0; i < types.Length; i++) { if (!types[i].IsClass || types[i].IsAbstract) { continue; } if (types[i].BaseType == packetBaseType) { PacketBase packetBase = (PacketBase)Activator.CreateInstance(types[i]); Type packetType = GetServerToClientPacketType(packetBase.Id); if (packetType != null) { Log.Warning("Already exist packet type '{0}', check '{1}' or '{2}'?.", packetBase.Id.ToString(), packetType.Name, packetBase.GetType().Name); continue; } m_ServerToClientPacketTypes.Add(packetBase.Id, types[i]); m_AllPacketTypes.Add(packetBase.Id, types[i]); } else if (types[i].BaseType == packetHandlerBaseType) { IPacketHandler packetHandler = (IPacketHandler)Activator.CreateInstance(types[i]); m_NetworkChannel.RegisterHandler(packetHandler); } else if (types[i].BaseType == CSpacketBaseType) { PacketBase packetBase = (PacketBase)Activator.CreateInstance(types[i]); Type packetType = GetClientToServerPacketType(packetBase.Id); if (packetType != null) { Log.Warning("Already exist packet type '{0}', check '{1}' or '{2}'?.", packetBase.Id.ToString(), packetType.Name, packetBase.GetType().Name); continue; } m_ClientToServerPacketTypes.Add(packetBase.Id, types[i]); m_AllPacketTypes.Add(packetBase.Id, types[i]); } } // 获取框架事件组件 EventComponent Event = UnityGameFramework.Runtime.GameEntry.GetComponent <EventComponent>(); Event.Subscribe(UnityGameFramework.Runtime.NetworkConnectedEventArgs.EventId, OnNetworkConnected); Event.Subscribe(UnityGameFramework.Runtime.NetworkClosedEventArgs.EventId, OnNetworkClosed); Event.Subscribe(UnityGameFramework.Runtime.NetworkMissHeartBeatEventArgs.EventId, OnNetworkMissHeartBeat); Event.Subscribe(UnityGameFramework.Runtime.NetworkErrorEventArgs.EventId, OnNetworkError); Event.Subscribe(UnityGameFramework.Runtime.NetworkCustomErrorEventArgs.EventId, OnNetworkCustomError); }
/// <summary> /// Sends an event of type <typeparamref name="T"/> to any listeners. Creates a default data object to send. /// </summary> public static void CreateEvent <T>(this MonoBehaviour monoBehaviour, EventComponent target) where T : Event <T> { Event <T> .CreateEvent(new MonobehaviourMetadata(monoBehaviour), target, default(T)); }
void Awake() { instance = this; dic = new MultiDictionary <EVENTTYPE, EVENTID, UnityEvent>(); }
public void UpdateEvent(EventComponent account) { }
/// <summary> /// Removes an EventComponent /// </summary> /// <param name="event">EventComponent</param> public void RemoveEvent(EventComponent @event) { events.Remove(events.Select(x => x).First(x => x.TableID == @event.TableID)); }
public static void sendEvent(Pool sender, Pool reciver, EventComponent evt) { int queueIndex = Array.IndexOf <Pool>(pools, sender); reciver.AddEvent(evt); }
public static void RegisterListener(EventComponent target, EventCallback callback) => RegisterListener(int.MaxValue, target, callback);
public static void Unsubscribe(this EventComponent eventComponent, EventId eventId, EventHandler <GameEventArgs> handler) { eventComponent.Unsubscribe((UnityGameFramework.Runtime.EventId)eventId, handler); }
/// <summary> /// Joins multiple components together to a composite. /// </summary> /// <returns>EventsComposite</returns> public EventComposite JoinComponentsToNewComposite(string title, string description, IAccount ownedByAccount, EventComponent[] components) { throw new NotImplementedException(); }
void Start() { EventComponent.RegistEvent(EVENTTYPE.Login, EVENTID.LoginSuccess, new UnityAction(OnLoginSuccess)); }
public void AddEvent(EventComponent newEvent) { throw new NotImplementedException(); }
/// <summary> /// updates a given event in the database /// </summary> /// <returns>true if success</returns> public static bool UpdateEvent(EventComponent anEvent) { return true; }
public static bool Check(this EventComponent eventComponent, EventId eventId, EventHandler <GameEventArgs> handler) { return(eventComponent.Check((UnityGameFramework.Runtime.EventId)eventId, handler)); }
public EventToTime(int time, EventComponent evt) { this.time = time; this.evt = evt; }
/// <summary> /// Gets a link for the user to visit for adding the component to his calendar. /// </summary> /// <returns>true if you are the owner of the event.</returns> public string GetSharedEventLink(Season season, EventComponent component) { throw new NotImplementedException(); }
public void RemoveEvent(EventComponent evt) { semaphore.WaitOne(); eventQueue.Remove(evt); semaphore.Release(); }
/// <summary> /// Removes an existing event from the database /// </summary> /// <param name="anEvent"></param> public void RemoveEvent(EventComponent anEvent) { throw new NotImplementedException(); }
public void ExecuteEventComponent(Event evt, EventComponent ec) { switch (ec.Type) { case EventComponentType.Repeat: if (!ec.BoolParam) { evt.RemoveNow = true; } break; case EventComponentType.Stash: if (ec.BoolParam) { } break; case EventComponentType.InterMap: if (TravelTo(ec.StringParam, ec.MapX, ec.MapY)) { Logger.Info("Engine", $"Travelled to {ec.StringParam}"); } break; case EventComponentType.IntraMap: if (TeleportTo(ec.MapX, ec.MapY)) { } break; case EventComponentType.MapMod: foreach (var mod in ec.MapMods) { map.DoMapMod(mod); } break; case EventComponentType.Spawn: foreach (var spawn in ec.MapSpawns) { enemyManager.SpawnMapSpawn(spawn); } break; case EventComponentType.ShakyCam: camera.ShakyCamTicks = ec.IntParam; break; case EventComponentType.Music: PlayMusic(ec.StringParam); break; case EventComponentType.SoundFX: FPoint pos = new FPoint(); bool loop = false; if (ec.MapX != -1 && ec.MapY != -1) { if (ec.MapX != 0 && ec.MapY != 0) { pos.X = ec.MapX + 0.5f; pos.Y = ec.MapY + 0.5f; } } else if (evt.PosX != 0 && evt.PosY != 0) { pos.X = evt.PosX + 0.5f; pos.Y = evt.PosY + 0.5f; } if (evt.Type == EventType.Load) { loop = true; } Sound sound = GetSound(ec.StringParam); if (sound != null) { sounds.PlaySound(sound, pos, loop); } break; case EventComponentType.SetStatus: campaignManager.SetStatus(ec.StringParams); break; case EventComponentType.UnsetStatus: campaignManager.UnsetStatus(ec.StringParams); break; } }
public void UpdateEvent(EventComponent @event) { throw new NotImplementedException(); }
/// <summary> /// Removes an existing event from the database /// </summary> /// <param name="anEvent"></param> public static void RemoveEvent(EventComponent anEvent) { }