Пример #1
0
 private void Awake()
 {
     pick             = GetComponent <Pickupable>();
     spriteHandler    = spriteObject.GetComponent <SpriteHandler>();
     itemAttributesV2 = gameObject.GetComponent <ItemAttributesV2>();
     pick.RefreshUISlotImage();
 }
Пример #2
0
        private void Awake()
        {
            attributes         = GetComponent <ItemAttributesV2>();
            bloodReagentStored = BloodStoredMax;             //Organs spawn in oxygenated.
            health             = maxHealth;
            //If gendered part then set the sprite limb data to it
            if (isDimorphic)
            {
                switch (gender)
                {
                case Gender.Male:
                    limbSpriteData = maleSprite;
                    break;

                case Gender.Female:
                    limbSpriteData = femaleSprite;
                    break;

                case Gender.NonBinary:
                    limbSpriteData = nonbinarySprite;
                    break;

                default:
                    //TODO: error log
                    limbSpriteData = nonbinarySprite;                             //set NB as fallbackk
                    break;
                }
            }

            Initialise();
        }
Пример #3
0
    private void EnsureInit()
    {
        if (pickupable != null)
        {
            return;
        }

        pickupable   = GetComponent <Pickupable>();
        itemAtts     = GetComponent <ItemAttributesV2>();
        registerTile = GetComponent <RegisterTile>();
        fireSource   = GetComponent <FireSource>();

        reagentContainer = GetComponent <ReagentContainer>();
        if (reagentContainer != null)
        {
            reagentContainer.OnSpillAllContents.AddListener(ServerEmptyWelder);
        }

        damageOff = itemAtts.ServerHitDamage;

        //leftHandOriginal = itemAtts.inHandReferenceLeft;
        //rightHandOriginal = itemAtts.inHandReferenceRight;

        leftHandFlame  = leftHandOriginal + 4;
        rightHandFlame = rightHandOriginal + 4;
    }
Пример #4
0
 private void Awake()
 {
     pick             = GetComponent <Pickupable>();
     spriteHandler    = GetComponentInChildren <SpriteHandler>();
     itemAttributesV2 = GetComponent <ItemAttributesV2>();
     pick.RefreshUISlotImage();
 }
Пример #5
0
 private void Awake()
 {
     spriteHandlerController = GetComponent <SpriteHandlerController>();
     myItem       = GetComponent <ItemAttributesV2>();
     myPickupable = GetComponent <Pickupable>();
     TryInit();
 }
Пример #6
0
    public void ServerPerformInteraction(InventoryApply interaction)
    {
        //is the target item chopable?
        ItemAttributesV2 attr       = interaction.TargetObject.GetComponent <ItemAttributesV2>();
        Ingredient       ingredient = new Ingredient(attr.ArticleName);
        GameObject       cut        = CraftingManager.Logs.FindRecipe(new List <Ingredient> {
            ingredient
        });

        if (cut != null)
        {
            Inventory.ServerDespawn(interaction.TargetSlot);

            SpawnResult spwn = Spawn.ServerPrefab(CraftingManager.Logs.FindOutputMeal(cut.name),
                                                  SpawnDestination.At(), 1);

            if (spwn.Successful)
            {
                //foreach (GameObject obj in spwn.GameObjects)
                //{
                //	Inventory.ServerAdd(obj,interaction.TargetSlot);
                //}

                Inventory.ServerAdd(spwn.GameObject, interaction.TargetSlot);
            }
        }
        else
        {
            Chat.AddExamineMsgFromServer(interaction.Performer, "You can't chop this.");
        }
    }
Пример #7
0
        private RightClickMenuItem CreateObjectMenu(GameObject forObject)
        {
            var label = forObject.ExpensiveName();

            // check if is a paletted item
            ItemAttributesV2 item    = forObject.GetComponent <ItemAttributesV2>();
            List <Color>     palette = null;

            if (item != null)
            {
                if (item.ItemSprites.IsPaletted)
                {
                    palette = item.ItemSprites.Palette;
                }
            }

            // See if this object has an AirLockAnimator then try to get the sprite from that, otherwise try to get the sprite from the first renderer we find
            var airLockAnimator = forObject.GetComponentInChildren <AirLockAnimator>();
            var spriteRenderer  = airLockAnimator != null ? airLockAnimator.doorbase : forObject.GetComponentInChildren <SpriteRenderer>();

            Sprite sprite = null;

            if (spriteRenderer != null)
            {
                sprite = spriteRenderer.sprite;
            }
            else
            {
                Logger.LogWarningFormat("Could not determine sprite to use for right click menu" +
                                        " for object {0}. Please manually configure a sprite in a RightClickAppearance component" +
                                        " on this object.", Category.UserInput, forObject.name);
            }

            return(RightClickMenuItem.CreateObjectMenuItem(forObject, ButtonColor, sprite, null, label, spriteRenderer.color, palette));
        }
Пример #8
0
    private void getEncryptionTypeFromHier()
    {
        ItemAttributesV2 attr = GetComponent <ItemAttributesV2>();

        //switch (attr.hierarchy)
        //{
        //	case "/obj/item/device/radio/headset":
        //		EncryptionKey = EncryptionKeyType.Common;
        //		break;
        //	case "/obj/item/device/radio/headset/heads/captain":
        //	case "/obj/item/device/radio/headset/heads/captain/alt":
        //		EncryptionKey = EncryptionKeyType.Captain;
        //		break;
        //	case "/obj/item/device/radio/headset/heads/ce":
        //		EncryptionKey = EncryptionKeyType.ChiefEngineer;
        //		break;
        //	case "/obj/item/device/radio/headset/heads/cmo":
        //		EncryptionKey = EncryptionKeyType.ChiefMedicalOfficer;
        //		break;
        //	case "/obj/item/device/radio/headset/heads/hop":
        //		EncryptionKey = EncryptionKeyType.HeadOfPersonnel;
        //		break;
        //	case "/obj/item/device/radio/headset/heads/hos":
        //	case "/obj/item/device/radio/headset/heads/hos/alt":
        //		EncryptionKey = EncryptionKeyType.HeadOfSecurity;
        //		break;
        //	case "/obj/item/device/radio/headset/heads/rd":
        //		EncryptionKey = EncryptionKeyType.ResearchDirector;
        //		break;
        //	case "/obj/item/device/radio/headset/headset_cargo":
        //		EncryptionKey = EncryptionKeyType.Supply;
        //		break;
        //	case "/obj/item/device/radio/headset/headset_cent":
        //	case "/obj/item/device/radio/headset/headset_cent/alt":
        //		EncryptionKey = EncryptionKeyType.CentComm;
        //		break;
        //	case "/obj/item/device/radio/headset/headset_eng":
        //		EncryptionKey = EncryptionKeyType.Engineering;
        //		break;
        //	case "/obj/item/device/radio/headset/headset_med":
        //		EncryptionKey = EncryptionKeyType.Medical;
        //		break;
        //	case "/obj/item/device/radio/headset/headset_sci":
        //		EncryptionKey = EncryptionKeyType.Science;
        //		break;
        //	case "/obj/item/device/radio/headset/headset_sec":
        //	case "/obj/item/device/radio/headset/headset_sec/alt":
        //		EncryptionKey = EncryptionKeyType.Security;
        //		break;
        //	case "/obj/item/device/radio/headset/headset_srv":
        //		EncryptionKey = EncryptionKeyType.Service;
        //		break;
        //	case "/obj/item/device/radio/headset/syndicate/alt":
        //		EncryptionKey = EncryptionKeyType.Syndicate;
        //		break;
        //	default:
        //		EncryptionKey = EncryptionKeyType.Common;
        //		break;
        //}
    }
Пример #9
0
    /// <summary>
    /// Players can check the remaining microwave time or insert something into the microwave.
    /// </summary>
    public void ServerPerformInteraction(HandApply interaction)
    {
        if (microwave.microwaveTimer > 0)
        {
            Chat.AddExamineMsgFromServer(interaction.Performer, $"{microwave.microwaveTimer:0} seconds until the {microwave.meal} is cooked.");
        }
        else if (interaction.HandObject != null)
        {
            // Check if the player is holding food that can be cooked
            ItemAttributesV2 attr       = interaction.HandObject.GetComponent <ItemAttributesV2>();
            Ingredient       ingredient = new Ingredient(attr.ArticleName);
            GameObject       meal       = CraftingManager.Meals.FindRecipe(new List <Ingredient> {
                ingredient
            });

            if (meal)
            {
                microwave.ServerSetOutputMeal(meal.name);
                Despawn.ServerSingle(interaction.HandObject);
                microwave.RpcStartCooking();
                Chat.AddExamineMsgFromServer(interaction.Performer, $"You microwave the {microwave.meal} for {microwave.COOK_TIME} seconds.");
            }
            else
            {
                Chat.AddExamineMsgFromServer(interaction.Performer, $"Your {attr.ArticleName} can not be microwaved.");
                // Alternative suggestions:
                // "$"The microwave is not programmed to cook your {attr.ArticleName}."
                // "$"The microwave does not know how to cook your{attr.ArticleName}."
            }
        }
        else
        {
            Chat.AddExamineMsgFromServer(interaction.Performer, "The microwave is empty.");
        }
    }
Пример #10
0
    private void EnsureInit()
    {
        if (spriteRenderer != null)
        {
            return;
        }
        pickupable     = GetComponent <Pickupable>();
        spriteRenderer = GetComponentInChildren <SpriteRenderer>();
        itemAttributes = GetComponentInChildren <ItemAttributesV2>();

        //aid for lazy people. you don't have to fill out fields for name and sprite in their default state
        if (initialState == EmptyFullStatus.Empty && EmptySprite == null)
        {
            EmptySprite = spriteRenderer.sprite;
        }
        else if (initialState == EmptyFullStatus.Full && FullSprite == null)
        {
            FullSprite = spriteRenderer.sprite;
        }

        if (initialState == EmptyFullStatus.Empty && string.IsNullOrEmpty(EmptyName))
        {
            EmptyName = itemAttributes.ArticleName;
        }
        else if (initialState == EmptyFullStatus.Full && string.IsNullOrEmpty(FullName))
        {
            FullName = itemAttributes.ArticleName;
        }
    }
Пример #11
0
    public void ServerPerformInteraction(InventoryApply interaction)
    {
        //is the target item cuttable?
        ItemAttributesV2 attr       = interaction.TargetObject.GetComponent <ItemAttributesV2>();
        Ingredient       ingredient = new Ingredient(attr.ArticleName);
        GameObject       roll       = CraftingManager.Roll.FindRecipe(new List <Ingredient> {
            ingredient
        });

        if (roll)
        {
            Inventory.ServerDespawn(interaction.TargetSlot);

            SpawnResult spwn = Spawn.ServerPrefab(CraftingManager.Roll.FindOutputMeal(roll.name),
                                                  SpawnDestination.At(), 1);

            if (spwn.Successful)
            {
                Inventory.ServerAdd(spwn.GameObject, interaction.TargetSlot);
            }
        }
        else
        {
            Chat.AddExamineMsgFromServer(interaction.Performer, "You can't roll this out.");
        }
    }
Пример #12
0
 private void Awake()
 {
     spriteHandler = GetComponentInChildren <SpriteHandler>();
     itemAttComp   = gameObject.GetComponent <ItemAttributesV2>();
     gunComp       = gameObject.GetComponent <Gun>();
     spriteHandler.ChangeSprite(0);
 }
Пример #13
0
    public bool ServerTryRemove(GameObject InGameObject, bool Destroy = false, Vector3?DroppedAtWorldPositionOrThrowVector = null,
                                bool Throw = false)
    {
        ItemAttributesV2 item = InGameObject.GetComponent <ItemAttributesV2>();

        if (item == null)
        {
            return(false);
        }
        IEnumerable <ItemSlot> slots = GetItemSlots();

        HealthV2.BodyPart mobHealth = InGameObject.GetComponent <HealthV2.BodyPart>();
        foreach (var slot in slots)
        {
            if (slot.Item.OrNull()?.gameObject == InGameObject)
            {
                if (mobHealth != null)
                {
                    if (mobHealth.CurrentBurnDamageLevel == TraumaDamageLevel.CRITICAL)
                    {
                        _ = Spawn.ServerPrefab(ashPrefab, mobHealth.HealthMaster.gameObject.RegisterTile().WorldPosition);
                        _ = Despawn.ServerSingle(slot.Item.gameObject);
                        return(true);
                    }
                }
                if (Destroy)
                {
                    return(Inventory.ServerDespawn(slot));
                }
                else
                {
                    if (Throw)
                    {
                        if (DroppedAtWorldPositionOrThrowVector != null)
                        {
                            return(Inventory.ServerThrow(slot, DroppedAtWorldPositionOrThrowVector.GetValueOrDefault()));
                        }
                        else
                        {
                            return(Inventory.ServerThrow(slot, Vector2.zero));
                        }
                    }
                    else
                    {
                        if (DroppedAtWorldPositionOrThrowVector != null)
                        {
                            return(Inventory.ServerDrop(slot, DroppedAtWorldPositionOrThrowVector.GetValueOrDefault()));
                        }
                        else
                        {
                            return(Inventory.ServerDrop(slot));
                        }
                    }
                }
            }
        }

        return(false);
    }
Пример #14
0
        /// <summary>
        /// Returns true if given food is in this creatures food preferences.
        /// Mobs with no food preferences will return true for any edible object.
        /// </summary>
        /// <param name="food"></param>
        /// <returns></returns>
        public bool IsInFoodPreferences(ItemAttributesV2 food)
        {
            if (hasFoodPrefereces == false)
            {
                return(food.gameObject.GetComponent <Edible>() != null);
            }

            return(foodPreferences.Any(food.HasTrait));
        }
Пример #15
0
    /// <summary>
    /// Returns true if given food is in this creatures food preferences.
    /// Mobs with no food preferences will return true for any edible object.
    /// </summary>
    /// <param name="food"></param>
    /// <returns></returns>
    public bool IsInFoodPreferences(ItemAttributesV2 food)
    {
        if (!hasFoodPrefereces)
        {
            return(food.gameObject.GetComponent <Edible>() != null);
        }

        return(foodInitialNames.Contains(food.InitialName));
    }
Пример #16
0
        /* This region is legacy, because it relies on the timer ending to cook the food.
         * It also uses a different system for cooking; the crafting system and not via the Cookable component.
         */

        public GameObject GetMeal(GameObject item)
        {
            ItemAttributesV2 itemAttributes = item.GetComponent <ItemAttributesV2>();
            Ingredient       ingredient     = new Ingredient(itemAttributes.ArticleName);

            return(CraftingManager.Meals.FindRecipe(new List <Ingredient> {
                ingredient
            }));
        }
Пример #17
0
    //invoked when the server recieves the interaction request and WIllinteract returns true
    public void ServerPerformInteraction(HandApply interaction)
    {
        ItemAttributesV2 attr = interaction.TargetObject.GetComponent <ItemAttributesV2>();

        if (attr.HasTrait(CommonTraits.Instance.Transforamble))
        {
            Spawn.ServerPrefab(TransformTo, interaction.TargetObject.RegisterTile().WorldPositionServer);
            Despawn.ServerSingle(interaction.TargetObject);
        }
    }
Пример #18
0
    public void Awake()
    {
        itemAttributes = GetComponent <ItemAttributesV2>();
        if (color == (int)SwordColor.Random)
        {
            color = Random.Range(1, 5);
        }

        worldRenderer.SetActive(false);
    }
Пример #19
0
 private void Awake()
 {
     itemAttributes = GetComponent <ItemAttributesV2>();
     lightControl   = GetComponent <ItemLightControl>();
     spriteHandler  = GetComponentInChildren <SpriteHandler>();
     if (color == SwordColor.Random)
     {
         // Get random color
         color = (SwordColor)Enum.GetValues(typeof(SwordColor)).GetValue(Random.Range(1, 5));
     }
 }
Пример #20
0
        public bool WillInteract(InventoryApply interaction, NetworkSide side)
        {
            // standard validation for interaction
            if (DefaultWillInteract.Default(interaction, side) == false || !interaction.TargetObject)
            {
                return(false);
            }

            ItemAttributesV2 attr = interaction.TargetObject.GetComponent <ItemAttributesV2>();

            return(attr.HasTrait(LightableSurface) && interaction.Intent == Intent.Harm);
        }
Пример #21
0
    public void Awake()
    {
        itemAttributes          = GetComponent <ItemAttributesV2>();
        spriteHandlerController = GetComponent <SpriteHandlerController>();
        pickupable = GetComponent <Pickupable>();
        if (color == (int)SwordColor.Random)
        {
            color = Random.Range(1, 5);
        }

        worldRenderer.SetActive(false);
    }
Пример #22
0
 public void RefreshParts(IDictionary <GameObject, int> partsInFrame)
 {
     // Get the machine stock parts used in this instance and get the tier of each part.
     // Collection is unorganized so run through the whole list.
     foreach (GameObject part in partsInFrame.Keys)
     {
         ItemAttributesV2 partAttributes = part.GetComponent <ItemAttributesV2>();
         if (partAttributes.HasTrait(MachinePartsItemTraits.Instance.MicroLaser))
         {
             laserTier = part.GetComponent <StockTier>().Tier;
         }
     }
 }
Пример #23
0
 private void Awake()
 {
     itemAttributes = GetComponent <ItemAttributesV2>();
     stackable      = GetComponent <Stackable>();
     if (itemAttributes)
     {
         itemAttributes.AddTrait(CommonTraits.Instance.Food);
     }
     else
     {
         Logger.LogErrorFormat("{0} prefab is missing ItemAttributes", Category.ItemSpawn, name);
     }
 }
Пример #24
0
    /// <summary>
    /// Players can check the remaining microwave time or insert something into the microwave.
    /// </summary>
    public void ServerPerformInteraction(HandApply interaction)
    {
        if (microwave.MicrowaveTimer > 0)
        {
            Chat.AddExamineMsgFromServer(interaction.Performer, $"{microwave.MicrowaveTimer:0} seconds until the {microwave.meal} is cooked.");
        }
        else if (interaction.HandObject != null)
        {
            // Check if the player is holding food that can be cooked
            ItemAttributesV2 attr       = interaction.HandObject.GetComponent <ItemAttributesV2>();
            Ingredient       ingredient = new Ingredient(attr.ArticleName);

            GameObject meal = CraftingManager.Meals.FindRecipe(new List <Ingredient> {
                ingredient
            });

            if (meal)
            {
                // HACK: Currently DOES NOT check how many items are used per meal
                // Blindly assumes each single item in a stack produces a meal

                //If food item is stackable, set output amount to equal input amount.
                Stackable stck = interaction.HandObject.GetComponent <Stackable>();
                if (stck != null)
                {
                    microwave.ServerSetOutputStackAmount(stck.Amount);
                }
                else
                {
                    microwave.ServerSetOutputStackAmount(1);
                }

                microwave.ServerSetOutputMeal(meal.name);
                Despawn.ServerSingle(interaction.HandObject);
                microwave.RpcStartCooking();
                microwave.MicrowaveTimer = microwave.COOK_TIME;
                Chat.AddExamineMsgFromServer(interaction.Performer, $"You microwave the {microwave.meal} for {microwave.COOK_TIME} seconds.");
            }
            else
            {
                Chat.AddExamineMsgFromServer(interaction.Performer, $"Your {attr.ArticleName} can not be microwaved.");
                // Alternative suggestions:
                // "$"The microwave is not programmed to cook your {attr.ArticleName}."
                // "$"The microwave does not know how to cook your{attr.ArticleName}."
            }
        }
        else
        {
            Chat.AddExamineMsgFromServer(interaction.Performer, "The microwave is empty.");
        }
    }
 /// <summary>
 /// Players can check the remaining microwave time or insert something into the microwave.
 /// </summary>
 public void ServerPerformInteraction(HandApply interaction)
 {
     if (interaction.HandObject != null)
     {
         // Check if the player is holding food that can be ground up
         ItemAttributesV2  attr       = interaction.HandObject.GetComponent <ItemAttributesV2>();
         Ingredient        ingredient = new Ingredient(attr.ArticleName);
         Chemistry.Reagent meal       = CraftingManager.Grind.FindReagentRecipe(new List <Ingredient> {
             ingredient
         });
         int count = CraftingManager.Grind.FindReagentAmount(new List <Ingredient> {
             ingredient
         });
         if (meal)
         {
             grinder.SetServerStackAmount(count);
             grinder.ServerSetOutputMeal(meal.name);
             Despawn.ServerSingle(interaction.HandObject);
             Chat.AddExamineMsgFromServer(interaction.Performer, $"You grind the {attr.ArticleName}.");
             GetComponent <AIOGrinder>().GrindFood();
         }
         else
         {
             Chat.AddExamineMsgFromServer(interaction.Performer, $"Your {attr.ArticleName} can not be ground up.");
         }
     }
     else
     {
         if (!grinderStorage.IsEmpty)
         {
             if (grinderStorage.ReagentMixTotal == grinderStorage.AmountOfReagent(grinderStorage.MajorMixReagent))
             {
                 Chat.AddExamineMsgFromServer(interaction.Performer,
                                              $"The grinder currently contains {grinderStorage.ReagentMixTotal} " +
                                              $"of {grinderStorage.MajorMixReagent}.");
             }
             else if (grinderStorage.ReagentMixTotal != grinderStorage.AmountOfReagent(grinderStorage.MajorMixReagent))
             {
                 Chat.AddExamineMsgFromServer(interaction.Performer,
                                              $"The grinder currently contains {grinderStorage.AmountOfReagent(grinderStorage.MajorMixReagent)} " +
                                              $"of {grinderStorage.MajorMixReagent}, as well as " +
                                              $"{grinderStorage.ReagentMixTotal - grinderStorage.AmountOfReagent(grinderStorage.MajorMixReagent)} of various other things.");
             }
         }
         else
         {
             Chat.AddExamineMsgFromServer(interaction.Performer, "The grinder is empty.");
         }
     }
 }
Пример #26
0
    void Awake()
    {
        pickupable       = GetComponent <Pickupable>();
        reagentContainer = GetComponent <ReagentContainer>();
        itemAtts         = GetComponent <ItemAttributesV2>();
        registerTile     = GetComponent <RegisterTile>();

        damageOff = itemAtts.ServerHitDamage;

        //leftHandOriginal = itemAtts.inHandReferenceLeft;
        //rightHandOriginal = itemAtts.inHandReferenceRight;

        leftHandFlame  = leftHandOriginal + 4;
        rightHandFlame = rightHandOriginal + 4;
    }
Пример #27
0
    private void EnsureInit()
    {
        if (itemAttributes != null)
        {
            return;
        }
        itemAttributes          = GetComponent <ItemAttributesV2>();
        spriteHandlerController = GetComponent <SpriteHandlerController>();
        pickupable = GetComponent <Pickupable>();
        if (color == (int)SwordColor.Random)
        {
            color = Random.Range(1, 5);
        }

        worldRenderer.SetActive(false);
    }
Пример #28
0
    private void EnsureInit()
    {
        if (pickupable != null)
        {
            return;
        }

        pickupable   = GetComponent <Pickupable>();
        itemAtts     = GetComponent <ItemAttributesV2>();
        registerTile = GetComponent <RegisterTile>();

        radioMessager = GetComponent <RadioMessager>();
        radioReceiver = GetComponent <RadioReceiver>();

        hackDevice = GetComponent <HackingDevice>();
    }
Пример #29
0
        private void Awake()
        {
            FoodContents   = GetComponent <ReagentContainer>();
            item           = GetComponent <RegisterItem>();
            itemAttributes = GetComponent <ItemAttributesV2>();
            stackable      = GetComponent <Stackable>();

            if (itemAttributes != null)
            {
                itemAttributes.AddTrait(CommonTraits.Instance.Food);
            }
            else
            {
                Logger.LogErrorFormat("{0} prefab is missing ItemAttributes", Category.Objects, name);
            }
        }
Пример #30
0
    private bool IsEVACompatible()
    {
        if (playerScript == null)
        {
            return(false);
        }

        ItemAttributesV2 headItem = playerScript.ItemStorage.GetNamedItemSlot(NamedSlot.head).ItemAttributes;
        ItemAttributesV2 suitItem = playerScript.ItemStorage.GetNamedItemSlot(NamedSlot.outerwear).ItemAttributes;

        if (headItem != null && suitItem != null)
        {
            return(headItem.IsEVACapable && suitItem.IsEVACapable);
        }

        return(false);
    }