public void TriggerSpecificEvent(int eventIndex, InGameEventType eventType, bool isFake = false, string adminName = null, bool announceEvent = true, string serializedEventParameters = null) { List <EventScriptBase> list; if (eventType == InGameEventType.Random) { list = GetRandomEventList(); } else { list = GetListFromEnum(eventType); } if (list == null) { Logger.LogError("Event List was null shouldn't happen unless new type wasn't added to switch", Category.Event); return; } if (eventIndex == 0) { StartRandomEvent(list, true, isFake, false, adminName, announceEvent); } else { var eventChosen = list[eventIndex - 1]; eventChosen.FakeEvent = isFake; eventChosen.AnnounceEvent = announceEvent; eventChosen.TriggerEvent(serializedEventParameters); AdminCommandsManager.LogAdminAction($"{adminName}: triggered the event: {eventChosen.EventName}. Is fake: {isFake}. Announce: {announceEvent}"); } }
public void TriggerEvent() { if (!InGameEventType.TryParse(eventTypeDropDown.options[eventTypeDropDown.value].text, out InGameEventType eventType)) { return; } var index = nextDropDown.value; if (eventType == InGameEventType.Random) { index = 0; } if (index != 0) // Index 0 (Random Event) will never have a parameter page { // Instead of triggering the event right away, if we have an extra parameter page, we show it List <EventScriptBase> listEvents = InGameEventsManager.Instance.GetListFromEnum(eventType); if (listEvents[index - 1].parametersPageType != ParametersPageType.None) { GameObject parameterPage = eventsParametersPages.eventParameterPages.FirstOrDefault(p => p.ParametersPageType == listEvents[index - 1].parametersPageType).ParameterPage; if (parameterPage) { parameterPage.SetActive(true); parameterPage.GetComponent <SicknessParametersPage>().SetBasicEventParameters(index, isFakeToggle.isOn, announceToggle.isOn, InGameEventType.Fun); return; } } } ServerCommandVersionFourMessageClient.Send(ServerData.UserID, PlayerList.Instance.AdminToken, index, isFakeToggle.isOn, announceToggle.isOn, eventType, "CmdTriggerGameEvent"); }
public void SetBasicEventParameters(int index, bool isFake, bool announce, InGameEventType eventType) { this.index = index; fakeEvent = isFake; announceEvent = announce; this.eventType = eventType; }
private void GenerateDropDownOptionsEventList(InGameEventType eventType) { //generate the drop down options: var optionData = new List <Dropdown.OptionData>(); //Add random entry: optionData.Add(new Dropdown.OptionData { text = "Random" }); var list = InGameEventsManager.Instance.GetListFromEnum(eventType); if (list == null) { nextDropDown.options = optionData; return; } foreach (var eventInList in list) { optionData.Add(new Dropdown.OptionData { text = eventInList.EventName }); } nextDropDown.options = optionData; }
public void CmdTriggerGameEvent(string adminId, string adminToken, int eventIndex, bool isFake, bool announceEvent, InGameEventType eventType, string serializedEventParameters, NetworkConnectionToClient sender = null) { if (IsAdmin(adminId, adminToken, sender) == false) return; InGameEventsManager.Instance.TriggerSpecificEvent(eventIndex, eventType, isFake, PlayerList.Instance.GetByUserID(adminId).Username, announceEvent, serializedEventParameters); }
public void CmdTriggerGameEvent(int eventIndex, bool isFake, bool announceEvent, InGameEventType eventType, string serializedEventParameters, NetworkConnectionToClient sender = null) { if (IsAdmin(sender, out var player) == false) { return; } InGameEventsManager.Instance.TriggerSpecificEvent( eventIndex, eventType, isFake, player.Username, announceEvent, serializedEventParameters); }
public List <EventScriptBase> GetRandomEventList() { var enumList = EnumListCache; enumList.Remove("Random"); enumList.Remove("Debug"); if (InGameEventType.TryParse(enumList.GetRandom(), out InGameEventType result)) { return(GetListFromEnum(result)); } return(null); }
public void CmdTriggerGameEvent(string adminId, string adminToken, int eventIndex, bool isFake, bool announceEvent, InGameEventType eventType, string serializedEventParameters) { var admin = PlayerList.Instance.GetAdmin(adminId, adminToken); if (admin == null) { return; } InGameEventsManager.Instance.TriggerSpecificEvent(eventIndex, eventType, isFake, PlayerList.Instance.GetByUserID(adminId).Username, announceEvent, serializedEventParameters); }
public void TriggerEvent() { // Pull time from game manager and put it into a private holder variable which gets cleared on timeout and allows the button to be pressed again. Current WAIT time set to 5 secs stationTimeHolder = GameManager.Instance.stationTime; if (stationTimeHolder < (stationTimeSnapshot)) { // Tells all admins to wait X seconds, this is based on round time so if the server stutters loading an event it // will take it into account effectivly stopping any sort of spam. Chat.AddExamineMsgToClient($"Please wait {Mathf.Round((float)stationTimeSnapshot.Subtract(stationTimeHolder).TotalSeconds)} seconds before trying to generate another event."); return; } stationTimeSnapshot = stationTimeHolder.AddSeconds(5); if (!InGameEventType.TryParse(eventTypeDropDown.options[eventTypeDropDown.value].text, out InGameEventType eventType)) { return; } var index = nextDropDown.value; if (eventType == InGameEventType.Random) { index = 0; } if (index != 0) // Index 0 (Random Event) will never have a parameter page { // Instead of triggering the event right away, if we have an extra parameter page, we show it List <EventScriptBase> listEvents = InGameEventsManager.Instance.GetListFromEnum(eventType); if (listEvents[index - 1].parametersPageType != ParametersPageType.None) { GameObject parameterPage = eventsParametersPages.eventParameterPages .FirstOrDefault(p => p.ParametersPageType == listEvents[index - 1].parametersPageType) .ParameterPage; if (parameterPage) { parameterPage.SetActive(true); parameterPage.GetComponent <SicknessParametersPage>().SetBasicEventParameters(index, isFakeToggle.isOn, announceToggle.isOn, InGameEventType.Fun); return; } } } AdminCommandsManager.Instance.CmdTriggerGameEvent(index, isFakeToggle.isOn, announceToggle.isOn, eventType, null); }
private void GenerateDropDownOptionsEventType() { if (!generated) { generated = true; EventTypeOptions(); } if (!InGameEventType.TryParse(eventTypeDropDown.options[eventTypeDropDown.value].text, out InGameEventType eventType)) { return; } GenerateDropDownOptionsEventList(eventType); }
public void TriggerEvent() { if (!InGameEventType.TryParse(eventTypeDropDown.options[eventTypeDropDown.value].text, out InGameEventType eventType)) { return; } var index = nextDropDown.value; if (eventType == InGameEventType.Random) { index = 0; } ServerCommandVersionFourMessageClient.Send(ServerData.UserID, PlayerList.Instance.AdminToken, index, isFakeToggle.isOn, announceToggle.isOn, eventType, "CmdTriggerGameEvent"); }
public void AddEventToList(EventScriptBase eventToAdd, InGameEventType eventType) { var list = GetListFromEnum(eventType); if (list == null) { Logger.LogError("An event has been set to random type, random is a dummy type and cant be accessed.", Category.Event); return; } if (list.Contains(eventToAdd)) { return; } list.Add(eventToAdd); }
public void RemoveEventFromList(EventScriptBase eventToRemove, InGameEventType enumValue) { switch (enumValue) { case InGameEventType.Fun: ListOfFunEventScripts.Remove(eventToRemove); return; case InGameEventType.Special: ListOfSpecialEventScripts.Remove(eventToRemove); return; case InGameEventType.Antagonist: ListOfAntagonistEventScripts.Remove(eventToRemove); return; case InGameEventType.Debug: ListOfDebugEventScripts.Remove(eventToRemove); return; } }
public List <EventScriptBase> GetListFromEnum(InGameEventType enumValue) { switch (enumValue) { case InGameEventType.Random: return(null); case InGameEventType.Fun: return(ListOfFunEventScripts); case InGameEventType.Special: return(ListOfSpecialEventScripts); case InGameEventType.Antagonist: return(ListOfAntagonistEventScripts); case InGameEventType.Debug: return(ListOfDebugEventScripts); default: return(null); } }
public void TriggerSpecificEvent(int eventIndex, InGameEventType eventType, bool isFake = false, string adminName = null, bool announceEvent = true, string serializedEventParameters = null) { List <EventScriptBase> list; if (eventType == InGameEventType.Random) { list = GetRandomEventList(); } else { list = GetListFromEnum(eventType); } if (list == null) { Debug.LogError("Event List was null shouldn't happen unless new type wasn't added to switch"); return; } if (eventIndex == 0) { StartRandomEvent(list, true, isFake, false, adminName, announceEvent); } else { var eventChosen = list[eventIndex - 1]; eventChosen.FakeEvent = isFake; eventChosen.AnnounceEvent = announceEvent; eventChosen.TriggerEvent(serializedEventParameters); var msg = $"{adminName}: triggered the event: {eventChosen.EventName}. Is fake: {isFake}. Announce: {announceEvent}"; UIManager.Instance.adminChatWindows.adminToAdminChat.ServerAddChatRecord(msg, null); DiscordWebhookMessage.Instance.AddWebHookMessageToQueue(DiscordWebhookURLs.DiscordWebhookAdminLogURL, msg, ""); } }
public static ServerCommandVersionFourMessageClient Send(string adminId, string adminToken, int eventIndex, bool isFake, bool announceEvent, InGameEventType eventType, string action) { ServerCommandVersionFourMessageClient msg = new ServerCommandVersionFourMessageClient { AdminId = adminId, AdminToken = adminToken, EventIndex = eventIndex, IsFake = isFake, AnnounceEvent = announceEvent, EventType = eventType, Action = action }; msg.Send(); return(msg); }
public static ServerCommandVersionFourMessageClient Send(string adminId, string adminToken, int eventIndex, bool isFake, bool announceEvent, InGameEventType eventType, string action, BaseEventParameters eventParameters = null) { ServerCommandVersionFourMessageClient msg = new ServerCommandVersionFourMessageClient { AdminId = adminId, AdminToken = adminToken, EventIndex = eventIndex, IsFake = isFake, AnnounceEvent = announceEvent, EventType = eventType, Action = action, SerializedEventParameters = JsonConvert.SerializeObject(eventParameters) }; msg.Send(); return(msg); }