Beispiel #1
0
    public void CreateShredResources()
    {
        if (currentlyShredding == null)
        {
            return;
        }
        MagnetLiftable component = currentlyShredding.GetComponent <MagnetLiftable>();

        if (component == null)
        {
            return;
        }
        ItemAmount[] shredResources = component.shredResources;
        foreach (ItemAmount itemAmount in shredResources)
        {
            Item  item = ItemManager.Create(itemAmount.itemDef, (int)itemAmount.amount, 0uL);
            float num  = 0.5f;
            if (item.CreateWorldObject(resourceSpawnPoint.transform.position + new Vector3(Random.Range(0f - num, num), 1f, Random.Range(0f - num, num))) == null)
            {
                item.Remove();
            }
        }
        BaseModularVehicle component2 = currentlyShredding.GetComponent <BaseModularVehicle>();

        if (!component2)
        {
            return;
        }
        foreach (BaseVehicleModule attachedModuleEntity in component2.AttachedModuleEntities)
        {
            if (!attachedModuleEntity.AssociatedItemDef || !attachedModuleEntity.AssociatedItemDef.Blueprint)
            {
                continue;
            }
            foreach (ItemAmount ingredient in attachedModuleEntity.AssociatedItemDef.Blueprint.ingredients)
            {
                int num2 = Mathf.FloorToInt(ingredient.amount * 0.5f);
                if (num2 != 0)
                {
                    Item  item2 = ItemManager.Create(ingredient.itemDef, num2, 0uL);
                    float num3  = 0.5f;
                    if (item2.CreateWorldObject(resourceSpawnPoint.transform.position + new Vector3(Random.Range(0f - num3, num3), 1f, Random.Range(0f - num3, num3))) == null)
                    {
                        item2.Remove();
                    }
                }
            }
        }
    }
 public virtual void ModuleAdded(BaseModularVehicle vehicle, int firstSocketIndex)
 {
     Vehicle                 = vehicle;
     FirstSocketIndex        = firstSocketIndex;
     TimeSinceAddedToVehicle = 0f;
     if (base.isServer)
     {
         TriggerParent[] array = triggerParents;
         for (int i = 0; i < array.Length; i++)
         {
             array[i].associatedMountable = vehicle;
         }
         SendNetworkUpdate();
     }
     RefreshConditionals(false);
 }