Skip to content

Commit b02f01d

Browse files
authored
Initial Upload
1 parent 391179e commit b02f01d

17 files changed

+717
-1
lines changed

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 ParkitectNexus
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

ModSparkLoader.csproj

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{FA17F423-2365-4230-88E5-BD736956F809}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<NoStandardLibraries>false</NoStandardLibraries>
9+
<AssemblyName>ClassLibrary</AssemblyName>
10+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
11+
<FileAlignment>512</FileAlignment>
12+
</PropertyGroup>
13+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
14+
<DebugSymbols>true</DebugSymbols>
15+
<DebugType>full</DebugType>
16+
<Optimize>false</Optimize>
17+
<OutputPath>bin\Debug\</OutputPath>
18+
<DefineConstants>DEBUG;TRACE</DefineConstants>
19+
<ErrorReport>prompt</ErrorReport>
20+
<WarningLevel>4</WarningLevel>
21+
</PropertyGroup>
22+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
23+
<DebugType>pdbonly</DebugType>
24+
<Optimize>true</Optimize>
25+
<OutputPath>bin\Release\</OutputPath>
26+
<DefineConstants>TRACE</DefineConstants>
27+
<ErrorReport>prompt</ErrorReport>
28+
<WarningLevel>4</WarningLevel>
29+
</PropertyGroup>
30+
<PropertyGroup>
31+
<RootNamespace>Custom_Scenery</RootNamespace>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="Assembly-CSharp">
35+
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Parkitect\Parkitect_Data\Managed\Assembly-CSharp.dll</HintPath>
36+
</Reference>
37+
<Reference Include="Depender">
38+
<HintPath>..\Depender\bin\Depender.dll</HintPath>
39+
</Reference>
40+
<Reference Include="System" />
41+
<Reference Include="System.Core" />
42+
<Reference Include="System.Data" />
43+
<Reference Include="System.Data.DataSetExtensions" />
44+
<Reference Include="System.Xml" />
45+
<Reference Include="System.Xml.Linq" />
46+
<Reference Include="UnityEngine">
47+
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Parkitect\Parkitect_Data\Managed\UnityEngine.dll</HintPath>
48+
</Reference>
49+
<Reference Include="UnityEngine.UI">
50+
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Parkitect\Parkitect_Data\Managed\UnityEngine.UI.dll</HintPath>
51+
</Reference>
52+
</ItemGroup>
53+
<ItemGroup>
54+
<Content Include=".gitignore" />
55+
</ItemGroup>
56+
<ItemGroup>
57+
<None Include="mod.json" />
58+
<None Include="README.md" />
59+
<None Include="scenery.json" />
60+
</ItemGroup>
61+
<ItemGroup>
62+
<Compile Include="ModSparkLoader\FlatRideLoader.cs" />
63+
<Compile Include="ModSparkLoader\Main.cs" />
64+
<Compile Include="ModSparkLoader\ModLoader.cs" />
65+
</ItemGroup>
66+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSHARP.Targets" />
67+
<ProjectExtensions>
68+
<VisualStudio AllowExistingFolder="true" />
69+
</ProjectExtensions>
70+
</Project>

ModSparkLoader.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.23107.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModSparkLoader", "ModSparkLoader.csproj", "{FA17F423-2365-4230-88E5-BD736956F809}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{FA17F423-2365-4230-88E5-BD736956F809}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{FA17F423-2365-4230-88E5-BD736956F809}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{FA17F423-2365-4230-88E5-BD736956F809}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{FA17F423-2365-4230-88E5-BD736956F809}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

ModSparkLoader/FlatRideLoader.cs

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Xml;
7+
using System.Xml.Linq;
8+
using Depender.Types.FlatRides;
9+
using Depender.AnimationMotors;
10+
using Depender.AnimationEvents;
11+
12+
public class FlatRideLoader
13+
{
14+
public static List<motor> LoadMotors(XmlNode ObjNode, GameObject GO)
15+
{
16+
List<motor> motors = new List<motor>();
17+
18+
foreach (XmlNode motorN in ObjNode.SelectSingleNode("Animation/motors").ChildNodes)
19+
{
20+
switch (motorN.Name)
21+
{
22+
23+
case "Rotator":
24+
RotatorHP R = GO.AddComponent<RotatorHP>();
25+
R.Identifier = motorN["Identifier"].InnerText;
26+
R.axisPath = motorN["axis"].InnerText;
27+
R.axis = GO.transform.FindChild(motorN["axis"].InnerText);
28+
R.maxSpeed = float.Parse(motorN["maxSpeed"].InnerText);
29+
R.accelerationSpeed = float.Parse(motorN["accelerationSpeed"].InnerText);
30+
R.rotationAxis = getVector3(motorN["rotationAxis"].InnerText);
31+
motors.Add(R);
32+
break;
33+
case "RotateBetween":
34+
RotateBetweenHP RB = GO.AddComponent<RotateBetweenHP>();
35+
RB.Identifier = motorN["Identifier"].InnerText;
36+
RB.axisPath = motorN["axis"].InnerText;
37+
RB.axis = GO.transform.FindChild(motorN["axis"].InnerText);
38+
RB.rotationAxis = getVector3(motorN["rotationAxis"].InnerText);
39+
RB.duration = float.Parse(motorN["duration"].InnerText);
40+
motors.Add(RB);
41+
break;
42+
case "Mover":
43+
MoverHP M = GO.AddComponent<MoverHP>();
44+
M.Identifier = motorN["Identifier"].InnerText;
45+
M.axisPath = motorN["axis"].InnerText;
46+
M.axis = GO.transform.FindChild(motorN["axis"].InnerText);
47+
M.toPosition = getVector3(motorN["toPosition"].InnerText);
48+
M.duration = float.Parse(motorN["duration"].InnerText);
49+
motors.Add(M);
50+
break;
51+
case "MultipleRotations":
52+
MultipleRotationsHP MR = GO.AddComponent<MultipleRotationsHP>();
53+
MR.Identifier = motorN["Identifier"].InnerText;
54+
MR.axisPath = motorN["MainAxis"].InnerText;
55+
XmlNodeList axisNs = motorN.SelectNodes("axis");
56+
foreach (XmlNode axisN in axisNs)
57+
{
58+
MR.AxissPath.Add(axisN.InnerText);
59+
}
60+
motors.Add(MR);
61+
break;
62+
case "PendulumRotator":
63+
PendulumRotatorHP PR = GO.AddComponent<PendulumRotatorHP>();
64+
PR.Identifier = motorN["Identifier"].InnerText;
65+
PR.axisPath = motorN["axis"].InnerText;
66+
PR.axis = GO.transform.FindChild(motorN["axis"].InnerText);
67+
PR.maxSpeed = float.Parse(motorN["maxSpeed"].InnerText);
68+
PR.accelerationSpeed = float.Parse(motorN["accelerationSpeed"].InnerText);
69+
PR.rotationAxis = getVector3(motorN["rotationAxis"].InnerText);
70+
PR.angularFriction = float.Parse(motorN["angularFriction"].InnerText);
71+
PR.gravity = float.Parse(motorN["gravity"].InnerText);
72+
PR.pendulum = Boolean.Parse(motorN["pendulum"].InnerText);
73+
PR.armLength = float.Parse(motorN["armLength"].InnerText);
74+
motors.Add(PR);
75+
break;
76+
77+
}
78+
}
79+
80+
return motors;
81+
throw new NotImplementedException();
82+
}
83+
public static List<Phase> LoadPhases(XmlNode ObjNode, GameObject GO)
84+
{
85+
List<Phase> Phases = new List<Phase>();
86+
87+
foreach (XmlNode PhaseN in ObjNode.SelectSingleNode("Animation/phases").ChildNodes)
88+
{
89+
90+
Phase phase = GO.AddComponent<Phase>();
91+
foreach (XmlNode EventN in PhaseN.SelectSingleNode("events").ChildNodes)
92+
{
93+
switch (EventN.Name)
94+
{
95+
case "Wait":
96+
Wait W = GO.AddComponent<Wait>();
97+
W.seconds = float.Parse(EventN["Seconds"].InnerText);
98+
phase.Events.Add(W);
99+
break;
100+
case "StartRotator":
101+
StartRotator SR = GO.AddComponent<StartRotator>();
102+
SR.identifierMotor = EventN["Identifier"].InnerText;
103+
phase.Events.Add(SR);
104+
break;
105+
case "SpinRotator":
106+
SpinRotater SpR = GO.AddComponent<SpinRotater>();
107+
SpR.identifierMotor = EventN["Identifier"].InnerText;
108+
SpR.spin = Boolean.Parse(EventN["spin"].InnerText);
109+
SpR.spins = float.Parse(EventN["spins"].InnerText);
110+
phase.Events.Add(SpR);
111+
break;
112+
case "StopRotator":
113+
StopRotator StR = GO.AddComponent<StopRotator>();
114+
StR.identifierMotor = EventN["Identifier"].InnerText;
115+
phase.Events.Add(StR);
116+
break;
117+
case "FromToRot":
118+
FromToRot FTR = GO.AddComponent<FromToRot>();
119+
FTR.identifierMotor = EventN["Identifier"].InnerText;
120+
phase.Events.Add(FTR);
121+
break;
122+
case "ToFromRot":
123+
ToFromRot TFR = GO.AddComponent<ToFromRot>();
124+
TFR.identifierMotor = EventN["Identifier"].InnerText;
125+
phase.Events.Add(TFR);
126+
break;
127+
case "FromToMove":
128+
FromToMove FTM = GO.AddComponent<FromToMove>();
129+
FTM.identifierMotor = EventN["Identifier"].InnerText;
130+
phase.Events.Add(FTM);
131+
break;
132+
case "ToFromMove":
133+
ToFromMove TFM = GO.AddComponent<ToFromMove>();
134+
TFM.identifierMotor = EventN["Identifier"].InnerText;
135+
phase.Events.Add(TFM);
136+
break;
137+
case "ApplyRotation":
138+
ApplyRotation AR = GO.AddComponent<ApplyRotation>();
139+
AR.identifierMotor = EventN["Identifier"].InnerText;
140+
phase.Events.Add(AR);
141+
break;
142+
case "ChangePendulum":
143+
ChangePendulum CP = GO.AddComponent<ChangePendulum>();
144+
CP.identifierMotor = EventN["Identifier"].InnerText;
145+
CP.Friction = float.Parse(EventN["Friction"].InnerText);
146+
CP.Pendulum = Boolean.Parse(EventN["Pendulum"].InnerText);
147+
phase.Events.Add(CP);
148+
break;
149+
default:
150+
Debug.Log("Couln't detect the right event called: " + EventN.Name);
151+
break;
152+
153+
}
154+
}
155+
156+
Phases.Add(phase);
157+
}
158+
return Phases;
159+
160+
throw new NotImplementedException();
161+
}
162+
163+
public static Vector3 getVector3(string rString)
164+
{
165+
string[] temp = rString.Substring(1, rString.Length - 2).Split(',');
166+
float x = float.Parse(temp[0]);
167+
float y = float.Parse(temp[1]);
168+
float z = float.Parse(temp[2]);
169+
Vector3 rValue = new Vector3(x, y, z);
170+
return rValue;
171+
}
172+
}
173+

ModSparkLoader/Main.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Depender;
2+
using UnityEngine;
3+
4+
namespace Custom_Scenery
5+
{
6+
public class Main : IMod
7+
{
8+
private GameObject _go;
9+
string name = "Could not load name";
10+
string description = "Could not load description";
11+
public void onEnabled()
12+
{
13+
_go = new GameObject();
14+
15+
_go.AddComponent<ModLoader>();
16+
17+
_go.GetComponent<ModLoader>().Path = Path;
18+
19+
_go.GetComponent<ModLoader>().Identifier = Identifier;
20+
21+
_go.GetComponent<ModLoader>().LoadScenery();
22+
23+
name = _go.GetComponent<ModLoader>().modName;
24+
25+
description = _go.GetComponent<ModLoader>().modDiscription;
26+
}
27+
28+
public void onDisabled()
29+
{
30+
Registar.UnRegister();
31+
Object.Destroy(_go);
32+
}
33+
34+
public string Name { get { return name; } }
35+
public string Description { get { return description; } }
36+
public string Path { get; set; }
37+
public string Identifier { get; set; }
38+
}
39+
}

0 commit comments

Comments
 (0)