Skip to content

Commit 8f367ed

Browse files
author
DaRealCode
committed
commit files from existing project
1 parent fe61fbc commit 8f367ed

File tree

2 files changed

+145
-0
lines changed

2 files changed

+145
-0
lines changed

GameData/IFFE.dll

9.5 KB
Binary file not shown.

IFFE.cs

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using UnityEngine;
8+
using UnityEngine.UI;
9+
using VehiclePhysics;
10+
using Kopernicus;
11+
12+
namespace FirstMod
13+
{
14+
[KSPAddon(KSPAddon.Startup.Flight, false)]
15+
public class FirstMods : MonoBehaviour
16+
{
17+
public void PartExploder()
18+
{
19+
List<Part> parts = FlightGlobals.ActiveVessel.parts;
20+
int index;
21+
System.Random rnd = new System.Random();
22+
index = rnd.Next(1, parts.Count);
23+
parts[index].explode();
24+
ScreenMessages.PostScreenMessage($"Destroyed part: {parts[index].partInfo.title}", 2);
25+
}
26+
IEnumerator EngineFail()
27+
{
28+
List<Part> parts1 = FlightGlobals.ActiveVessel.parts;
29+
List<Part> engines = new List<Part>();
30+
foreach (Part engines1 in parts1)
31+
{
32+
if (engines1.isEngine())
33+
{
34+
engines.Add(engines1);
35+
}
36+
}
37+
int index;
38+
System.Random rand = new System.Random();
39+
index = rand.Next(0, engines.Count);
40+
foreach (ModuleEngines x in engines[index].FindModulesImplementing<ModuleEngines>())
41+
{
42+
x.Shutdown();
43+
}
44+
ScreenMessages.PostScreenMessage($"Failure on engine {engines[index].partInfo.title}", 4);
45+
yield return null;
46+
}
47+
48+
IEnumerator NoAtmosphere()
49+
{
50+
CelestialBody current = FlightGlobals.getMainBody();
51+
if (current.atmosphere is true)
52+
{
53+
current.atmosphere = false;
54+
ScreenMessages.PostScreenMessage("Removed planet atmosphere", 4);
55+
yield return new WaitForSeconds(5);
56+
current.atmosphere = true;
57+
}
58+
}
59+
IEnumerator ZeroG()
60+
{
61+
CelestialBody body = FlightGlobals.getMainBody();
62+
body.GeeASL = -body.GeeASL;
63+
ScreenMessages.PostScreenMessage("Flipped Gravity", 4);
64+
yield return new WaitForSeconds(5);
65+
body.GeeASL = -body.GeeASL;
66+
}
67+
68+
public void RandomTeleporter()
69+
{
70+
List<CelestialBody> bodies = FlightGlobals.Bodies;
71+
int index;
72+
System.Random rand = new System.Random();
73+
index = rand.Next(0, bodies.Count);
74+
int cindex = bodies[index].flightGlobalsIndex;
75+
ScreenMessages.PostScreenMessage($"Teleported to planet: {bodies[index].name}", 4);
76+
FlightGlobals.fetch.SetVesselPosition(cindex, FlightGlobals.ActiveVessel.latitude, FlightGlobals.ActiveVessel.longitude, FlightGlobals.ActiveVessel.altitude, FlightGlobals.ActiveVessel.orbit.inclination, FlightGlobals.ship_heading, true);
77+
}
78+
79+
bool modenabled = true;
80+
int activate = 0;
81+
int toggleactivate = 0;
82+
public void Update()
83+
{
84+
if (activate > 0)
85+
{
86+
activate -= 1;
87+
}
88+
else
89+
{
90+
ScreenMessages.PostScreenMessage("Mod is ready...", 4);
91+
}
92+
if (toggleactivate > 0)
93+
{
94+
toggleactivate -= 1;
95+
}
96+
bool togglekey = Input.GetKey(KeyCode.KeypadDivide);
97+
if (togglekey && toggleactivate == 0)
98+
{
99+
if (modenabled)
100+
{
101+
modenabled = false;
102+
ScreenMessages.PostScreenMessage("Disabled mod effects", 6);
103+
toggleactivate = 5;
104+
}
105+
else
106+
{
107+
modenabled = true;
108+
ScreenMessages.PostScreenMessage("Enabled mod effects", 6);
109+
toggleactivate = 5;
110+
}
111+
}
112+
113+
bool explodekey = Input.GetKey(KeyCode.LeftAlt) && Input.GetKeyDown(KeyCode.Alpha1);
114+
if (explodekey && modenabled && activate == 0)
115+
{
116+
PartExploder();
117+
activate = 5;
118+
}
119+
bool enginecutkey = Input.GetKey(KeyCode.LeftAlt) && Input.GetKeyDown(KeyCode.Alpha2);
120+
if (enginecutkey && modenabled && activate == 0)
121+
{
122+
StartCoroutine("EngineFail");
123+
activate = 5;
124+
}
125+
bool atmokey = Input.GetKey(KeyCode.LeftAlt) && Input.GetKeyDown(KeyCode.Alpha3);
126+
if (atmokey && modenabled && activate == 0)
127+
{
128+
StartCoroutine("NoAtmosphere");
129+
activate = 5;
130+
}
131+
bool gravkey = Input.GetKey(KeyCode.LeftAlt) && Input.GetKeyDown(KeyCode.Alpha4);
132+
if (gravkey && modenabled && activate == 0)
133+
{
134+
StartCoroutine("ZeroG");
135+
activate = 5;
136+
}
137+
bool telekey = Input.GetKey(KeyCode.LeftAlt) && Input.GetKeyDown(KeyCode.Alpha5);
138+
if (telekey && modenabled && activate == 0)
139+
{
140+
RandomTeleporter();
141+
activate = 5;
142+
}
143+
}
144+
}
145+
}

0 commit comments

Comments
 (0)