예제 #1
0
        public float GetPriorityStateGroup(MyClientInfo client)
        {
            MyClientState state = (MyClientState)client.State;

            if (Inventory.ForcedPriority.HasValue)
            {
                return(Inventory.ForcedPriority.Value);
            }

            if (state.ContextEntity != null)
            {
                MyCubeGrid parent = state.ContextEntity.GetTopMostParent() as MyCubeGrid;

                if (parent != null)
                {
                    foreach (var block in parent.GridSystems.TerminalSystem.Blocks)
                    {
                        if (block == Inventory.Container.Entity)
                        {
                            if (state.Context == Sandbox.Engine.Multiplayer.MyClientState.MyContextKind.Production && (block is MyAssembler) == false)
                            {
                                continue;
                            }
                            return(1.0f);
                        }
                    }
                }
                else if (state.ContextEntity == Inventory.Owner)
                {
                    return(1.0f);
                }
            }
            return(0);
        }
예제 #2
0
        public float GetGroupPriority(int frameCountWithoutSync, MyClientInfo client)
        {
            ProfilerShort.Begin("MyEntityInventoryStateGroup::GetGroupPriority");
            InventoryClientData            clientData = m_clientInventoryUpdate[client.EndpointId.Value];
            List <MyPhysicalInventoryItem> items      = Inventory.GetItems();

            if (clientData.Dirty == false && clientData.FailedIncompletePackets.Count == 0)
            {
                ProfilerShort.End();
                return(-1);
            }

            if (clientData.FailedIncompletePackets.Count > 0)
            {
                ProfilerShort.End();
                return(1.0f * frameCountWithoutSync);
            }

            MyClientState state = (MyClientState)client.State;

            if (Inventory.Owner is MyCharacter)
            {
                MyCharacter character = Inventory.Owner as MyCharacter;
                MyPlayer    player    = MyPlayer.GetPlayerFromCharacter(character);

                if (player == null && character.IsUsing != null)
                {
                    MyShipController cockpit = (character.IsUsing as MyShipController);
                    if (cockpit != null && cockpit.ControllerInfo.Controller != null)
                    {
                        player = cockpit.ControllerInfo.Controller.Player;
                    }
                }

                if (player != null && player.Id.SteamId == client.EndpointId.Value)
                {
                    ProfilerShort.End();
                    return(1.0f * frameCountWithoutSync);
                }
            }

            if (state.ContextEntity is MyCharacter && state.ContextEntity == Inventory.Owner)
            {
                ProfilerShort.End();
                return(1.0f * frameCountWithoutSync);
            }

            if (state.Context == MyClientState.MyContextKind.Inventory || state.Context == MyClientState.MyContextKind.Building ||
                (state.Context == MyClientState.MyContextKind.Production && Inventory.Owner is MyAssembler))
            {
                ProfilerShort.End();
                return(GetPriorityStateGroup(client) * frameCountWithoutSync);
            }

            ProfilerShort.End();
            return(0);
        }
        public float GetGroupPriority(int frameCountWithoutSync, MyClientStateBase client)
        {
            InventoryClientData clientData = m_clientInventoryUpdate[client.EndpointId.Value];

            MyClientState state = client as MyClientState;

            if (Inventory.Owner is MyCharacter && m_clientInventoryUpdate[client.EndpointId.Value].Dirty)
            {
                MyPlayer player = MyPlayer.GetPlayerFromCharacter(Inventory.Owner as MyCharacter);
                if (player != null && player.Id.SteamId == client.EndpointId.Value)
                {
                    return(1.0f);
                }
            }

            if (m_clientInventoryUpdate[client.EndpointId.Value].Dirty && (state.Context == MyClientState.MyContextKind.Inventory ||
                                                                           (state.Context == MyClientState.MyContextKind.Production && Inventory.Owner is MyAssembler)))
            {
                return(Inventory.GetPriorityStateGroup(client));
            }
            return(0);
        }