Esempio n. 1
0
        public void OnWorldReport(MediusWorldReport report)
        {
            // Ensure report is for correct game world
            if (report.MediusWorldID != Id)
            {
                return;
            }

            GameName         = report.GameName;
            MinPlayers       = report.MinPlayers;
            MaxPlayers       = report.MaxPlayers;
            GameLevel        = report.GameLevel;
            PlayerSkillLevel = report.PlayerSkillLevel;
            RulesSet         = report.RulesSet;
            GenericField1    = report.GenericField1;
            GenericField2    = report.GenericField2;
            GenericField3    = report.GenericField3;

            // Once the world has been closed then we force it closed.
            // This is because when the host hits 'Play Again' they tell the server the world has closed (EndGameReport)
            // but the existing clients tell the server the world is still active.
            // This gives the host a "Game Name Already Exists" when they try to remake with the same name.
            // This just fixes that. At the cost of the game not showing after a host leaves a game.
            if (WorldStatus != MediusWorldStatus.WorldClosed)
            {
                // When game starts, send game mode payload
                if (report.WorldStatus == MediusWorldStatus.WorldActive && WorldStatus != MediusWorldStatus.WorldActive)
                {
                    if (CustomGamemode != null)
                    {
                        CustomGamemode.Apply(Clients.Select(x => x.Client));
                    }
                    else
                    {
                        Gamemode.Disable(Clients.Select(x => x.Client));
                    }
                }

                WorldStatus = report.WorldStatus;
            }
        }
Esempio n. 2
0
        public void OnWorldReport(MediusWorldReport report)
        {
            // Ensure report is for correct game world
            if (report.MediusWorldID != Id)
            {
                return;
            }

            GameName         = report.GameName;
            MinPlayers       = report.MinPlayers;
            MaxPlayers       = report.MaxPlayers;
            GameLevel        = report.GameLevel;
            PlayerSkillLevel = report.PlayerSkillLevel;
            RulesSet         = report.RulesSet;
            GenericField1    = report.GenericField1;
            GenericField2    = report.GenericField2;
            GenericField3    = report.GenericField3;
            GenericField4    = report.GenericField4;
            GenericField5    = report.GenericField5;
            GenericField6    = report.GenericField6;
            GenericField7    = report.GenericField7;
            GenericField8    = report.GenericField8;

            // Once the world has been closed then we force it closed.
            // This is because when the host hits 'Play Again' they tell the server the world has closed (EndGameReport)
            // but the existing clients tell the server the world is still active.
            // This gives the host a "Game Name Already Exists" when they try to remake with the same name.
            // This just fixes that. At the cost of the game not showing after a host leaves a game.
            if (WorldStatus != MediusWorldStatus.WorldClosed)
            {
                // When game starts, send custom gamemode payload
                if (report.WorldStatus == MediusWorldStatus.WorldActive && WorldStatus != MediusWorldStatus.WorldActive)
                {
                    // Send to plugins
                    Program.Plugins.OnEvent(PluginEvent.MEDIUS_GAME_ON_STARTED, new OnGameArgs()
                    {
                        Game = this
                    });

                    /*
                     * var payloads = new List<BaseScertMessage>();
                     *
                     * // Add payloads and set payload defs
                     * int count = CustomGamemode == null ? 0 : 1;
                     * byte[] moduleDefinitions = new byte[16 * (count + 1)];
                     * for (int i = 0; i < count; ++i)
                     * {
                     *  if (i == 0 && CustomGamemode != null)
                     *  {
                     *      payloads.AddRange(CustomGamemode.GetPayload());
                     *      CustomGamemode.SetModuleEntry(moduleDefinitions, i * 16, true);
                     *  }
                     * }
                     *
                     * // Add module definitions payload
                     * payloads.Add(new RT_MSG_SERVER_MEMORY_POKE()
                     * {
                     *  Address = 0x000CF000,
                     *  Payload = moduleDefinitions
                     * });
                     *
                     * // Send
                     * foreach (var client in Clients.Select(x => x.Client))
                     *  client.Queue(payloads);
                     */
                }

                WorldStatus = report.WorldStatus;
            }
        }