Jump to content

.CS != .DLL Project VisiKerb hits a wall


Recommended Posts

Hi folks, I have been working on the plugin by SFR to try and fix a few things and generally make some nice looking command pods. Thus far I have been doing ok and getting some models up and running using the original plugin that can be found here.

Some images and that, sorry I got a bit carried away but those Kerbals just look so awesome in their little pods!

Javascript is disabled. View full album

Ok so I have a problem with the plugin code however my attempts at recreating the original .dll file from the source code have not worked well. The original .cs file does not Compile into a useable .dll file because the Kerbals do not spawn.

What I have done thus far is to compile the code along with some tweaks, I got the IVA view working correctly and the code is running as shown by both debug warnings and the presence of the IVA model...

But still no Kerbals ;.;

If anyone has any suggestions, the offending code is here, I would be very happy if you could help...

using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;


namespace sfrPartModules1
{
class sfrUtility
{
public static Camera FindCamera(string name)
{
foreach (Camera c in Camera.allCameras)
if (c.name == name)
return c;
return null;
}

public static void LogCameras()
{
int i = 0;
foreach (Camera c in Camera.allCameras)
{
Debug.LogWarning("Cam " + i++ + " " + c.name + " " + c.cullingMask);
Debug.Log(c.transform.position + " " + c.transform.rotation.eulerAngles + " " + c.fov + " " + c.depth + " " + c.clearFlags);
}
}

public static void LogModules(Part part)
{
int i = 0;
foreach (PartModule p in part.Modules)
Debug.Log("Mod " + i++ + " " + p.name + " " + p.GUIName + " " + p.guiText);
}
}

// surplus class removed here
// Then on to the remainder

public class sfrInternal : PartModule
{

Transform kspParent;
Vector3 kspPosition = new Vector3(18.3f, -6.9f, 0);
Quaternion kspRotation = new Quaternion(0, 0.7f, -0.7f, 0);
bool isActive = true;

public override void OnAwake()
{
base.OnAwake();
Debug.LogWarning("sfrInternal OnAwake " + GameInfo.gameScene + " " + part + " " + vessel);
}

public override void OnLoad(ConfigNode node)
{
base.OnLoad(node);
Debug.LogWarning("sfrInternal OnLoad " + node.name);

}

public override void OnSave(ConfigNode node)
{
base.OnSave(node);
Debug.LogWarning("sfrInternal OnSave " + node.name);

}

public override void OnStart(StartState state)
{
base.OnStart(state);
Debug.LogWarning("sfrInternal OnStart, StartState: " + state);

Camera c = sfrUtility.FindCamera("Main Camera");
if (c)
c.cullingMask |= 1 << 16 | 1 << 20;

if(!part.internalModel)
{
try
{
part.CreateInternalModel();
}
catch (Exception e)
{
Debug.LogException(e, this);
}
}

if(part.internalModel)
{
if (state != StartState.Editor)
kspParent = part.internalModel.transform.parent;

part.internalModel.transform.parent = part.transform;
part.internalModel.transform.localRotation = new Quaternion(0, 0.7f, -0.7f, 0);
part.internalModel.transform.localPosition = Vector3.zero;
}
}

public override void OnUpdate()
{
base.OnUpdate();
Debug.LogWarning("sfrInternal OnUpdate");

if (isActive != part.vessel.isActiveVessel)
{
Camera c = sfrUtility.FindCamera("Main Camera");
if (c)
c.cullingMask |= 1 << 16 | 1 << 20;

part.CreateInternalModel();
kspParent = part.internalModel.transform.parent; // InternalCamera.Instance.transform.parent;

part.internalModel.SetVisible(true);
part.vessel.SetActiveInternalPart(part);

if (part.protoModuleCrew.Count > 0 && isActive)
{
part.vessel.SpawnCrew();
}

part.internalModel.transform.parent = part.transform;
part.internalModel.transform.localRotation = new Quaternion(0, 0.7f, -0.7f, 0);
part.internalModel.transform.localPosition = Vector3.zero;
}

if(!part.internalModel)
{
part.CreateInternalModel();
kspParent = part.internalModel.transform.parent; // InternalCamera.Instance.transform.parent;

part.internalModel.SetVisible(true);
part.vessel.SetActiveInternalPart(part);

if (part.protoModuleCrew.Count > 0 && isActive)
{
part.vessel.SpawnCrew();
}

part.internalModel.transform.parent = part.transform;
part.internalModel.transform.localRotation = new Quaternion(0, 0.7f, -0.7f, 0);
part.internalModel.transform.localPosition = Vector3.zero;
}

try
{
if (sfrUtility.FindCamera("InternalCamera"))
{
if (part.vessel.isActiveVessel)
{
part.internalModel.transform.position = Vector3.zero; //kspPosition;
// Edited here to swap out for the Vector3.Zero as originally commented in the source
part.internalModel.transform.parent = kspParent;
part.internalModel.transform.localRotation = new Quaternion(0, 0.7f, -0.7f, 0);
}
}
else
{
part.internalModel.transform.parent = part.transform;
part.internalModel.transform.localRotation = new Quaternion(0, 0.7f, -0.7f, 0);
part.internalModel.transform.localPosition = Vector3.zero;
}
}
catch (Exception e)
{
Debug.LogException(e, this);
}

}

}

}




Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...