Skip to content

Commit 9cc899b

Browse files
author
DaRealCode
committed
Make the MP version of the mod
1 parent a6fd9fc commit 9cc899b

File tree

4 files changed

+152
-40
lines changed

4 files changed

+152
-40
lines changed

GameData/IFFT-MP/IFFE.dll

9.5 KB
Binary file not shown.

GameData/IFFT/IFFT.version

Lines changed: 0 additions & 19 deletions
This file was deleted.

GameData/IFFT/LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

IFFE-MP.cs

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
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_MP
13+
{
14+
[KSPAddon(KSPAddon.Startup.Flight, false)]
15+
public class FirstMods_MP : MonoBehaviour
16+
{
17+
public void PartExploder_MP()
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_MP()
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_MP()
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_MP()
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_MP()
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+
int mana = 0;
83+
public void Update()
84+
{
85+
if (modenabled)
86+
{
87+
mana += 2000;
88+
ScreenMessages.PostScreenMessage($"Mana: {mana}");
89+
}
90+
if (activate > 0)
91+
{
92+
activate -= 1;
93+
}
94+
if (toggleactivate > 0)
95+
{
96+
toggleactivate -= 1;
97+
}
98+
bool togglekey = Input.GetKey(KeyCode.KeypadDivide);
99+
if (togglekey && toggleactivate == 0)
100+
{
101+
if (modenabled)
102+
{
103+
modenabled = false;
104+
ScreenMessages.PostScreenMessage("Disabled mod effects", 6);
105+
toggleactivate = 5;
106+
}
107+
else
108+
{
109+
modenabled = true;
110+
ScreenMessages.PostScreenMessage("Enabled mod effects", 6);
111+
toggleactivate = 5;
112+
}
113+
}
114+
115+
bool explodekey = Input.GetKey(KeyCode.LeftAlt) && Input.GetKeyDown(KeyCode.Alpha1);
116+
if (explodekey && modenabled && activate == 0 && mana == 500000)
117+
{
118+
PartExploder_MP();
119+
activate = 5;
120+
mana -= 500000;
121+
}
122+
bool enginecutkey = Input.GetKey(KeyCode.LeftAlt) && Input.GetKeyDown(KeyCode.Alpha2);
123+
if (enginecutkey && modenabled && activate == 0 && mana == 250000)
124+
{
125+
StartCoroutine("EngineFail_MP");
126+
activate = 5;
127+
mana -= 250000;
128+
}
129+
bool atmokey = Input.GetKey(KeyCode.LeftAlt) && Input.GetKeyDown(KeyCode.Alpha3);
130+
if (atmokey && modenabled && activate == 0 && mana == 750000)
131+
{
132+
StartCoroutine("NoAtmosphere_MP");
133+
activate = 5;
134+
mana -= 750000;
135+
}
136+
bool gravkey = Input.GetKey(KeyCode.LeftAlt) && Input.GetKeyDown(KeyCode.Alpha4);
137+
if (gravkey && modenabled && activate == 0 && mana == 600000)
138+
{
139+
StartCoroutine("ZeroG_MP");
140+
activate = 5;
141+
mana -= 600000;
142+
}
143+
bool telekey = Input.GetKey(KeyCode.LeftAlt) && Input.GetKeyDown(KeyCode.Alpha5);
144+
if (telekey && modenabled && activate == 0 && mana == 1500000)
145+
{
146+
RandomTeleporter_MP();
147+
activate = 5;
148+
mana -= 1500000;
149+
}
150+
}
151+
}
152+
}

0 commit comments

Comments
 (0)