-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStarvationSystem.cs
71 lines (62 loc) · 1.9 KB
/
StarvationSystem.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
// Decompiled with JetBrains decompiler
// Type: StarvationMod.StarvationSystem
// Assembly: StarvingMod, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 4A15FDF5-21E3-4CB5-8573-C3144BA04543
// Assembly location: C:\Users\admin\Downloads\StarvationMod\StarvationMod.dll
using StarvationMod.Api;
using UnityEngine;
namespace StarvationMod
{
public class StarvationSystem
{
private Player player;
private bool isStarving = false;
private bool effectActive = false;
private float interval = 30f;
private float damage = 5f;
private float timer;
private float deltaTime = Time.deltaTime;
public void setPlayerInstance(ref Player playerInstance) => this.player = playerInstance;
public bool checkUpdate() => Object.op_Inequality((Object) this.player, (Object) null) && !((Character) this.player).IsDead();
public void update()
{
if ((double) this.timer >= (double) this.interval)
this.damageTick();
else
this.timer += this.deltaTime;
}
private void effectTick()
{
if (!this.isStarving && this.effectActive)
{
GLOBAL.playerApi.removeStatusEffect(StatusEffectList.Starving);
this.effectActive = false;
}
else
{
if (!this.isStarving || this.effectActive)
return;
GLOBAL.playerApi.addStatusEffect(StatusEffectList.Starving);
this.effectActive = true;
}
}
private void damageTick()
{
if (this.getPlayerFood() == 0)
{
this.isStarving = true;
this.damagePlayer();
}
else
this.isStarving = false;
this.timer = 0.0f;
}
private int getPlayerFood() => this.player.GetFoods().Count;
private void damagePlayer() => ((Character) this.player).ApplyDamage(new HitData()
{
m_damage = {
m_damage = this.damage
}
}, true, true, (HitData.DamageModifier) 0);
}
}