Exemple #1
0
 public override void OnDisconnection(VMEODClient client)
 {
     Lobby.Leave(client);
     State = VMEODBandStates.Idle;
     base.OnDisconnection(client);
     SetTimer(-1);
 }
Exemple #2
0
        public override void OnConnection(VMEODClient client)
        {
            var args = client.Invoker.Thread.TempRegisters;

            // client belongs to a player
            if (client.Avatar != null)
            {
                if ((args != null) && (args[0] > -1) && (args[0] < 4))
                {
                    if (Lobby.Join(client, args[0]))
                    {
                        client.Send("Band_UI_Init", new byte[] { (byte)args[0] });
                        var slot = Lobby.GetSlotData(client);
                        if (slot != null)
                        {
                            slot.AvatarName  = client.Avatar.Name;
                            slot.Instrument  = (VMEODBandInstrumentTypes)Enum.ToObject(typeof(VMEODBandInstrumentTypes), args[0]);
                            slot.SkillAmount = GetAvatarsCurrentSkill(client);

                            if (Lobby.IsFull())
                            {
                                InitGame();
                            }
                        }
                    }
                }
            }
            // client belongs to the smart tile, is contoller
            else
            {
                Controller = client;
            }
            base.OnConnection(client);
        }
Exemple #3
0
 /*
  * This Simantics event happens after a win or a loss and each time a new player joins.
  */
 void NewGameHandler(short evt, VMEODClient client)
 {
     if (State.Equals(VMEODBandStates.Finale))
     {
         InitGame(FINALE_TIMER_DFEAULT);
     }
 }
 /*
  * This Simantics event only happens after a win or a loss and after each sequence round.
  */
 private void AnimationsFinishedHandler(short evt, VMEODClient client)
 {
     if (State.Equals(VMEODBandStates.MinPayment))
     {
         EnqueueGotoState(VMEODBandStates.Finale);
         Lobby.Broadcast("Band_Win", Data.VMEODGameCompDrawACardData.SerializeStrings(CumulativePayout + "", "" + CurrentSongLength));
         // send the song length for the win animation
         Controller.SendOBJEvent(new VMEODEvent((short)VMEODBandEventTypes.NewSongLength, CurrentSongLength));
         // get the prorated skill payout amount
         short skillPayout = (short)Math.Round(0m + (CombinedSkillAmount * SKILL_PAYOUT_MULTIPLIER * CurrentSongLength) / MAX_SONG_LENGTH);
         Controller.SendOBJEvent(new VMEODEvent((short)VMEODBandEventTypes.NewSkillPayout, skillPayout));
         // send the win amount
         Controller.SendOBJEvent(new VMEODEvent((short)VMEODBandEventTypes.WinRound, (short)CumulativePayout));
     }
     else if (State.Equals(VMEODBandStates.Electric))
     {
         if (Lobby.IsFull())
         {
             EnqueueGotoState(VMEODBandStates.Intermission);
         }
     }
     else
     {
         if (Lobby.IsFull())
         {
             EnqueueGotoState(VMEODBandStates.PreShow);
         }
     }
 }
Exemple #5
0
        private void WearCostumeHandler(string evt, string costumeID, VMEODClient client)
        {
            // make sure the requested item is valid and is found in the collection
            ulong parsedID;
            ulong assetID;
            var   valid = ulong.TryParse(costumeID, out parsedID);

            if (valid)
            {
                assetID = FindInCollection(parsedID);
            }
            else
            {
                assetID = 0;
            }

            // send event to assign costume to avatar's dynamic costume and disconnect client
            if (assetID != 0)
            {
                client.vm.SendCommand(new VMNetSetOutfitCmd
                {
                    UID    = client.Avatar.PersistID,
                    Scope  = VMPersonSuits.DynamicCostume,
                    Outfit = assetID,
                });
                // now get out
                client.SendOBJEvent(new VMEODEvent((short)VMEODTrunkPluginEvents.Change));
                Server.Disconnect(client);
            }
        }
Exemple #6
0
 public override void OnConnection(VMEODClient client)
 {
     base.OnConnection(client);
     if (client.Avatar != null)
     {
         // get the params, temp 0 is player type
         var local = client.Invoker.Thread.TempRegisters;
         if ((local != null) && (local[0] == (short)VMEODWarGamePlayers.Blue))
         {
             BluePlayerClient = client;
             BluePlayerClient.Send("WarGame_Init", BluePlayerClient.Avatar.ObjectID + "%blue");
             NumberOfPlayers++;
         }
         else
         {
             RedPlayerClient = client;
             RedPlayerClient.Send("WarGame_Init", RedPlayerClient.Avatar.ObjectID + "%red");
             NumberOfPlayers++;
         }
     }
     else
     {
         ControllerClient = client;
     }
     if ((NumberOfPlayers == 2) && (ControllerClient != null))
     {
         BluePlayerClient.Send("WarGame_Draw_Opponent", RedPlayerClient.Avatar.ObjectID + "");
         RedPlayerClient.Send("WarGame_Draw_Opponent", BluePlayerClient.Avatar.ObjectID + "");
         NextGameHandler((short)VMEODWarGameEvents.NextGame, ControllerClient);
     }
 }
        void IsRunningChangeHandler(string evt, byte[] newRunningState, VMEODClient client)
        {
            if ((newRunningState == null) || (newRunningState.Length < 1) || (newRunningState[0] > 1))
            {
                return;
            }

            switch (IsRunning)
            {
            case true:
            {
                if (newRunningState[0] == 0)
                {
                    IsRunning = false;
                    PlayerClient.SendOBJEvent(new VMEODEvent((short)VMEODTimerEvents.Pause));
                }
                break;
            }

            default:
            {
                if (newRunningState[0] == 1)
                {
                    IsRunning = true;
                    PlayerClient.SendOBJEvent(new VMEODEvent((short)VMEODTimerEvents.Start));
                    UpdatedAfterStop = false;
                }
                break;
            }
            }
        }
Exemple #8
0
        private void WheelsStoppedHandler(string evt, string uselessString, VMEODClient client)
        {
            var winnings = CurrentWinnings;

            CurrentWinnings = 0;
            if (winnings > 0)
            {
                // send win event with random number for message displayed
                client.Send("slots_display_win", "" + SlotsRandom.Next(25, 30) + "%" + winnings);

                // pay the player
                var VM = client.vm;
                VM.GlobalLink.PerformTransaction(VM, false, Server.Object.PersistID, client.Avatar.PersistID, winnings,

                                                 // debit the balance of the machine
                                                 (bool success, int transferAmount, uint uid1, uint budget1, uint uid2, uint budget2) =>
                {
                    if (success)
                    {
                        MachineBalance = (int)(budget1);
                    }
                });
            }
            else
            {
                // send loss event with random number for message displayed
                client.Send("slots_display_loss", "" + SlotsRandom.Next(30, 35));
            }
        }
Exemple #9
0
        private void TryOutfitOn(string evt, string data, VMEODClient client)
        {
            uint outfitId = 0;

            if (!uint.TryParse(data, out outfitId))
            {
                return;
            }

            GetOutfit(client.vm, outfitId, outfit => {
                if (outfit == null)
                {
                    return;
                }

                var slot = GetSuitSlot(true);

                //store the outfit under dynamic costume
                client.vm.SendCommand(new VMNetSetOutfitCmd {
                    UID    = client.Avatar.PersistID,
                    Scope  = slot,
                    Outfit = outfit.asset_id
                });
                //3 uses dynamic costume, by using this we avoid updating default outfits without a good reason to
                client.SendOBJEvent(new VMEODEvent((short)VMEODRackEvent.TryOnOutfit, (short)RackType));
            });
        }
        void WearCostumeHandler(string evt, string costumeID, VMEODClient client)
        {
            // make sure the requested item is valid and is found in the collection
            ulong assetID = 0;
            var   valid   = ulong.TryParse(costumeID, out var parsedID);

            if (valid)
            {
                assetID = FindInCollection(parsedID);
            }

            // change added 23.10.18 for Halloween event: skeleton body added to costume trunk bypassing collections/purchasebles
            if (assetID == 0 && IsCostumeTrunk)
            {
                assetID = 6000069312525;
            }

            // send event to assign costume to avatar's dynamic costume and disconnect client
            if (assetID != 0)
            {
                client.vm.SendCommand(new VMNetSetOutfitCmd
                {
                    UID    = client.Avatar.PersistID,
                    Scope  = VMPersonSuits.DynamicCostume,
                    Outfit = assetID,
                });
                // now get out
                client.SendOBJEvent(new VMEODEvent((short)VMEODTrunkPluginEvents.Change));
                Server.Disconnect(client);
            }
        }
Exemple #11
0
        private void NextRoundHandler(short eventID, VMEODClient eventSource)
        {
            byte remainingBluePieces = (byte)Players[(byte)VMEODWarGamePlayers.Blue].Pieces.Count;
            byte remainingRedPieces  = (byte)Players[(byte)VMEODWarGamePlayers.Red].Pieces.Count;

            // the game is over as one of the players has no more available piece choices
            if ((remainingBluePieces == 0) || (remainingRedPieces == 0)) // can not both be zero, fyi
            {
                WinHandler((remainingBluePieces > remainingRedPieces) ? (short)VMEODWarGamePlayers.Blue : (short)VMEODWarGamePlayers.Red);
            }
            // check to make sure the game isn't a stalemate - both players have the same remaining piece
            else if ((remainingBluePieces == 1) && (remainingRedPieces == 1))
            {
                if (Players[(byte)VMEODWarGamePlayers.Blue].Pieces[0].PieceType.Equals(Players[(byte)VMEODWarGamePlayers.Red].Pieces[0].PieceType))
                {
                    BluePlayerClient.Send("WarGame_Stalemate", new Byte[] { (byte)Players[(byte)VMEODWarGamePlayers.Blue].Pieces[0].PieceType });
                    RedPlayerClient.Send("WarGame_Stalemate", new Byte[] { (byte)Players[(byte)VMEODWarGamePlayers.Red].Pieces[0].PieceType });
                    GameMessageTimer.Start();
                }
            }
            else if (NumberOfPlayers == 2)
            {
                BluePlayerClient.Send("WarGame_Resume", new Byte[] { remainingBluePieces, remainingRedPieces });
                RedPlayerClient.Send("WarGame_Resume", new Byte[] { remainingBluePieces, remainingRedPieces });
            }
        }
 public void S_RespondBake(short evt, VMEODClient client)
 {
     if (State == VMEODPizzaState.Bake)
     {
         EnterState(VMEODPizzaState.Break);
     }
 }
        public override void OnConnection(VMEODClient client)
        {
            base.OnConnection(client);
            var args           = client.Invoker.Thread.TempRegisters;
            var trunkTypeShort = args[0];

            // check if the passed params match a trunk
            bool isValidTrunkParam = Enum.IsDefined(typeof(VMEODTrunkPluginCollections), trunkTypeShort);

            if (!isValidTrunkParam)
            {
                Server.Disconnect(client);
            }

            if (trunkTypeShort == (short)VMEODTrunkPluginCollections.costumes)
            {
                IsCostumeTrunk = true;
            }

            var typeString = Enum.GetName(typeof(VMEODTrunkPluginCollections), trunkTypeShort);

            // avatar gender affects collection & path
            var  avatar = client.Avatar;
            bool isMale = (avatar.GetPersonData(VMPersonDataVariable.Gender) == 0);

            string collectionPath = typeString + (isMale ? "_" : "_fe") + "male.col";

            // get the matching trunk collection
            var content = Content.GameContent.Get;

            TrunkOutfits = content.AvatarCollections.Get(collectionPath);

            client.Send("trunk_fill_UI", collectionPath);
        }
Exemple #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="evt"></param>
        /// <param name="chosenDifficulty"></param>
        /// <param name="client"></param>
        private void ChooseDifficultyHandler(string evt, byte[] chosenDifficulty, VMEODClient client)
        {
            if (GameState.Equals(FreeSOMazeStates.Lobby) && NextState.Equals(FreeSOMazeStates.Invalid))
            {
                FreeSOMazePlayer caller  = null;
                FreeSOMazePlayer partner = null;
                if (LogicPlayer != null && client.Equals(LogicPlayer.Client))
                {
                    caller  = LogicPlayer;
                    partner = CharismaPlayer;
                }
                else
                {
                    caller  = CharismaPlayer;
                    partner = LogicPlayer;
                }
                int difficultyNum = BitConverter.ToInt32(chosenDifficulty, 0);
                FreeSOMazeDifficulties difficulty = FreeSOMazeDifficulties.Unselected;
                if (Enum.IsDefined(typeof(FreeSOMazeDifficulties), difficultyNum))
                {
                    difficulty = (FreeSOMazeDifficulties)Enum.ToObject(typeof(FreeSOMazeDifficulties), difficultyNum);
                }

                ValidateDifficulty(caller, difficulty, partner);
            }
        }
Exemple #15
0
        /*
         * Responds to event called by client when they click UIButton:SaveBtn OR answering in the affirmitive on any UIAlert while this evaluation is true:
         * (UIGameCompDrawACardPluginEODStates:State == UIGameCompDrawACardPluginEODStates.EditSingleCard)
         * @param evt:String containing the name of the event
         * @param cardText:String containing the desired updated text of the card at Game.CurrentCardIndex
         * @note: Due to the MaxChars limit of 256 of the UITextEdit:EditCardTextEdit, cardText:String must not have a length greater than 256.
         * @note: No callback function is needed, which means the client's ability to interact with the UI is unaffected and not dependent on this handler.
         */
        void EditCurrentCardHandler(string evt, byte[] cardTextArray, VMEODClient client)
        {
            // client has to be the object owner
            bool isOwner = (((VMTSOObjectState)Server.Object.TSOState).OwnerID == UserClient.Avatar.PersistID);

            // validate the data
            bool   isValid  = false;
            string cardText = null;
            var    strings  = VMEODGameCompDrawACardData.DeserializeStrings(cardTextArray);

            if (strings != null)
            {
                cardText = strings[0];
            }
            if ((cardText != null) && (cardText.Length < 257))
            {
                isValid = true;
            }

            // If the user would like this card to be blank, replace the blank string with the name of the enum entry for custom.
            if (cardText.Length == 0)
            {
                cardText = VMEODGameCompDrawACardTypes.VMEODGameCompDrawACardCustom.ToString();
            }
            if ((isOwner) && (isValid))
            {
                if (!Game.CurrentCardText.Equals(cardText))
                {
                    DeckHasChanged = true;
                    Game.EditCurrentCard(cardText);
                    UserClient.Send("DrawCard_Update_Deck", GetDeckListBoxData());
                }
            }
        }
Exemple #16
0
 internal FreeSOMazePlayer(VMEODClient client, decimal skill, bool iAmLogicPlayer)
 {
     _Client       = client;
     _Skill        = skill;
     IsLogicPlayer = iAmLogicPlayer;
     Reset();
 }
 public void S_RespondPhone(short evt, VMEODClient client)
 {
     if (State == VMEODPizzaState.PhoneCall)
     {
         EnterState(VMEODPizzaState.Contribution);
     }
 }
        private void RoundStartHandler(short evt, VMEODClient client)
        {
            //init dance mode
            //random dancer pattern is set on tick
            DancePatternNum = 0;
            RoundTicks      = 0;

            //set the winning dj pattern
            var rand = new Random();

            for (int i = 0; i < 4; i++)
            {
                CurrentWinningDJPattern[i] = rand.Next(64);
            }

            //reset all plugins
            foreach (var dj in DJPlatforms)
            {
                dj.Reset();
            }
            foreach (var dancer in DancePlatforms)
            {
                dancer.Reset();
            }

            //let's identify dancer avatars to push interactions onto.
            Dancers = new List <VMAvatar>();
            foreach (var avatar in Server.vm.Context.ObjectQueries.Avatars)
            {
                if (avatar.Object.Resource.Name == "oj-nc-npc-dancer")
                {
                    Dancers.Insert(rand.Next(Dancers.Count + 1), (VMAvatar)avatar);
                }
            }
        }
        private void UpdatePrice(string evt, string data, VMEODClient client)
        {
            bool isOwner = (((VMTSOObjectState)Server.Object.TSOState).OwnerID == client.Avatar.PersistID);

            if ((Lobby.GetPlayerSlot(client) != 0) || (!isOwner))
            {
                return;
            }

            var  split        = data.Split(',');
            uint outfitId     = 0;
            int  newSalePrice = 0;

            if (!uint.TryParse(split[0], out outfitId) ||
                !int.TryParse(split[1], out newSalePrice))
            {
                return;
            }

            if (!PRICE_VALIDATION.IsMatch(newSalePrice.ToString()))
            {
                return;
            }

            var VM = client.vm;

            VM.GlobalLink.UpdateOutfitSalePrice(VM, outfitId, Server.Object.PersistID, newSalePrice, success => {
                BroadcastOutfits(VM, false);
            });
        }
Exemple #20
0
        public void P_Ingredient(string evt, string text, VMEODClient client)
        {
            if (ControllerClient == null || !int.TryParse(text, out var item))
            {
                return; //invalid
            }
            var station = Array.IndexOf(Players, client);

            if (station == -1 || State != VMEODPizzaState.Contribution)
            {
                return;
            }
            var player = PizzaPlayers[station];

            if (player.Contrib != null || item < 0 || item > 2)
            {
                return;
            }

            /* non-freeso
             * var avaID = (short)(client.Avatar.ObjectID);
             * if (avaID > 255) avaID = 0; //cool object
             */

            var avaID = station; //freeso patched. should really signal this on init.

            player.Contrib = player.Hand[item];
            ControllerClient.SendOBJEvent(new VMEODEvent((short)VMEODPizzaObjEvent.Contribute,
                                                         (short)((short)player.Contrib.Type | (short)(avaID << 8)))); //lo: ingredient, hi: FREESO player id
            InsertCard(player.Hand[item]);
            player.Hand[item] = null;

            PlayerContributionUpdate();
        }
Exemple #21
0
        public void B_SetMessage(string evt, byte[] data, VMEODClient client)
        {
            lock (this)
            {
                VMEODSignsData newData;
                try
                {
                    newData = new VMEODSignsData(data);
                }
                catch (Exception) { return; }

                if (Mode == VMEODSignsMode.Read)
                {
                    return;                              //cannot change anything
                }
                else if (Mode == VMEODSignsMode.Write)
                {
                    newData.Flags = Data.Flags;                                    //cannot change permissions
                }
                if (newData.Text.Length > 0)
                {
                    newData.Text = newData.Text.Substring(0, Math.Min(MaxLength, newData.Text.Length));
                }
                Data = newData;

                Server.vm.GlobalLink.SavePluginPersist(Server.vm, Server.Object.PersistID, Server.PluginID, newData.Save());

                foreach (var cli in Server.Clients)
                {
                    cli.SendOBJEvent(new VMEODEvent((short)VMEODSignsEvent.TurnOnWritingSign, (short)((Data.Text.Length > 0) ? 1 : 0)));
                }
            }
        }
 /// <summary>
 /// I pressed my buzzer.
 /// </summary>
 /// <param name="evt"></param>
 /// <param name="data"></param>
 /// <param name="client"></param>
 private void PlayerBuzzedHandler(string evt, byte[] data, VMEODClient client)
 {
     if (MyBuzzerEnabled)
     {
         PlayerBuzzedEventHandler(this);
     }
 }
Exemple #23
0
        public override void OnConnection(VMEODClient client)
        {
            var param = client.Invoker.Thread.TempRegisters;

            Mode      = (VMEODSignsMode)param[0];
            MaxLength = param[1];
        }
 public override void OnDisconnection(VMEODClient client)
 {
     SessionStamp = 0;
     SearchStamp  = 0;
     SyncEvent   -= PlayerSyncHandler;
     base.OnDisconnection(client);
 }
Exemple #25
0
        /// <summary>
        /// Notifies each connected contestant of the winner chosen by the host.
        /// </summary>
        /// <param name="evt">Buzzer_Host_A_DeclareWinner</param>
        /// <param name="playerIndex"></param>
        private void DeclareWinnerHandler(string evt, byte[] playerIndex, VMEODClient host)
        {
            var index = BitConverter.ToInt32(playerIndex, 0);

            if (IsValidConnectedContestant(index))
            {
                var winner = ConnectedContestants[index];
                if (winner != null)
                {
                    var name = winner.AvatarName;

                    // queue for player
                    WinnerAction = () => { winner?.DeclareWinner(2, name); };

                    // notify other players
                    var players = GetConnectedPlayers(index, false);
                    foreach (var player in players)
                    {
                        player.DeclareWinner(1, name); // you lose
                    }
                    // host callback
                    MyClient.Send("Buzzer_Player_Win", name);
                    // execute Simantics event for host to declare winner
                    Controller.SendOBJEvent(new Model.VMEODEvent((short)VMEODGameshowHostPluginEvents.Declare_Winner, winner.MyClient?.Avatar?.ObjectID ?? 0));
                }
            }
        }
 public override void OnConnection(VMEODClient client)
 {
     if (client.Avatar != null)
     {
         var args = client.Invoker.Thread.TempRegisters;
         if (args[0] == 1)
         {
             LogicPlayer = client;
             client.Send("TSOMaze_Show_Logic", new byte[0]);
             CooldownTimer = 6;
         }
         else
         {
             CharismaPlayer = client;
             client.Send("TSOMaze_Show_Charisma", new byte[0]);
             CooldownTimer = 8;
         }
         if (LogicPlayer != null && CharismaPlayer != null)
         {
             EnqueueGotoState(VMEODTwoPersonJobObjectMazePluginStates.Ready);
         }
     }
     else
     {
         Controller = client;
     }
     base.OnConnection(client);
 }
        public void P_TryCode(string evt, string data, VMEODClient client)
        {
            if (Mode != VMEODPermissionDoorMode.CodeInput)
            {
                return;
            }
            lock (this)
            {
                if (!SentMessage)
                {
                    Server.Shutdown(); return;
                }
                //verify that the code is at most a 4 digit number
                if (!uint.TryParse(data, out var code) || code > 999999999)
                {
                    Server.Shutdown(); return;
                }

                foreach (var cli in Server.Clients)
                {
                    cli.SendOBJEvent(new VMEODEvent((short)VMEODPermissionDoorEvent.ValidateResult, (short)((code == Code)?1:0)));
                }

                Server.Shutdown();
            }
        }
Exemple #28
0
        private void StoreDefaultSuit(VMEODClient client, VMPersonSuits category, uint outfitId)
        {
            GetOutfit(client.vm, outfitId, outfit => {
                if (outfit == null)
                {
                    //You don't own this outfit!
                    return;
                }

                if (outfit.outfit_type != (byte)category)
                {
                    //Wrong category, no swimming in PJs!
                    return;
                }

                //Set the default in the vm, this will be persisted on exit avatar persist
                client.vm.SendCommand(new VMNetSetOutfitCmd {
                    UID    = client.Avatar.PersistID,
                    Scope  = category,
                    Outfit = outfit.asset_id
                });

                //Have the UI update the default
                client.Send("dresser_refresh_default", "");
            });
        }
Exemple #29
0
        private void NewOddsHandler(string evt, Byte[] args, VMEODClient client)
        {
            bool isOwner = (((VMTSOObjectState)Server.Object.TSOState).OwnerID == UserClient.Avatar.PersistID);

            if (isOwner)
            {
                if ((args != null) && (args.Length > 0))
                {
                    if (args[0] < 80)
                    {
                        MachinePaybackPercent = 80;
                    }
                    else if (args[0] > 110)
                    {
                        MachinePaybackPercent = 110;
                    }
                    else
                    {
                        MachinePaybackPercent = args[0];
                    }
                }
                client.SendOBJEvent(new VMEODEvent((short)VMOEDSlotsObjectEvents.SetNewPayout, new short[1] {
                    MachinePaybackPercent
                }));
            }
        }
        public override void OnConnection(VMEODClient client)
        {
            base.OnConnection(client);

            PlayerClient = client;

            // get the registers
            var args = client.Invoker.Thread.TempRegisters;

            // get the initial minutes and seconds
            CurrentDisplayedMinutes = args[2];
            CurrentDisplayedSeconds = args[3];

            // get the current running states
            IsRunning = (args[0] == 1) ? true : false;
            if (Enum.IsDefined(typeof(VMEODTimerPluginStates), args[1]))
            {
                State = (VMEODTimerPluginStates)Enum.ToObject(typeof(VMEODTimerPluginStates), args[1]);
            }
            else
            {
                State = VMEODTimerPluginStates.Countdown;
            }

            // show the client: @params - Byte[] { 0 if IsRunning or 1 if !IsRunning, 0 if State = Countdown 1 if State = Stopwatch, Minutes/256, Seconds }
            PlayerClient.Send("Timer_Show", new Byte[] { (byte)args[0], (byte)args[1], (byte)(CurrentDisplayedMinutes), (byte)CurrentDisplayedSeconds });
        }
 public override void OnConnection(VMEODClient client)
 {
     if (client.Avatar != null)
     {
         client.Send("dance_show", "");
     }
     else
     {
         //we're the dance floor controller!
         ControllerClient = client;
     }
 }
 public void S_RespondBake(short evt, VMEODClient client)
 {
     if (State == VMEODPizzaState.Bake) EnterState(VMEODPizzaState.Break);
 }
Exemple #33
0
 public override void OnConnection(VMEODClient client)
 {
     //immediately disconnect
     Server.Disconnect(client);
 }
Exemple #34
0
 public virtual void OnDisconnection(VMEODClient client)
 {
 }
 public void P_Close(string evt, string text, VMEODClient client)
 {
     Server.Disconnect(client);
 }
        public void P_Ingredient(string evt, string text, VMEODClient client)
        {
            int item;
            if (ControllerClient == null || !int.TryParse(text, out item)) return; //invalid
            var station = Array.IndexOf(Players, client);
            if (station == -1 || State != VMEODPizzaState.Contribution) return;
            var player = PizzaPlayers[station];
            if (player.Contrib != null || item < 0 || item > 2) return;

            /* non-freeso
            var avaID = (short)(client.Avatar.ObjectID);
            if (avaID > 255) avaID = 0; //cool object
            */

            var avaID = station; //freeso patched. should really signal this on init.

            player.Contrib = player.Hand[item];
            ControllerClient.SendOBJEvent(new VMEODEvent((short)VMEODPizzaObjEvent.Contribute,
                (short)((short)player.Contrib.Type | (short)(avaID<<8)))); //lo: ingredient, hi: FREESO player id
            InsertCard(player.Hand[item]);
            player.Hand[item] = null;

            PlayerContributionUpdate();
        }
 public void S_RespondPhone(short evt, VMEODClient client)
 {
     if (State == VMEODPizzaState.PhoneCall) EnterState(VMEODPizzaState.Contribution);
 }
 public override void OnDisconnection(VMEODClient client)
 {
     var playerIndex = Array.IndexOf(Players, client);
     if (playerIndex != -1)
     {
         Players[playerIndex] = null;
         PizzaPlayers[playerIndex] = null;
         PlayerRosterUpdate();
     }
 }
 public void S_AllContributed(short evt, VMEODClient client)
 {
     //bake enter state will handle us not having all assigned, if that ever happens.
     if (State == VMEODPizzaState.Contribution) EnterState(VMEODPizzaState.Bake);
 }
        public override void OnConnection(VMEODClient client)
        {
            var param = client.Invoker.Thread.TempRegisters;
            if (client.Avatar != null)
            {
                //take tuning settings from object
                PhoneWaitSeconds = param[1];
                ContributionTimeoutSeconds = param[2];
                RestartDelaySeconds = param[3];
                CardsPerSmallIngredient = param[4];
                CardsPerMediumIngredient = param[5];
                CardsPerLargeIngredient = param[6];
                CardsPerBonusIngredientPerSize = param[7];

                //what part are we trying to join?
                var station = param[0];
                if (Players[station] != null)
                {
                    //what? someone's already here...
                    Server.Disconnect(client);
                }
                else
                {
                    client.Send("pizza_show", "");
                    Players[station] = client;
                    PizzaPlayers[station] = new VMEODPizzaPlayer();
                    PlayerRosterUpdate();
                }
            }
            else
            {
                //we're the pizza controller!
                ControllerClient = client;
            }
        }
 public void PlayerHandUpdate(VMEODClient client, VMEODPizzaPlayer player)
 {
     string msg = "";
     foreach (var item in player.Hand)
     {
         msg += ((item == null) ? "--" : item.ToString()) + "\n";
     }
     client.Send("pizza_hand", msg);
 }
Exemple #42
0
 public void P_Close(string evt, string text, VMEODClient client)
 {
     Server.Shutdown();
 }
Exemple #43
0
        public void B_SetMessage(string evt, byte[] data, VMEODClient client)
        {
            lock (this)
            {
                VMEODSignsData newData;
                try
                {
                    newData = new VMEODSignsData(data);
                }
                catch (Exception) { return; }

                if (Mode == VMEODSignsMode.Read) return; //cannot change anything
                else if (Mode == VMEODSignsMode.Write) newData.Flags = Data.Flags; //cannot change permissions

                if (newData.Text.Length > 0) newData.Text = newData.Text.Substring(0, Math.Min(MaxLength, newData.Text.Length));
                Data = newData;

                Server.vm.GlobalLink.SavePluginPersist(Server.vm, Server.Object.PersistID, Server.PluginID, newData.Save());

                foreach (var cli in Server.Clients)
                    cli.SendOBJEvent(new VMEODEvent((short)VMEODSignsEvent.TurnOnWritingSign, (short)((Data.Text.Length > 0) ? 1 : 0)));
            }
        }
 public void P_DanceButton(string evt, string text, VMEODClient client)
 {
     byte num = 0;
     if (!byte.TryParse(text, out num)) return;
     if (ControllerClient != null) ControllerClient.SendOBJEvent(new VMEODEvent(num, client.Avatar.ObjectID));
 }
Exemple #45
0
 public override void OnConnection(VMEODClient client)
 {
     var param = client.Invoker.Thread.TempRegisters;
     Mode = (VMEODSignsMode)param[0];
     MaxLength = param[1];
 }