コード例 #1
0
        void Resend(ESlotType slotType, SlotList.ChangeEvent arg)
        {
            switch (arg.op)
            {
            case SlotList.ChangeEvent.Op.Set:
                changeEventor.Dispatch(new EventArg()
                {
                    op = EventArg.Op.Put, itemObj = GetItem(slotType, arg.index)
                });
                break;

            case SlotList.ChangeEvent.Op.Reset:
                changeEventor.Dispatch(new EventArg()
                {
                    op = EventArg.Op.Reset, itemObj = GetItem(slotType, arg.index)
                });
                break;

            case SlotList.ChangeEvent.Op.Update:
                changeEventor.Dispatch(new EventArg()
                {
                    op = EventArg.Op.Update, itemObj = null
                });
                break;

            case SlotList.ChangeEvent.Op.Clear:
                break;

            case SlotList.ChangeEvent.Op.Sort:
                break;

            default:
                break;
            }
        }
コード例 #2
0
        public static int CodeIndex(ESlotType type, int slotIndex)
        {
            if (type == ESlotType.Max || slotIndex < 0)
            {
                return(InvalidIndex);
            }

            return(slotIndex | (((int)type) << 24));
        }
コード例 #3
0
        public SlotList GetSlotList(ESlotType itemClass = ESlotType.Item)
        {
            if (itemClass == ESlotType.Max)
            {
                return(null);
            }

            return(mSlotListArray[(int)itemClass]);
        }
コード例 #4
0
        public ItemObject GetItem(ESlotType slotType, int index)
        {
            SlotList slotList = GetSlotList(slotType);

            if (null == slotList)
            {
                return(null);
            }

            return(slotList[index]);
        }
コード例 #5
0
 public bool HasEquipmentAt(ESlotType slotType)
 {
     for (int i = 0; i < equipmentSlots.Length; i++)
     {
         if (equipmentSlots[i].SlotType == slotType && equipmentSlots[i].IsFilled)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #6
0
        public int GetVacancySlotIndex(ESlotType slotType)
        {
            SlotList list = GetSlotList(slotType);

            if (null == list)
            {
                return(-1);
            }

            return(list.VacancyIndex());
        }
コード例 #7
0
        public static bool DecodeIndex(int index, out ESlotType type, out int slotIndex)
        {
            type      = (ESlotType)(index >> 24);
            slotIndex = index & 0x00ffffff;

            if (index == InvalidIndex)
            {
                return(false);
            }

            return(true);
        }
コード例 #8
0
        public void Sort(ESlotType type)
        {
            SlotList slotList = GetSlotList(type);

            if (null == slotList)
            {
                return;
            }

            slotList.Reduce();
            slotList.Sort();
        }
コード例 #9
0
        public InventorySlotHud(ESlotType slotType, Texture2D texture2D, Vector2 position, float rotation, Vector2 origin, Vector2 scale)
        {
            DrawableComponents.Add("RenderComponent", new RenderComponent(this, texture2D, position, rotation, origin, scale, 1.0f));


            //We just initialize these at default values
            // DrawableComponents.Add("RenderComponent2", new RenderComponent(this, null, new Vector2(), 0.0f, new Vector2(), new Vector2(), 1.0f));
            containsItem  = false;
            this.slotType = slotType;
            item          = null;
            numberOfItems = 0;
        }
コード例 #10
0
        /// <summary>
        /// Exchanges the old equipment at this slot with the new equipment
        /// </summary>
        /// <param name="slotType">The slot where to perform the change</param>
        /// <param name="newEquipment">The new equipment</param>
        /// <returns>The old equipment if there was one</returns>
        public Equipment SetEquipmentAt(ESlotType slotType, Equipment newEquipment = null)
        {
            for (int i = 0; i < equipmentSlots.Length; i++)
            {
                if (equipmentSlots[i].SlotType == slotType)
                {
                    return(equipmentSlots[i].ChangeEquipment(newEquipment));
                }
            }

            // Shouldn't reach here if tested with HasSlot
            return(null);
        }
コード例 #11
0
        bool SetSlotList(ESlotType itemClass, SlotList list)
        {
            if (itemClass == ESlotType.Max)
            {
                return(false);
            }

            mSlotListArray[(int)itemClass] = list;

            RegisterSlotEvent(itemClass);

            return(true);
        }
コード例 #12
0
        public int PutItem(ItemObject item, int slotIndex, ESlotType slotType)
        {
            if (slotType == ESlotType.Max)
            {
                slotType = (ESlotType)item.protoData.tabIndex;
            }

            SlotList slotList = GetSlotList(slotType);

            SetItem(slotList, item, slotIndex);

            return(CodeIndex(slotType, slotIndex));
        }
コード例 #13
0
        public int FindItemIndexByProtoId(int protoId)
        {
            ESlotType eSlotType = GetSlotType(protoId);
            SlotList  slotList  = GetSlotList(eSlotType);

            if (null == slotList)
            {
                return(-1);
            }

            int index = slotList.FindItemIndexByProtoId(protoId);

            return(CodeIndex(eSlotType, index));
        }
コード例 #14
0
        public int AddItem(ItemObject itemObject, bool isNew = false)
        {
            ESlotType eSlotType    = GetSlotType(itemObject.protoId);
            SlotList  slotList     = GetSlotList(eSlotType);
            int       vacancyIndex = slotList.VacancyIndex();

            if (-1 == vacancyIndex)
            {
                return(InvalidIndex);
            }

            SetItem(slotList, itemObject, vacancyIndex, isNew);

            return(CodeIndex(eSlotType, vacancyIndex));
        }
コード例 #15
0
        List <int> getRestrictedSlots(string attach, string vehicleType, RestrictedInventory restrictedInv)
        {
            SlotRestriction[] restrictions = restrictedInv.Restrictions;
            List <int>        slots        = new List <int>();
            ESlotType         result       = ESlotType.None;

            switch (attach)
            {
            case "bumper": result = ESlotType.RoachBullBar; break;

            case "front": result = (vehicleType == "roach") ? ESlotType.RoachFrontBay : (vehicleType == "goat" ? ESlotType.GoatFrontpanel : ESlotType.KangaFrontpanel); break;

            case "rear": result = (vehicleType == "roach") ? ESlotType.RoachRearBay : (vehicleType == "goat" ? ESlotType.GoatBackpanel : ESlotType.KangaBackpanel); break;

            case "left": result = ESlotType.RoachSidePanel; break;

            case "right": result = ESlotType.RoachSidePanel; break;

            case "roof": result = ESlotType.RoachRoofBay; break;

            case "wheel":
            case "tire": result = (vehicleType == "roach") ? ESlotType.RoachWheel : (vehicleType == "goat" ? ESlotType.QuadWheel : ESlotType.KangaWheel); break;

            case "gearbox":
            case "gear": result = (vehicleType == "roach") ? ESlotType.RoachGearbox : (vehicleType == "goat" ? ESlotType.QuadGearbox : ESlotType.KangaGearbox); break;

            case "engine": result = (vehicleType == "roach") ? ESlotType.RoachEngine : (vehicleType == "goat" ? ESlotType.QuadEngine : ESlotType.KangaEngine); break;

            default: break;
            }

            for (int k = 0; k < (int)restrictions.Length; k++)
            {
                ESlotType slotRestrictionType = restrictions[k].SlotType;
                if (slotRestrictionType == result && restrictedInv.Items[restrictions[k].SlotNumber] != null)
                {
                    if ((attach == "left" && restrictions[k].SlotNumber != 0) || (attach == "right" && restrictions[k].SlotNumber != 1))
                    {
                        continue;
                    }
                    slots.Add(restrictions[k].SlotNumber);
                }
            }

            return(slots);
        }
コード例 #16
0
        public void Clear(ESlotType type = ESlotType.Max)
        {
            if (type == ESlotType.Max)
            {
                GetSlotList(ESlotType.Item).Clear();
                GetSlotList(ESlotType.Equipment).Clear();
                GetSlotList(ESlotType.Resource).Clear();
                GetSlotList(ESlotType.Armor).Clear();
            }
            else
            {
                GetSlotList(type).Clear();
            }

            changeEventor.Dispatch(new EventArg()
            {
                op = EventArg.Op.Clear, itemObj = null
            });
        }
コード例 #17
0
ファイル: ScannerColoPurify.cs プロジェクト: MgAl2O4/SINoCOLO
        protected void ScanActionSlot(FastBitmapHSV bitmap, Point slotPos, ScreenData screenData, int slotIdx)
        {
            float[]   pixelInput = ExtractActionSlotData(bitmap, slotIdx);
            ESlotType SlotType   = (ESlotType)classifierPurify.Calculate(pixelInput, out float BestPct);

            screenData.Slots[slotIdx] = SlotType;
            if (DebugLevel >= EDebugLevel.Simple)
            {
                Console.WriteLine("{0} ScanActionSlot[{1}]: {2} ({3:P2})", ScannerName, slotIdx, screenData.Slots[slotIdx], BestPct);
            }

            if (DebugLevel >= EDebugLevel.Verbose)
            {
                byte frameColor =
                    (SlotType == ESlotType.None) ? (byte)0 :
                    (SlotType == ESlotType.Locked || SlotType == ESlotType.LockedBig) ? (byte)128 :
                    (byte)255;

                DrawRectangle(bitmap, slotPos.X, slotPos.Y, 48, 96, frameColor, 1);
                if (SlotType == ESlotType.Big)
                {
                    DrawRectangle(bitmap, slotPos.X, slotPos.Y, 48, 96, frameColor, 3);
                }

                int previewX = slotPos.X + ((slotIdx < 4) ? -20 : (48 + 5));
                int previewY = slotPos.Y;
                int readIdx  = 0;
                for (int idxY = 0; idxY < 16; idxY++)
                {
                    for (int idxX = 0; idxX < 16; idxX++)
                    {
                        byte color = (byte)(pixelInput[readIdx] * 255);
                        readIdx++;

                        bitmap.SetPixel(previewX + idxX, previewY + idxY, new FastPixelHSV(color, color, color));
                    }
                }
            }
        }
コード例 #18
0
        void RegisterSlotEvent(ESlotType slotType)
        {
            SlotList list = GetSlotList(slotType);

            switch (slotType)
            {
            case ESlotType.Item:
                if (null != list)
                {
                    list.eventor.Subscribe(ItemSlotListMsgHandler);
                }
                break;

            case ESlotType.Equipment:
                if (null != list)
                {
                    list.eventor.Subscribe(EquipmentSlotListMsgHandler);
                }
                break;

            case ESlotType.Resource:
                if (null != list)
                {
                    list.eventor.Subscribe(ResourceSlotListMsgHandler);
                }
                break;

            case ESlotType.Armor:
                if (null != list)
                {
                    list.eventor.Subscribe(ArmorSlotListMsgHandler);
                }
                break;

            default:
                break;
            }
        }
コード例 #19
0
ファイル: Stairs.cs プロジェクト: wokste/LotUS-Roguelike
 public bool FitsIn(ESlotType type) => false;
コード例 #20
0
        void cmdCar(PlayerSession session, string command, string[] args)
        {
            //Check for permission to use the plugin
            if (!userHasPerm(session, "vehiclemanager.use"))
            {
                hurt.SendChatMessage(session, null, Color(GetMsg("msg_SERVER"), "red") + GetMsg("msg_permission").Replace("{perm}", "vehiclemanager.use"));
                return;
            }

            var allVsm = Resources.FindObjectsOfTypeAll <VehicleStatManager>().ToList();
            VehicleOwnershipManager vom           = Singleton <VehicleOwnershipManager> .Instance;
            VehicleControllerBase   controller    = null;
            RestrictedInventory     restrictedInv = null;
            VehicleStatManager      vsm           = getVSMs(session, vom, allVsm, true)?[0];

            if (args.Length == 0)
            {
                if (!GetConfig(true, "ShowDistanceCommand"))
                {
                    hurt.SendChatMessage(session, null, Color(GetMsg("msg_SERVER"), "red") + GetMsg("msg_showDistanceCMD"));
                    return;
                }
                var playerVSMs = getVSMs(session, vom, allVsm, false);
                if (playerVSMs != null && playerVSMs.Count > 0)
                {
                    foreach (var playerVSM in playerVSMs)
                    {
                        double distance    = getPlayerToCarDistance(session, playerVSM);
                        string distanceMsg = string.Format("{0:0}m", (int)Math.Ceiling(distance));
                        int    index       = playerVSM.gameObject.name.IndexOf('(');
                        string vehicleName = playerVSM.gameObject.name.Substring(0, index);
                        hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_vehicleDistance").Replace("{vehicle}", vehicleName).Replace("{distance}", distanceMsg));
                    }
                }
                else
                {
                    hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_noClaim"));
                }
            }
            else if (args.Length == 1)
            {
                if (args[0] == "claim")
                {
                    if (vsm != null)
                    {
                        if (vsm.Owner == null)
                        {
                            controller = vsm.GetComponent <VehicleControllerBase>();
                            if (!controller.IsKittedOut())
                            {
                                Singleton <AlertManager> .Instance.GenericTextNotificationServer("Alerts/Not Drivable", session.Player);

                                return;
                            }
                            if (!vom.HasClaim(session.Identity))
                            {
                                hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_claimWithButtom"));
                                return;
                            }

                            List <VehicleStatManager> playerVSM = (from v in allVsm where v.Owner == session.Identity select v).ToList();
                            if (playerVSM.Count >= GetConfig(1, "MaxVehicleClaimsPerPlayer"))
                            {
                                hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_maxClaim").Replace("{number}", playerVSM.Count + ""));
                                return;
                            }

                            vsm.Owner = session.Identity;
                            Singleton <AlertManager> .Instance.GenericTextNotificationServer("Sucessfully claimed", session.Player);
                        }
                        else
                        {
                            Singleton <AlertManager> .Instance.GenericTextNotificationServer("Alerts/Already Owned", session.Player);
                        }
                    }
                    else
                    {
                        hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_notInsideVehicle"));
                    }
                }
                else if (args[0] == "unclaim")
                {
                    if (vsm != null)
                    {
                        if (vsm.Owner != null && vsm.Owner == session.Identity)
                        {
                            if (vom.GetClaimant(vsm) != string.Empty)       //unclaim official vehicle
                            {
                                vom.Unclaim(session.Identity);
                            }
                            else                                            //unclaim one of additional vehicles
                            {
                                vsm.Owner = null;
                            }
                            Singleton <AlertManager> .Instance.GenericTextNotificationServer("Sucessfully unclaimed", session.Player);
                        }
                        else
                        {
                            Singleton <AlertManager> .Instance.GenericTextNotificationServer("Alerts/Not Owner", session.Player);
                        }
                    }
                    else
                    {
                        hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_notInsideVehicle"));
                    }
                }
                else if (args[0] == "help" || args[0] == "h")
                {
                    // /car help | h

                    string[] commands =
                    {
                        Color(GetMsg("carCmds_AVAILABLE"), "orange"),
                        Color("/car ",                     "orange") + GetMsg("carCmds_carInfo"),
                        Color("/car install <1-8> ",       "orange") + GetMsg("carCmds_install"),
                        Color("/car install <1-8> <L|R> ", "orange") + GetMsg("carCmds_installLR"),
                        Color("/car remove <attach> ",     "orange") + GetMsg("carCmds_remove"),
                        Color("/car remove <attach> ",     "orange") + GetMsg("carCmds_removeExtra"),
                        Color("/car claim ",               "orange") + GetMsg("carCmds_claim"),
                        Color("/car unclaim ",             "orange") + GetMsg("carCmds_unclaim")
                    };

                    foreach (string cmd in commands)
                    {
                        hurt.SendChatMessage(session, null, cmd);
                    }
                }
                else
                {
                    hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_carInfo"));
                }
            }
            else if (args.Length == 2 || (args.Length == 3 && (args[2].ToLower() == "l" || args[2].ToLower() == "r")))
            {
                //Get vehicle type (roach or goat) and RestrictedInventory
                string vehicleType = "";
                if (vsm != null)
                {
                    if (vsm.Owner == null || vsm.Owner == session.Identity)
                    {
                        controller    = vsm.GetComponent <VehicleControllerBase>();
                        restrictedInv = controller.GetComponent <RestrictedInventory>();

                        //Get vehicle type
                        string tmp = vsm.name.ToLower();
                        if (tmp.Contains("roach"))
                        {
                            vehicleType = "roach";
                        }
                        else if (tmp.Contains("kanga"))
                        {
                            vehicleType = "kanga";
                        }
                        else if (tmp.Contains("goat"))
                        {
                            vehicleType = "goat";
                        }
                    }
                    else
                    {
                        hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_notOwner"));
                        return;
                    }
                }
                else
                {
                    hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_notInsideVehicle"));
                    return;
                }
                if (args[0] == "install")
                {
                    //Check for permission to install
                    if (!userHasPerm(session, "vehiclemanager.install"))
                    {
                        hurt.SendChatMessage(session, null, Color(GetMsg("msg_SERVER"), "red") + GetMsg("msg_permission").Replace("{perm}", "vehiclemanager.install"));
                        return;
                    }

                    // /car install 1-8 [mandatory for side panels: L|R]
                    //Check if player is installing a correct vehicle attachment
                    int slot = -1;
                    if (!int.TryParse(args[1], out slot) || slot < 1 || slot > 8)
                    {
                        hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_carInfo"));
                        return;
                    }
                    PlayerInventory playerInventory       = session.WorldPlayerEntity.GetComponent <PlayerInventory>();
                    var             playerInventory_items = playerInventory.Items;
                    var             playerItemInstance    = playerInventory_items[slot - 1];
                    if (playerItemInstance != null)
                    {
                        IItem     item           = playerItemInstance.Item;
                        ESlotType itemSlotType   = getSlotType(item);
                        string    slotTypeString = itemSlotType.ToString().ToLower();
                        if (!slotTypeString.Contains(vehicleType))
                        {
                            if ((vehicleType == "roach" && slotTypeString.Contains("goat")) ||
                                (vehicleType == "goat" && slotTypeString.Contains("roach")) ||
                                (vehicleType == "kanga" && slotTypeString.Contains("kanga")))
                            {
                                hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_notCorrectVehicleAttachment").Replace("{vehicleType}", vehicleType));
                            }
                            else
                            {
                                hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_notVehicleAttachment"));
                            }
                            return;
                        }
                        if (itemSlotType == ESlotType.RoachSidePanel)
                        {
                            if (args.Length == 2 || (args.Length == 3 && (args[2].ToLower() != "l" && args[2].ToLower() != "r")))
                            {
                                hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_roachSideIncorrect"));
                                hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_carInfo"));
                                return;
                            }
                        }
                        //Correct item. Can install/switch.
                        //Check if vehicle has the same attachment type installed. If not, install player's item. If yes, switch with player's item.
                        if (controller != null)
                        {
                            if (restrictedInv != null)
                            {
                                SlotRestriction[] restrictions = restrictedInv.Restrictions;
                                for (int k = 0; k < (int)restrictions.Length; k++)
                                {
                                    ESlotType slotRestrictionType = restrictions[k].SlotType;
                                    if (slotRestrictionType == itemSlotType)
                                    {
                                        if (itemSlotType == ESlotType.RoachSidePanel && !sideMatchWithSlot(k, args[2].ToLower()))
                                        {
                                            continue;
                                        }
                                        //Found correct slot type
                                        if (restrictedInv.Items[restrictions[k].SlotNumber] == null)
                                        {
                                            //Vehicle doesn't have attachment on that slot. Can install.
                                            vehicleInstall(session, playerItemInstance, restrictedInv, restrictions[k].SlotNumber);
                                            hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_vehicleInstall").Replace("{attachInstalled}", Color(playerItemInstance.Item.GetNameKey(), "orange")).Replace("{vehicleType}", vehicleType));
                                        }
                                        else
                                        {
                                            //Vehicle have attachment on that slot. Can switch.
                                            string attachSwitched = vehicleSwitch(session, playerItemInstance, restrictedInv, restrictions[k].SlotNumber);
                                            hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_vehicleSwitch").Replace("{attachSwitched}", Color(attachSwitched, "orange")).Replace("{vehicleType}", vehicleType).Replace("{attachInstalled}", Color(playerItemInstance.Item.GetNameKey(), "orange")));
                                        }
                                        restrictedInv.Invalidate(false);
                                        return;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_noCarAttachment").Replace("{slot}", slot + ""));
                    }
                }
                else if (args[0] == "remove")
                {
                    // /car remove bumper|front|left|right|roof|rear|tire|engine|gearbox

                    string tmp = args[1];

                    //Check for permission to remove.extra
                    if (tmp == "gear" || tmp == "gearbox" || tmp == "engine" || tmp == "tire" || tmp == "wheel")
                    {
                        if (!userHasPerm(session, "vehiclemanager.remove.extra"))
                        {
                            hurt.SendChatMessage(session, null, Color(GetMsg("msg_SERVER"), "red") + GetMsg("msg_permission").Replace("{perm}", "vehiclemanager.remove.extra"));
                            return;
                        }
                    }
                    //Check for permission to remove
                    if (tmp == "bumper" || tmp == "front" || tmp == "left" || tmp == "right" || tmp == "roof" || tmp == "rear" || tmp == "all")
                    {
                        if (!userHasPerm(session, "vehiclemanager.remove"))
                        {
                            hurt.SendChatMessage(session, null, Color(GetMsg("msg_SERVER"), "red") + GetMsg("msg_permission").Replace("{perm}", "vehiclemanager.remove"));
                            return;
                        }
                    }

                    List <string> parts;
                    if (tmp == "all")
                    {
                        parts = new List <string> {
                            "bumper", "front", "left", "right", "roof", "rear"
                        };
                    }
                    else
                    {
                        parts = new List <string> {
                            tmp
                        }
                    };

                    bool ignorePart = false;
                    foreach (string attach in parts)
                    {
                        ignorePart = false;
                        //Cannot remove rear if a player is on the vehicle rear
                        if (attach == "rear" || attach == "front")
                        {
                            List <VehiclePassenger> passengers = GameObjectExtensions.GetComponentsByInterfaceInChildren <VehiclePassenger>(vsm.gameObject).ToList();
                            foreach (VehiclePassenger p in passengers)
                            {
                                if (p.Passenger != null)
                                {
                                    string seat = getSeatName(p.SeatOffset);
                                    if (attach == seat)
                                    {
                                        hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_removeSeatError").Replace("{seat}", seat));
                                        ignorePart = true;
                                        break;
                                    }
                                }
                            }
                        }

                        if (ignorePart)
                        {
                            continue;
                        }
                        //Get the restrictedSlots relative to vehicle attachment player wants to remove
                        List <int> restrictedSlots = getRestrictedSlots(attach, vehicleType, restrictedInv);
                        var        im = GlobalItemManager.Instance;
                        foreach (int slot in restrictedSlots)
                        {
                            //Give vehicle attach to player inventory
                            ItemInstance vehicleAttach = restrictedInv.Items[slot];
                            im.GiveItem(session.Player, vehicleAttach.Item, 1);
                            //Remove attachment from vehicle.
                            restrictedInv.Items[slot] = null;
                            restrictedInv.Invalidate(false);
                            if (tmp != "all")
                            {
                                hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_vehicleRemove").Replace("{attachRemoved}", Color(vehicleAttach.Item.GetNameKey(), "orange")).Replace("{vehicleType}", vehicleType));
                            }
                        }
                        if (restrictedSlots.Count == 0)
                        {
                            if (tmp != "all")
                            {
                                hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_removeError").Replace("{attach}", attach));
                            }
                        }
                    }
                    if (tmp == "all")
                    {
                        hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_vehicleRemoveAll").Replace("{vehicleType}", vehicleType));
                    }
                }
                else
                {
                    hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_carInfo"));
                }
            }
            else
            {
                hurt.SendChatMessage(session, null, Color(GetMsg("msg_INFO"), "orange") + GetMsg("msg_carInfo"));
            }
        }
コード例 #21
0
 public Armor(int damageReduction, ESlotType slotType)
 {
     DamageReduction = damageReduction;
     SlotType        = slotType;
 }
コード例 #22
0
        /*
         * item:            The item to add if its not already in the list. If it is in the list we only increase the number of this item
         * numberOfItems:   How many of this item we add. Invalid to send in a value that is less than 1
         * slotType:        The slot which we want to insert this item into
         * returns true if it was successfully inserted
         * */
        public bool insertItem(ItemHud item, int numberOfItems, ESlotType slotType)
        {
            if (numberOfItems > 0)
            {
                foreach (InventorySlotHud slotHud in slots)
                {
                    if (slotHud.getSlotType() == slotType)
                    {
                        int id = -1;

                        if (!slotHud.getContainsItem())
                        {
                            //Console.WriteLine("Insert");
                            Vector2   position = slotHud.Properties.getProperty <Vector2>("Position");
                            Texture2D texture  = item.Properties.getProperty <Texture2D>("Texture2D");
                            float     rotation = item.Properties.getProperty <float>("Rotation");
                            Vector2   origin   = item.Properties.getProperty <Vector2>("Origin");
                            Vector2   scale    = item.Properties.getProperty <Vector2>("Scale");

                            ItemHud newItem = new ItemHud(item.getItemType(), texture, position, rotation, origin, scale);

                            slotHud.setItemHud(newItem);
                            slotHud.setContainsItem(true);

                            if (slotType == ESlotType.OTHER)
                            {
                                slotHud.setNumberOfItems(slotHud.getNumberOfItems() + numberOfItems);

                                //Checks what type of item we are adding to the inventory
                                if (newItem.getItemType() == EItemType.SCREW)
                                {
                                    id = 0;
                                }
                                else if (newItem.getItemType() == EItemType.OILCAN)
                                {
                                    id = 1;
                                }
                                else if (newItem.getItemType() == EItemType.CEMENT)
                                {
                                    id = 2;
                                }
                                else if (newItem.getItemType() == EItemType.APPLE)
                                {
                                    id = 3;
                                }
                                else if (newItem.getItemType() == EItemType.CORN)
                                {
                                    id = 4;
                                }
                                else if (newItem.getItemType() == EItemType.TREEGUN)
                                {
                                    id = 5;
                                }
                                else if (newItem.getItemType() == EItemType.SHOVEL)
                                {
                                    id = 6;
                                }
                                else if (newItem.getItemType() == EItemType.PICKAXE)
                                {
                                    id = 7;
                                }

                                //Adds the font associated with this item
                                SceneManager.getInstance.getFontManager().addFont(new Font(EFontType.STATIC, id, "FontInventory", ResourceManager.getInstance.Font2, slotHud.getNumberOfItems() + "",
                                                                                           new Vector2(position.X + 4.0f, position.Y - 35.0f), Color.Red, -1.0f));
                            }

                            return(true);
                        }
                        else if (slotHud.getContainsItem() && slotHud.getItemHud().Equals(item))
                        {
                            //Console.WriteLine("Count up");

                            if (slotType == ESlotType.OTHER)
                            {
                                slotHud.setNumberOfItems(slotHud.getNumberOfItems() + numberOfItems);

                                //Checks what type of item we are adding to the inventory
                                if (item.getItemType() == EItemType.SCREW)
                                {
                                    id = 0;
                                }
                                else if (item.getItemType() == EItemType.OILCAN)
                                {
                                    id = 1;
                                }
                                else if (item.getItemType() == EItemType.CEMENT)
                                {
                                    id = 2;
                                }
                                else if (item.getItemType() == EItemType.APPLE)
                                {
                                    id = 3;
                                }
                                else if (item.getItemType() == EItemType.CORN)
                                {
                                    id = 4;
                                }
                                else if (item.getItemType() == EItemType.TREEGUN)
                                {
                                    id = 5;
                                }
                                else if (item.getItemType() == EItemType.SHOVEL)
                                {
                                    id = 6;
                                }
                                else if (item.getItemType() == EItemType.PICKAXE)
                                {
                                    id = 7;
                                }

                                //Adds the font associated with this item
                                SceneManager.getInstance.getFontManager().addFont(new Font(EFontType.STATIC, id, "FontInventory", ResourceManager.getInstance.Font2, slotHud.getNumberOfItems() + "",
                                                                                           new Vector2(slotHud.Properties.getProperty <Vector2>("Position").X + 4.0f,
                                                                                                       slotHud.Properties.getProperty <Vector2>("Position").Y - 35.0f), Color.Red, -1.0f));
                            }
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
コード例 #23
0
 public Equipment(BaseEquipment baseEquipment)
 {
     Name       = baseEquipment.Name;
     Attributes = new Attributes(baseEquipment.Attributes);
     SlotType   = baseEquipment.SlotType;
 }
コード例 #24
0
        /*
         * item:            The item to add if its not already in the list. If it is in the list we only increase the number of this item
         * numberOfItems:   How many of this item we add. Invalid to send in a value that is less than 1
         * slotType:        The slot which we want to insert this item into
         * returns true if it was successfully inserted
         * */
        public bool insertItem(ItemHud item, int numberOfItems, ESlotType slotType)
        {
            if (numberOfItems > 0)
            {
                foreach (InventorySlotHud slotHud in slots)
                {
                    if (slotHud.getSlotType() == slotType)
                    {
                        int id = -1;

                        if (!slotHud.getContainsItem())
                        {
                            //Console.WriteLine("Insert");
                            Vector2 position = slotHud.Properties.getProperty<Vector2>("Position");
                            Texture2D texture = item.Properties.getProperty<Texture2D>("Texture2D");
                            float rotation = item.Properties.getProperty<float>("Rotation");
                            Vector2 origin = item.Properties.getProperty<Vector2>("Origin");
                            Vector2 scale = item.Properties.getProperty<Vector2>("Scale");

                            ItemHud newItem = new ItemHud(item.getItemType(), texture, position, rotation, origin, scale);

                            slotHud.setItemHud(newItem);
                            slotHud.setContainsItem(true);

                            if (slotType == ESlotType.OTHER)
                            {
                                slotHud.setNumberOfItems(slotHud.getNumberOfItems() + numberOfItems);

                                //Checks what type of item we are adding to the inventory
                                if (newItem.getItemType() == EItemType.SCREW)
                                {
                                    id = 0;
                                }
                                else if (newItem.getItemType() == EItemType.OILCAN)
                                {
                                    id = 1;
                                }
                                else if (newItem.getItemType() == EItemType.CEMENT)
                                {
                                    id = 2;
                                }
                                else if (newItem.getItemType() == EItemType.APPLE)
                                {
                                    id = 3;
                                }
                                else if (newItem.getItemType() == EItemType.CORN)
                                {
                                    id = 4;
                                }
                                else if (newItem.getItemType() == EItemType.TREEGUN)
                                {
                                    id = 5;
                                }
                                else if (newItem.getItemType() == EItemType.SHOVEL)
                                {
                                    id = 6;
                                }
                                else if (newItem.getItemType() == EItemType.PICKAXE)
                                {
                                    id = 7;
                                }

                                //Adds the font associated with this item
                                SceneManager.getInstance.getFontManager().addFont(new Font(EFontType.STATIC, id, "FontInventory", ResourceManager.getInstance.Font2, slotHud.getNumberOfItems() + "",
                                    new Vector2(position.X + 4.0f, position.Y - 35.0f), Color.Red, -1.0f));
                            }

                            return true;
                        }
                        else if (slotHud.getContainsItem() && slotHud.getItemHud().Equals(item))
                        {
                            //Console.WriteLine("Count up");

                            if (slotType == ESlotType.OTHER)
                            {
                                slotHud.setNumberOfItems(slotHud.getNumberOfItems() + numberOfItems);

                                //Checks what type of item we are adding to the inventory
                                if (item.getItemType() == EItemType.SCREW)
                                {
                                    id = 0;
                                }
                                else if (item.getItemType() == EItemType.OILCAN)
                                {
                                    id = 1;
                                }
                                else if (item.getItemType() == EItemType.CEMENT)
                                {
                                    id = 2;
                                }
                                else if (item.getItemType() == EItemType.APPLE)
                                {
                                    id = 3;
                                }
                                else if (item.getItemType() == EItemType.CORN)
                                {
                                    id = 4;
                                }
                                else if (item.getItemType() == EItemType.TREEGUN)
                                {
                                    id = 5;
                                }
                                else if (item.getItemType() == EItemType.SHOVEL)
                                {
                                    id = 6;
                                }
                                else if (item.getItemType() == EItemType.PICKAXE)
                                {
                                    id = 7;
                                }

                                //Adds the font associated with this item
                                SceneManager.getInstance.getFontManager().addFont(new Font(EFontType.STATIC, id, "FontInventory", ResourceManager.getInstance.Font2, slotHud.getNumberOfItems() + "",
                                    new Vector2(slotHud.Properties.getProperty<Vector2>("Position").X + 4.0f,
                                        slotHud.Properties.getProperty<Vector2>("Position").Y - 35.0f), Color.Red, -1.0f));

                            }
                            return true;
                        }
                    }
                }
            }
            return false;
        }
コード例 #25
0
        private void DoInstall(PlayerSession session, string[] args, string vehicleType, VehicleInventory vehicleInventory)
        {
            string steamId = session.SteamId.ToString();

            if (!permission.UserHasPermission(steamId, InstallPermission))
            {
                Player.Message(session, GetMsg("NoPermission", steamId).Replace("{permission}", InstallPermission));
                return;
            }

            //Check if player is installing a correct vehicle attachment
            int slot;

            if (!int.TryParse(args[1], out slot) || slot < 1 || slot > 8)
            {
                Player.Message(session, GetMsg("HelpCommand", steamId));
                return;
            }

            PlayerInventory playerInventory  = session.WorldPlayerEntity.GetComponent <PlayerInventory>();
            ItemObject      playerItemObject = playerInventory.GetSlot(slot - 1);

            if (playerItemObject != null)
            {
                ESlotType itemSlotType = GetSlotType(playerItemObject);

                string slotTypeString = itemSlotType.ToString().ToLower();
                Puts(slotTypeString);
                if (!slotTypeString.Contains(vehicleType))
                {
                    Player.Message(session, GetMsg("NotVehicleAttachment", steamId));
                    return;
                }

                //Correct item. Can install/switch.
                //Check if vehicle has the same attachment type installed. If not, install player's item. If yes, switch with player's item.
                bool updated     = false;
                bool notSwitched = false;
                for (int slotNumber = 0; slotNumber < vehicleInventory.StorageConfig.Slots.Length; ++slotNumber)
                {
                    StorageSlotConfig storageSlotConfig = vehicleInventory.StorageConfig.Slots[slotNumber];
                    if (storageSlotConfig.SlotRestrictions.Contains(itemSlotType))
                    {
                        ItemObject switchslot = vehicleInventory.GetSlot(storageSlotConfig.SlotNumber);
                        if (switchslot == null)
                        {
                            //Vehicle doesn't have attachment on that slot. Can install.
                            VehicleInstall(session, playerItemObject, vehicleInventory, storageSlotConfig.SlotNumber);
                            Player.Message(session, GetMsg("VehicleInstall", steamId).Replace("{attachInstalled}", playerItemObject.Generator.name).Replace("{vehicleType}", GetMsg("vehicles/" + vehicleType)));
                            updated = true;
                        }
                        else
                        {
                            ItemObject vehicleAttach = vehicleInventory.GetSlot(storageSlotConfig.SlotNumber);
                            if (RuntimeHurtDB.Instance.GetGuid(vehicleAttach.Generator) == RuntimeHurtDB.Instance.GetGuid(playerItemObject.Generator))
                            {
                                notSwitched = true;
                                continue;
                            }
                            else
                            {
                                //Vehicle have attachment on that slot. Can switch.
                                string attachSwitched = VehicleSwitch(session, playerItemObject, vehicleInventory, storageSlotConfig.SlotNumber);
                                Player.Message(session, GetMsg("VehicleSwitch", steamId).Replace("{attachSwitched}", attachSwitched).Replace("{vehicleType}", GetMsg("vehicles/" + vehicleType)).Replace("{attachInstalled}", playerItemObject.Generator.name));
                                updated = true;
                            }
                        }
                        vehicleInventory.Invalidate(false);
                    }
                    if (updated)
                    {
                        break;
                    }
                }
                if (notSwitched && !updated)
                {
                    Player.Message(session, GetMsg("VehicleAttachmentAlreadyInstalled", steamId).Replace("{attachment}", playerItemObject.Generator.name));
                }
            }
            else
            {
                Player.Message(session, GetMsg("NoAttachmentFound", steamId).Replace("{slot}", slot.ToString()));
            }
        }
コード例 #26
0
 public bool FitsIn(ESlotType type)
 {
     return(false);
 }
コード例 #27
0
 public BaseEquipment()
 {
     Name       = "";
     Attributes = new BaseAttributes();
     SlotType   = ESlotType.Head;
 }
コード例 #28
0
 public EquipmentSlot(ESlotType slotType, Equipment equipment = null)
 {
     SlotType       = slotType;
     this.equipment = equipment;
 }