-
Notifications
You must be signed in to change notification settings - Fork 1
/
LegendaryDogsWorgPack1.cs
81 lines (75 loc) · 1.96 KB
/
LegendaryDogsWorgPack1.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
using System;
using System.Collections.Generic;
using XRL.Core;
using XRL.Rules;
using XRL.World.ObjectBuilders;
namespace XRL.World.Parts
{
[Serializable]
public class LegendaryDogsWorgPack1 : IPart
{
//
// Fields
//
public bool bCreated;
//
// Constructors
//
public LegendaryDogsWorgPack1 ()
{
base.SetName("LegendaryDogsWorgPack1");
}
//
// Methods
//
public override bool FireEvent (Event E)
{
if (E.ID == "EnteredCell") {
try {
if (this.bCreated) {
return true;
}
this.bCreated = true;
Physics physics = this.ParentObject.GetPart ("Physics") as Physics;
List<Cell> cellList = new List<Cell> ();
physics.CurrentCell.GetAdjacentCells (4, cellList, true);
List<Cell> emptyCellList = new List<Cell> ();
foreach (Cell current in cellList) {
if (current.IsEmpty ()) {
emptyCellList.Add (current);
}
}
List<string> randomWorgs = new List<string> ();
int worgs = Stat.Random (2, 5);
for (int i = 0; i < worgs; i++) {
randomWorgs.Add ("LegendaryDogs_Worg");
}
Tier1HumanoidEquipment tier1HumanoidEquipment = new Tier1HumanoidEquipment ();
int worgIterator = 0;
while (worgIterator < randomWorgs.Count && emptyCellList.Count > 0) {
GameObject gameObject = GameObjectFactory.Factory.CreateObject (randomWorgs [worgIterator]);
tier1HumanoidEquipment.Apply (gameObject, null);
gameObject.GetPart<Brain> ().PartyLeader = this.ParentObject;
Cell randomElement = emptyCellList.GetRandomElement (null);
randomElement.AddObject (gameObject);
XRLCore.Core.Game.ActionManager.AddActiveObject (gameObject);
emptyCellList.Remove (randomElement);
worgIterator++;
}
}
catch {
}
return true;
}
return true;
}
public override void Register (GameObject Object)
{
Object.RegisterPartEvent (this, "EnteredCell");
}
public override bool SameAs (IPart p)
{
return false;
}
}
}