This repository has been archived by the owner on May 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModdedFood.cs
106 lines (91 loc) · 3.75 KB
/
ModdedFood.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using Oxide.Core;
using System;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using System.Linq;
using UnityEngine;
using System.Collections.Generic;
namespace Oxide.Plugins
{
[Info("ModdedFood", "Auro", "1.0.0")]
[Description("Replaces burnt food variants with special ones")]
public class ModdedFood : RustPlugin
{
string craftPerm = "moddedfood.craft";
void Init()
{
permission.RegisterPermission(craftPerm, this);
}
enum Foods
{
Pizza
}
[ChatCommand("craft")]
void CraftCommand(BasePlayer player, string command, string[] args)
{
if (!permission.UserHasPermission(player.UserIDString, craftPerm))
{
SendReply(player, "You don't have permission to use this command");
return;
}
RaycastHit hit;
var raycast = Physics.Raycast(player.eyes.HeadRay(), out hit, 5f);
BaseEntity entity = raycast ? hit.GetEntity() : null;
if (entity == null)
{
SendReply(player, "You need to be looking at a barbeque");
return;
}
if (entity is StorageContainer)
{
var container = entity as StorageContainer;
if (container.name == "assets/prefabs/deployable/bbq/bbq.deployed.prefab")
{
if (!args.Any())
{
SendReply(player, "You need to specify a food to craft");
return;
}
switch (args[0])
{
case "pizza":
var pizza = ItemManager.CreateByName("bearmeat.burned", 1, 1902068186);
pizza.name = "Pizza";
ItemModConsumable component = (ItemModConsumable)((Component)pizza.info).GetComponent<ItemModConsumable>();
foreach (var effect in component.effects)
{
Puts($"{effect.type} - {effect.amount}");
if (effect.type == MetabolismAttribute.Type.HealthOverTime)
{
effect.amount = 100f;
}
}
pizza.info.GetComponent<ItemModConsumable>().effects = component.effects;
player.inventory.GiveItem(pizza);
break;
case "burger":
var burger = ItemManager.CreateByName("deermeat.burned", 1, 2668022576);
burger.name = "Burger";
ItemModConsumable component2 = (ItemModConsumable)((Component)burger.info).GetComponent<ItemModConsumable>();
foreach (var effect in component2.effects)
{
Puts($"{effect.type} - {effect.amount}");
if (effect.type == MetabolismAttribute.Type.HealthOverTime)
{
effect.amount = 100f;
}
}
burger.info.GetComponent<ItemModConsumable>().effects = component2.effects;
player.inventory.GiveItem(burger);
break;
}
}
else
{
SendReply(player, "You need to be looking at a barbeque");
return;
}
}
}
}
}