Beispiel #1
0
            public SendQueueEntry( GameClient ns, HouseFoundation foundation, DesignState state )
            {
                m_NetState = ns;
                m_Serial = foundation.Serial;
                m_Revision = state.Revision;
                m_Root = state;

                MultiComponentList mcl = state.Components;

                m_xMin = mcl.Min.X;
                m_yMin = mcl.Min.Y;
                m_xMax = mcl.Max.X;
                m_yMax = mcl.Max.Y;

                m_Tiles = mcl.List;
            }
Beispiel #2
0
        public DesignStateGeneral( HouseFoundation house, DesignState state )
            : base(0xBF)
        {
            EnsureCapacity( 13 );

            m_Stream.Write( (short) 0x1D );
            m_Stream.Write( (int) house.Serial );
            m_Stream.Write( (int) state.Revision );
        }
Beispiel #3
0
        public DesignState( DesignState toCopy )
        {
            m_Foundation = toCopy.m_Foundation;
            m_Components = new MultiComponentList( toCopy.m_Components );
            m_Revision = toCopy.m_Revision;
            m_Fixtures = new MultiTileEntry[toCopy.m_Fixtures.Length];

            for ( int i = 0; i < m_Fixtures.Length; ++i )
                m_Fixtures[i] = toCopy.m_Fixtures[i];
        }
Beispiel #4
0
 public static void SendDetails( GameClient ns, HouseFoundation house, DesignState state )
 {
     m_SendQueue.Enqueue( new SendQueueEntry( ns, house, state ) );
     m_Sync.Set();
 }
Beispiel #5
0
        public void EndConfirmCommit( Mobile from )
        {
            if ( this.Deleted )
                return;

            int oldPrice = Price;
            int newPrice = oldPrice + ( ( DesignState.Components.List.Length - CurrentState.Components.List.Length ) * 500 );
            int cost = newPrice - oldPrice;

            if ( cost >= 0 )
            {
                if ( Banker.Withdraw( from, cost ) )
                {
                    from.SendLocalizedMessage( 1060398, cost.ToString() ); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
                }
                else
                {
                    from.SendLocalizedMessage( 1061903 ); // You cannot commit this house design, because you do not have the necessary funds in your bank box to pay for the upgrade.  Please back up your design, obtain the required funds, and commit your design again.
                    return;
                }
            }
            else
            {
                if ( Banker.Deposit( from, -cost ) )
                    from.SendLocalizedMessage( 1060397, ( -cost ).ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box.
                else
                    return;
            }

            /* Client chose to commit current design state
             *  - Commit design state
             *     - Construct a copy of the current design state
             *     - Clear visible fixtures
             *     - Melt fixtures from constructed state
             *     - Add melted fixtures from constructed state
             *     - Assign constructed state to foundation
             *  - Update house price
             *  - Remove design context
             *  - Notify the client that customization has ended
             *  - Notify the core that the foundation has changed and should be resent to all clients
             *  - If a signpost is needed, add it
             *  - Eject all from house
             *  - Restore relocated entities
             */

            // Commit design state : Construct a copy of the current design state
            DesignState copyState = new DesignState( DesignState );

            // Commit design state : Clear visible fixtures
            ClearFixtures( from );

            // Commit design state : Melt fixtures from constructed state
            copyState.MeltFixtures();

            // Commit design state : Add melted fixtures from constructed state
            AddFixtures( from, copyState.Fixtures );

            // Commit design state : Assign constructed state to foundation
            CurrentState = copyState;

            // Update house price
            Price = newPrice;

            // Remove design context
            DesignContext.Remove( from );

            // Notify the client that customization has ended
            from.Send( new EndHouseCustomization( this ) );

            // Notify the core that the foundation has changed and should be resent to all clients
            Delta( ItemDelta.Update );
            ProcessDelta();
            CurrentState.SendDetailedInfoTo( from.Client );

            // If a signpost is needed, add it
            CheckSignpost();

            // Eject all from house
            from.RevealingAction();

            foreach ( Item item in GetItems() )
                item.Location = BanLocation;

            foreach ( Mobile mobile in GetMobiles() )
                mobile.Location = BanLocation;

            // Restore relocated entities
            RestoreRelocatedEntities();
        }
Beispiel #6
0
 public void SetInitialState()
 {
     // This is a new house, it has not yet loaded a design state
     m_Current = new DesignState( this, GetEmptyFoundation() );
     m_Design = new DesignState( m_Current );
     m_Backup = new DesignState( m_Current );
 }
Beispiel #7
0
        public override void Deserialize( GenericReader reader )
        {
            int version = reader.ReadInt();

            switch ( version )
            {
                case 5:
                case 4:
                    {
                        m_Signpost = reader.ReadItem();
                        m_SignpostGraphic = reader.ReadInt();

                        goto case 3;
                    }
                case 3:
                    {
                        m_Type = (FoundationType) reader.ReadInt();

                        goto case 2;
                    }
                case 2:
                    {
                        m_SignHanger = reader.ReadItem();

                        goto case 1;
                    }
                case 1:
                    {
                        if ( version < 5 )
                            m_DefaultPrice = reader.ReadInt();

                        goto case 0;
                    }
                case 0:
                    {
                        if ( version < 3 )
                            m_Type = FoundationType.Stone;

                        if ( version < 4 )
                            m_SignpostGraphic = 9;

                        m_LastRevision = reader.ReadInt();
                        m_Fixtures = reader.ReadItemList();

                        m_Current = new DesignState( this, reader );
                        m_Design = new DesignState( this, reader );
                        m_Backup = new DesignState( this, reader );

                        break;
                    }
            }

            base.Deserialize( reader );
        }
Beispiel #8
0
        public static void Designer_Revert( GameClient state, IEntity e, EncodedReader pvSrc )
        {
            Mobile from = state.Mobile;
            DesignContext context = DesignContext.Find( from );

            if ( context != null )
            {
                /* Client chose to revert design state to currently visible state
                 *  - Revert design state
                 *     - Construct a copy of the current visible state
                 *     - Freeze fixtures in constructed state
                 *     - Assign constructed state to foundation
                 *     - If a signpost is needed, add it
                 *  - Update revision
                 *  - Update client with new state
                 */

                // Revert design state : Construct a copy of the current visible state
                DesignState copyState = new DesignState( context.Foundation.CurrentState );

                // Revert design state : Freeze fixtures in constructed state
                copyState.FreezeFixtures();

                // Revert design state : Assign constructed state to foundation
                context.Foundation.DesignState = copyState;

                // Revert design state : If a signpost is needed, add it
                context.Foundation.CheckSignpost();

                // Update revision
                copyState.OnRevised();

                // Update client with new state
                context.Foundation.SendInfoTo( state );
                copyState.SendDetailedInfoTo( state );
            }
        }
Beispiel #9
0
        public static void Designer_Restore( GameClient state, IEntity e, EncodedReader pvSrc )
        {
            Mobile from = state.Mobile;
            DesignContext context = DesignContext.Find( from );

            if ( context != null )
            {
                /* Client chose to restore design to the last backup state
                 *  - Restore backup
                 *     - Construct new design state from backup state
                 *     - Assign constructed state to foundation
                 *  - Update revision
                 *  - Update client with new state
                 */

                // Restore backup : Construct new design state from backup state
                DesignState backupDesign = new DesignState( context.Foundation.BackupState );

                // Restore backup : Assign constructed state to foundation
                context.Foundation.DesignState = backupDesign;

                // Update revision;
                backupDesign.OnRevised();

                // Update client with new state
                context.Foundation.SendInfoTo( state );
                backupDesign.SendDetailedInfoTo( state );
            }
        }
Beispiel #10
0
        public static void Designer_Clear( GameClient state, IEntity e, EncodedReader pvSrc )
        {
            Mobile from = state.Mobile;
            DesignContext context = DesignContext.Find( from );

            if ( context != null )
            {
                /* Client chose to clear the design
                 *  - Restore empty foundation
                 *     - Construct new design state from empty foundation
                 *     - Assign constructed state to foundation
                 *  - Update revision
                 *  - Update client with new state
                 */

                // Restore empty foundation : Construct new design state from empty foundation
                DesignState newDesign = new DesignState( context.Foundation, context.Foundation.GetEmptyFoundation() );

                // Restore empty foundation : Assign constructed state to foundation
                context.Foundation.DesignState = newDesign;

                // Update revision
                newDesign.OnRevised();

                // Update client with new state
                context.Foundation.SendInfoTo( state );
                newDesign.SendDetailedInfoTo( state );
            }
        }
Beispiel #11
0
        public static void Designer_Backup( GameClient state, IEntity e, EncodedReader pvSrc )
        {
            Mobile from = state.Mobile;
            DesignContext context = DesignContext.Find( from );

            if ( context != null )
            {
                /* Client chose to backup design state
                 *  - Construct a copy of the current design state
                 *  - Assign constructed state to backup state field
                 */

                // Construct a copy of the current design state
                DesignState copyState = new DesignState( context.Foundation.DesignState );

                // Assign constructed state to backup state field
                context.Foundation.BackupState = copyState;
            }
        }