Beispiel #1
0
        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");
    }
Beispiel #3
0
 public void SetBasicEventParameters(int index, bool isFake, bool announce, InGameEventType eventType)
 {
     this.index     = index;
     fakeEvent      = isFake;
     announceEvent  = announce;
     this.eventType = eventType;
 }
Beispiel #4
0
    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);
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        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);
    }
Beispiel #10
0
    private void GenerateDropDownOptionsEventType()
    {
        if (!generated)
        {
            generated = true;
            EventTypeOptions();
        }

        if (!InGameEventType.TryParse(eventTypeDropDown.options[eventTypeDropDown.value].text, out InGameEventType eventType))
        {
            return;
        }

        GenerateDropDownOptionsEventList(eventType);
    }
Beispiel #11
0
    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");
    }
Beispiel #12
0
        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);
        }
Beispiel #13
0
        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;
            }
        }
Beispiel #14
0
        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);
            }
        }
Beispiel #15
0
        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, "");
            }
        }
Beispiel #16
0
        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);
        }
Beispiel #17
0
        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);
        }