-
Notifications
You must be signed in to change notification settings - Fork 0
/
Waddiwassi.cs
69 lines (59 loc) · 2.57 KB
/
Waddiwassi.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using ThunderRoad;
namespace WandSpellss
{
class Waddiwassi : MonoBehaviour
{
Item item;
public static SpellType spellType = SpellType.Raycast;
public void Start()
{
item = GetComponent<Item>();
CastRay();
}
new public void CastRay()
{
RaycastHit hit;
Transform parent;
if (Physics.Raycast(item.flyDirRef.transform.position, item.flyDirRef.transform.forward, out hit, float.MaxValue, Physics.DefaultRaycastLayers, QueryTriggerInteraction.Ignore))
{
CustomDebug.Debug("Did hit.");
CustomDebug.Debug(hit.collider.gameObject.transform.parent.name);
if (hit.collider.GetComponentInParent<Creature>() is Creature creature)
{
float distance = (creature.ragdoll.headPart.transform.position - item.transform.position).magnitude;
List<Item> itemsToForce = Item.allActive.Where(item => item != null && distance < 3f && !Player.currentCreature.equipment.GetAllHolsteredItems().Contains(item))?.ToList();
Item itemToForce = itemsToForce[UnityEngine.Random.Range(0, itemsToForce.Count - 1)];
Vector3 direction = (creature.ragdoll.headPart.transform.position - itemToForce.transform.position).normalized;
itemToForce.physicBody.rigidBody.AddForce(direction * itemToForce.physicBody.rigidBody.mass * (10f * distance), ForceMode.Impulse);
}
}
}
}
public class WaddiwassiHandler : Spell
{
public static SpellType spellType = SpellType.Raycast;
public override Spell AddGameObject(GameObject gameObject)
{
throw new NotImplementedException();
}
public override void SpawnSpell(Type type, string name, Item wand, float spellSpeed)
{
throw new NotImplementedException();
}
public override void UpdateSpell(Type type, string name, Item wand)
{
if (wand.gameObject.GetComponent(type)) UnityEngine.Object.Destroy(wand.gameObject.GetComponent(type));
wand.gameObject.AddComponent(type);
}
public override void UpdateSpell(Type type, string name, Item wand, String itemType)
{
throw new NotImplementedException();
}
}
}