コード例 #1
0
 /// <summary>
 /// Use to spawn an item into the game world as if dropped by this player, but only spawns it locally.
 /// You may notice that the vanilla game's source-code uses Resources.Load to spawn items. You should not use that.
 /// </summary>
 /// <param name="pos">The position to spawn the item at. Note that despite being a 2D game, Roguelands uses 3D space. That being said, the z-coordinate should nearly always be 0.</param>
 /// <param name="item">The item to spawn.</param>
 /// <param name="isChip">True to drop a chip instead of a normal item.</param>
 public static ItemScript DropItemLocal(Vector3 pos, Item item, bool isChip = false)
 {
     if (!isChip)
     {
         int[]      st         = ConstructIntArrayFromItem(item);
         ItemScript itemScript = ((GameObject)UnityEngine.Object.Instantiate(Resources.Load("i2"), pos, Quaternion.identity)).GetComponent <ItemScript>();
         itemScript.SendMessage("InitL", st);
         if (ItemRegistry.GetSingleton().HasEntry(item.id) && (ItemRegistry.GetSingleton().GetEntry(item.id).Type & ItemType.EQUIPABLE) == ItemType.EQUIPABLE)
         {
             itemScript.back.SetActive(true);
         }
         return(itemScript);
     }
     else
     {
         ItemScript itemScript = ((GameObject)UnityEngine.Object.Instantiate(Resources.Load("i2"), pos, Quaternion.identity)).GetComponent <ItemScript>();
         itemScript.SendMessage("ChipL", item.id);
         return(itemScript);
     }
 }
コード例 #2
0
 /// <summary>
 /// Constructs a new VanillaItemInfo based upon the given ID. Do not try to call this yourself - use <see cref="Wrap"/>
 /// </summary>
 /// <param name="ID">The vanilla ID to be wrapped.</param>
 protected VanillaTileInfo(int ID) : base(TileRegistry.GetDefaultTypeByID(ID), GadgetCoreAPI.GetTileMaterial(ID), TileRegistry.GetDefaultTypeByID(ID) == TileType.INTERACTIVE ? GadgetCoreAPI.GetPlaceableNPCResource(ID) : GadgetCoreAPI.GetPropResource(ID), ItemRegistry.GetSingleton().HasEntry(ID) ? ItemRegistry.GetSingleton().GetEntry(ID) : VanillaItemInfo.WrapForTile(ID, false))
 {
     this.ID = ID;
 }