コード例 #1
0
        public override void Deserialize(IGenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 1:
            {
                ICraftable.Deserialize(reader, this);

                m_Resource = (CraftResource)reader.ReadEncodedInt();

                goto case 0;
            }

            case 0:
            {
                m_BurntOut  = reader.ReadBool();
                m_Burning   = reader.ReadBool();
                m_Duration  = reader.ReadTimeSpan();
                m_Protected = reader.ReadBool();

                if (m_Burning && m_Duration != TimeSpan.Zero)
                {
                    DoTimer(reader.ReadDeltaTime() - DateTime.Now);
                }

                break;
            }
            }
        }
コード例 #2
0
ファイル: Inventory.cs プロジェクト: KernelPryanic/StateZ
		private void Craft(InventoryItemBase item, ICraftable craftable)
		{
			if (MenuType == MenuType.Player && item != null && craftable != null && (DeveloperMode || (CanCraftItem(craftable) && item.Amount < item.MaxAmount)))
			{
				FoodInventoryItem food = item as FoodInventoryItem;
				if (!DeveloperMode)
				{
					NearbyResource? nearby = food?.NearbyResource;
					NearbyResource? nullable = nearby;
					NearbyResource? nullable2 = nullable;
					if (nullable2.HasValue)
					{
						NearbyResource valueOrDefault = nullable2.GetValueOrDefault();
						if (valueOrDefault == NearbyResource.CampFire)
						{
							Prop[] props = World.GetNearbyProps(PlayerPosition, 2.5f, "prop_beach_fire");
							if (!props.Any())
							{
								UI.Notify("There's no ~g~Camp Fire~s~ nearby.");
								return;
							}
						}
					}
				}
				AddItem(item, 1, ItemType.Item);
				Array.ForEach(craftable.RequiredComponents, delegate(CraftableItemComponent c)
				{
					AddItem(c.Resource, -c.RequiredAmount, ItemType.Resource);
				});
				this.TryCraft?.Invoke(item);
			}
		}
コード例 #3
0
        public override void Deserialize(IGenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 3:
                ICraftable.Deserialize(reader, this);

                goto case 2;

            case 2:
            {
                PotionStrength = reader.ReadUInt();
                goto case 1;
            }

            case 1:
            case 0:
            {
                PotionEffect = (PotionEffect)reader.ReadInt();
                break;
            }
            }

            if (version == 0)
            {
                Stackable = false;
            }
        }
コード例 #4
0
        private void Craft(InventoryItemBase item, ICraftable craftable)
        {
            if ((uint)this.MenuType > 0U || item == null || craftable == null || !this.DeveloperMode && (!this.CanCraftItem(craftable) || item.Amount >= item.MaxAmount))
            {
                return;
            }
            FoodInventoryItem foodInventoryItem = item as FoodInventoryItem;

            if (!this.DeveloperMode)
            {
                NearbyResource?nearbyResource = foodInventoryItem?.NearbyResource;
                if (nearbyResource.HasValue && nearbyResource.GetValueOrDefault() == NearbyResource.CampFire && !((IEnumerable <Prop>)World.GetNearbyProps(Inventory.PlayerPosition, 2.5f, Model.op_Implicit("prop_beach_fire"))).Any <Prop>())
                {
                    UI.Notify("There's no ~g~Camp Fire~s~ nearby.");
                    return;
                }
            }
            this.AddItem(item, 1, ItemType.Item);
            Array.ForEach <CraftableItemComponent>(craftable.RequiredComponents, (Action <CraftableItemComponent>)(c => this.AddItem(c.Resource, -c.RequiredAmount, ItemType.Resource)));
            // ISSUE: reference to a compiler-generated field
            Inventory.CraftedItemEvent tryCraft = this.TryCraft;
            if (tryCraft == null)
            {
                return;
            }
            tryCraft(item);
        }
コード例 #5
0
 public Recipe(string name, List <Ingredient> ingredients, MethodInfo productMethod, float duration, ICraftable craftable)
 {
     Name          = name;
     Ingredients   = ingredients;
     ProductMethod = productMethod;
     Duration      = duration;
     Craftable     = craftable;
 }
コード例 #6
0
    public static Recipe GetTable(ICraftable craftable)
    {
        List <Ingredient> ingredients = new List <Ingredient>()
        {
            new Ingredient("wood", null, 2)
        };

        return(new Recipe("table", ingredients, typeof(ItemFactory).GetMethod("GetTable"), 12f, craftable));
    }
コード例 #7
0
    public static Recipe GetShotgun(ICraftable craftable)
    {
        List <Ingredient> ingredients = new List <Ingredient>()
        {
            new Ingredient("wood", null, 2), new Ingredient("stone", null, 1)
        };

        return(new Recipe("shotgun", ingredients, typeof(WeaponFactory).GetMethod("GetShotgun"), 12f, craftable));
    }
コード例 #8
0
    public static Recipe GetKebab(ICraftable craftable)
    {
        List <Ingredient> ingredients = new List <Ingredient>()
        {
            new Ingredient("Onion", null, 2), new Ingredient("Flower", null, 2)
        };

        return(new Recipe("kebab", ingredients, typeof(EquipableFactory).GetMethod("GetWoodenHelmet"), 5f, craftable));
    }
コード例 #9
0
    public static Recipe GetWoodenFaulds(ICraftable craftable)
    {
        List <Ingredient> ingredients = new List <Ingredient>()
        {
            new Ingredient("wood", null, 4)
        };

        return(new Recipe("wooden_faulds", ingredients, typeof(EquipableFactory).GetMethod("GetWoodenFaulds"), 10f, craftable));
    }
コード例 #10
0
    public string Crafting(ICraftable obj1, ICraftable obj2)
    {
        switch (obj1.GetEffects)
        {
        case effects.effect1:
            switch (obj2.GetEffects)
            {
            case effects.effect2: Debug.Log("Effetto1 + Effetto2");
                break;

            case effects.effect3: Debug.Log("Effetto1 + Effetto3");
                break;

            default: Debug.Log("Effetto non compatibile");
                break;
            }
            break;

        case effects.effect2:
            switch (obj2.GetEffects)
            {
            case effects.effect1:
                Debug.Log("Effetto2 + Effetto1");
                break;

            case effects.effect3:
                Debug.Log("Effetto2 + Effetto3");
                break;

            default:
                Debug.Log("Effetto non compatibile");
                break;
            }
            break;

        case effects.effect3:
            switch (obj2.GetEffects)
            {
            case effects.effect1:
                Debug.Log("Effetto3 + Effetto1");
                break;

            case effects.effect2:
                Debug.Log("Effetto3 + Effetto2");
                break;

            default:
                Debug.Log("Effetto non compatibile");
                break;
            }
            break;

        default:
            break;
        }
        return(string.Format("Effetto craft: {0} + {1} = ", obj1.GetCraftEffect(), obj2.GetCraftEffect()));
    }
コード例 #11
0
        public override void Serialize(IGenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write(1); // version

            ICraftable.Serialize(writer, this);

            writer.WriteEncodedInt((int)m_Resource);
        }
コード例 #12
0
        public override void Deserialize(IGenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            ICraftable.Deserialize(reader, this);

            m_Resource = (CraftResource)reader.ReadEncodedInt();
        }
コード例 #13
0
ファイル: Extensions.cs プロジェクト: ruaduck/XScript
 public static CraftResource ReadCraftResource(this ICraftable obj, List <ClilocItemRec> reader)
 {
     if (ClilocHelper.Contains(reader, 1053099))
     {
         var Value = ClilocHelper.GetParams(reader, 1053099)[0];
         return
             ((from object e in Enum.GetValues(typeof(CraftResource)) where Value.Equals(e) select e)
              .Cast <CraftResource>().FirstOrDefault());
     }
     return(CraftResource.Default);
 }
コード例 #14
0
        public override void Serialize(IGenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)3);  // version

            ICraftable.Serialize(writer, this);

            writer.Write(PotionStrength);
            writer.Write((int)PotionEffect);
        }
コード例 #15
0
    private void Update()
    {
        ICraftable Obj1 = object1.GetComponent <ICraftable>();
        ICraftable Obj2 = object2.GetComponent <ICraftable>();

        if (Obj1 != null && Obj2 != null)
        {
            Debug.Log(Crafting(Obj1, Obj2));
        }
        else
        {
            Debug.Log("Not craftable");
        }
    }
コード例 #16
0
ファイル: Inventory.cs プロジェクト: KernelPryanic/StateZ
		private bool CanCraftItem(ICraftable craftable)
		{
			if (craftable?.RequiredComponents != null)
			{
				CraftableItemComponent[] requiredComponents = craftable.RequiredComponents;
				foreach (CraftableItemComponent component in requiredComponents)
				{
					InventoryItemBase resource = component.Resource;
					if (Resources.Contains(resource) && Resources.Find((InventoryItemBase i) => resource == i)?.Amount < component.RequiredAmount)
					{
						return false;
					}
				}
				return true;
			}
			return false;
		}
コード例 #17
0
    private void CraftNow()
    {
        if (object1 != null && object2 != null)                    // Assicurati che non ci siano errori
        {
            ICraftable Obj1 = object1.GetComponent <ICraftable>(); // Prendi solo quello che ti serve
            ICraftable Obj2 = object2.GetComponent <ICraftable>();

            if (Obj1 != null && Obj2 != null)    // Un controllo in più non fa male
            {
                Debug.Log(Crafting(Obj1, Obj2)); // Stampa il risultato
            }
            else
            {
                Debug.Log("Not craftable"); // Cazzo hai messo dentro la forgia?
            }
        }
    }
コード例 #18
0
        public override void Deserialize(IGenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            if (version == 2)
            {
                ICraftable.Deserialize(reader, this);

                m_Resource = (CraftResource)reader.ReadEncodedInt();
            }

            if (version < 1 && Layer == Layer.OneHanded)
            {
                Layer = Layer.TwoHanded;
            }
        }
コード例 #19
0
        public override void Deserialize(IGenericReader reader)
        {
            base.Deserialize(reader);

            LootType = LootType.Blessed;

            int version = reader.ReadInt();

            switch (version)
            {
            case 2:
            {
                ICraftable.Deserialize(reader, this);

                goto case 1;
            }

            case 1:
            {
                m_Level = (SecureLevel)reader.ReadInt();
                goto case 0;
            }

            case 0:
            {
                int count = reader.ReadInt();

                m_Entries = new List <RunebookEntry>(count);

                for (int i = 0; i < count; ++i)
                {
                    m_Entries.Add(new RunebookEntry(reader));
                }

                m_Description  = reader.ReadString();
                m_CurCharges   = reader.ReadInt();
                m_MaxCharges   = reader.ReadInt();
                m_DefaultIndex = reader.ReadInt();

                break;
            }
            }
        }
コード例 #20
0
 public void ProcessKeys()
 {
     if ((uint)this.MenuType > 0U || !this.InventoryMenu.get_Visible())
     {
         return;
     }
     Game.DisableControlThisFrame(2, (Control)23);
     Game.DisableControlThisFrame(2, (Control)75);
     Game.DisableControlThisFrame(2, (Control)26);
     if (Game.IsDisabledControlJustPressed(2, (Control)23))
     {
         ICraftable selectedInventoryItem = this.GetSelectedInventoryItem <ICraftable>();
         if (selectedInventoryItem == null)
         {
             return;
         }
         StringBuilder str = new StringBuilder("Blueprint:\n");
         if (selectedInventoryItem.RequiredComponents == null || !((IEnumerable <CraftableItemComponent>)selectedInventoryItem.RequiredComponents).Any <CraftableItemComponent>() && !this.DeveloperMode)
         {
             return;
         }
         Array.ForEach <CraftableItemComponent>(selectedInventoryItem.RequiredComponents, (Action <CraftableItemComponent>)(i => str.Append(string.Format("{0}{1}~s~ / {2} {3}\n", i.Resource.Amount >= i.RequiredAmount ? (object)"~g~" : (object)"~r~", (object)i.Resource.Amount, (object)i.RequiredAmount, (object)i.Resource.Id))));
         UI.Notify(str.ToString());
     }
     else
     {
         if (!Game.IsDisabledControlJustPressed(2, (Control)26))
         {
             return;
         }
         InventoryItemBase selectedInventoryItem = this.GetSelectedInventoryItem <InventoryItemBase>();
         ICraftable        craftable             = selectedInventoryItem as ICraftable;
         if (selectedInventoryItem == null)
         {
             throw new NullReferenceException("item");
         }
         if (craftable == null)
         {
             return;
         }
         this.Craft(selectedInventoryItem, craftable);
     }
 }
コード例 #21
0
        public override void Serialize(IGenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)1);

            ICraftable.Serialize(writer, this);
            writer.WriteEncodedInt((int)m_Resource);

            writer.Write(m_BurntOut);
            writer.Write(m_Burning);
            writer.Write(m_Duration);
            writer.Write(m_Protected);

            if (m_Burning && m_Duration != TimeSpan.Zero)
            {
                writer.WriteDeltaTime(m_End);
            }
        }
コード例 #22
0
        public override void Serialize(IGenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)7);                // version

            ICraftable.Serialize(writer, this);

            writer.Write(IsShipwreckedItem);

            writer.Write((bool)m_TrapOnLockpick);

            writer.Write((int)m_RequiredSkill);

            writer.Write((int)m_MaxLockLevel);

            writer.Write(m_KeyValue);
            writer.Write((int)m_LockLevel);
            writer.Write((bool)m_Locked);
        }
コード例 #23
0
 private bool CanCraftItem(ICraftable craftable)
 {
     if (craftable?.RequiredComponents == null)
     {
         return(false);
     }
     foreach (CraftableItemComponent requiredComponent in craftable.RequiredComponents)
     {
         InventoryItemBase resource = requiredComponent.Resource;
         if (this.Resources.Contains(resource))
         {
             int?amount         = this.Resources.Find((Predicate <InventoryItemBase>)(i => resource == i))?.Amount;
             int requiredAmount = requiredComponent.RequiredAmount;
             if (amount.GetValueOrDefault() < requiredAmount && amount.HasValue)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
コード例 #24
0
        public override void Serialize(IGenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write(2);

            ICraftable.Serialize(writer, this);

            writer.Write((int)m_Level);

            writer.Write(m_Entries.Count);

            for (int i = 0; i < m_Entries.Count; ++i)
            {
                m_Entries[i].Serialize(writer);
            }

            writer.Write(m_Description);
            writer.Write(m_CurCharges);
            writer.Write(m_MaxCharges);
            writer.Write(m_DefaultIndex);
        }
コード例 #25
0
ファイル: Inventory.cs プロジェクト: KernelPryanic/StateZ
		public void ProcessKeys()
		{
			if (MenuType == MenuType.Player && InventoryMenu.Visible)
			{
				Game.DisableControlThisFrame(2, GTA.Control.Enter);
				Game.DisableControlThisFrame(2, GTA.Control.VehicleExit);
				Game.DisableControlThisFrame(2, GTA.Control.LookBehind);
				if (Game.IsDisabledControlJustPressed(2, GTA.Control.Enter))
				{
					ICraftable craftable = GetSelectedInventoryItem<ICraftable>();
					if (craftable != null)
					{
						StringBuilder str = new StringBuilder("Blueprint:\n");
						if (craftable.RequiredComponents != null && (craftable.RequiredComponents.Any() || DeveloperMode))
						{
							Array.ForEach(craftable.RequiredComponents, delegate(CraftableItemComponent i)
							{
								str.Append(string.Format("{0}{1}~s~ / {2} {3}\n", (i.Resource.Amount >= i.RequiredAmount) ? "~g~" : "~r~", i.Resource.Amount, i.RequiredAmount, i.Resource.Id));
							});
							UI.Notify(str.ToString());
						}
					}
				}
				else if (Game.IsDisabledControlJustPressed(2, GTA.Control.LookBehind))
				{
					InventoryItemBase item = GetSelectedInventoryItem<InventoryItemBase>();
					ICraftable craftableItem = item as ICraftable;
					if (item == null)
					{
						throw new NullReferenceException("item");
					}
					if (craftableItem != null)
					{
						Craft(item, craftableItem);
					}
				}
			}
		}
コード例 #26
0
        public override void Serialize(IGenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)4);  // version

            ICraftable.Serialize(writer, this);

            writer.WriteEncodedInt((int)m_Resource);

            writer.Write(m_ReplenishesCharges);
            if (m_ReplenishesCharges)
            {
                writer.Write(m_LastReplenished);
            }

            writer.WriteEncodedInt((int)m_Slayer);
            writer.WriteEncodedInt((int)m_Slayer2);

            writer.WriteEncodedInt((int)UsesRemaining);

            writer.WriteEncodedInt((int)m_WellSound);
            writer.WriteEncodedInt((int)m_BadlySound);
        }
コード例 #27
0
        public override void Deserialize(IGenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 4:
            {
                ICraftable.Deserialize(reader, this);

                m_Resource = (CraftResource)reader.ReadEncodedInt();

                goto case 3;
            }

            case 3:
            {
                m_ReplenishesCharges = reader.ReadBool();

                if (m_ReplenishesCharges)
                {
                    m_LastReplenished = reader.ReadDateTime();
                }

                goto case 2;
            }

            case 2:
            {
                m_Slayer  = (SlayerName)reader.ReadEncodedInt();
                m_Slayer2 = (SlayerName)reader.ReadEncodedInt();

                UsesRemaining = reader.ReadEncodedInt();

                m_WellSound  = reader.ReadEncodedInt();
                m_BadlySound = reader.ReadEncodedInt();

                break;
            }

            case 1:
            {
                m_Slayer = (SlayerName)reader.ReadEncodedInt();

                UsesRemaining = reader.ReadEncodedInt();

                m_WellSound  = reader.ReadEncodedInt();
                m_BadlySound = reader.ReadEncodedInt();

                break;
            }

            case 0:
            {
                m_WellSound   = reader.ReadInt();
                m_BadlySound  = reader.ReadInt();
                UsesRemaining = Utility.RandomMinMax(InitMinUses, InitMaxUses);

                break;
            }
            }

            CheckReplenishUses();
        }
コード例 #28
0
 private static string GetCraftedFortified(ICraftable craftable)
 {
     return(craftable is BaseHat {
         Fortified : ItemFortificationType.Fortified
     } ? "Fortified " : "");
コード例 #29
0
 public static string GetCraftableItemName(ICraftable craftable)
 {
     return
         ($"{GetCraftedFortified(craftable)}{GetCraftedExceptional(craftable)}{GetCraftedResource(craftable)}{GetItemDesc(craftable as Item)}{GetCraftedBy(craftable)}");
 }
コード例 #30
0
        private object ICanCraft(uLink.NetworkPlayer player, ICraftable recipe)
        {
            PlayerSession session = Player.Find(player);

            return(Interface.CallHook("CanCraft", session, recipe));
        }