Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Debugger.nl2sco
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<model path="models/DebugSymbols.glb">
<clip distance="250"/>
</model>
<description>Enables debugging information to be displayed in simulator.</description>
<description>Enables debugging information to be displayed in simulator messages, and also make all Emitters visible in play mode.</description>
<defaultinstancename>DebugSymbols</defaultinstancename>
<preview>thumbs/Bug.png</preview>
<param allowrot="false"/>
Expand Down
2 changes: 1 addition & 1 deletion scripts/AudioController.nlvm
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public final class AudioController extends Behaviour implements IReferenceable
{
sound = m_GroupEmitters[i].SetCurrentSound(m_PrimaryAudioLoop.GetName());
sound.SetGain(0);
AddOrSetGain(m_PrimaryAudioLoop.GetName(), 0);
}
AddOrSetGain(m_PrimaryAudioLoop.GetName(), 0);

}
IEnumerator enumerator = m_Queue.GetEnumerator();
Expand Down
1 change: 1 addition & 0 deletions scripts/AudioCueButton.nlvm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public final class AudioCueButton extends AudioCue implements InteractionActionL
m_Interaction.addActionListener(this);
m_Animation = new Animation(m_SceneObject);
m_SceneObject.getElementForName("Plaque").setVisible(!GetBoolParameter("hide_plaque"));
SetIsVisible(true);
}
public void Update(float deltaTime)
{
Expand Down
33 changes: 26 additions & 7 deletions scripts/AudioToggleMute.nlvm
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package scripts;

import com.nolimitscoaster.*;
import scripts.containers.*;
import scripts.utilities.StringUtil;

public final class AudioToggleMute extends Behaviour implements InteractionActionListener
{
private AudioController m_AudioController = null;
private AudioController[] m_AudioControllers = null;
private InteractionObject m_Interaction = null;
private Animation m_Animation = null;
private bool m_IsToggled = false;
Expand All @@ -24,14 +26,30 @@ public final class AudioToggleMute extends Behaviour implements InteractionActio

public void Start()
{
String groupId = GetStringParameter("audio_group");
IReferenceable reference = Registry.GetInstance().GetReferenceFromName("scripts.AudioController", groupId);
if(reference == null)
String controllerParams = GetStringParameter("audio_group");
String[] params = StringUtil.SplitString(controllerParams, ',');
if(params.length == 0)
{
Debug.Warn("Button - Music Mute Toggle | Could not find Audio Group with Group Id '" + groupId + "'");
Debug.Warn("Cue Trigger | Internal error when parsing Group Id/s, '" + controllerParams + "' is not a valid parameter entry");
return;
}
m_AudioController = (AudioController)reference;
List tempControllers = new List(params.length);
for(int i = 0; i < params.length; ++i)
{
IReferenceable reference = Registry.GetInstance().GetReferenceFromName("scripts.AudioController", params[i]);
if(reference == null)
{
Debug.Warn("Cue Trigger | Unable to find Audio Group with id '" + params[i] + "'");
continue;
}
tempControllers.Insert(reference);
}
m_AudioControllers = new AudioController[tempControllers.Count()];
IEnumerator enumerator = tempControllers.GetEnumerator();
int l = 0;
while(enumerator.MoveNext())
m_AudioControllers[l++] = (AudioController)enumerator.Get();

m_Interaction = InteractionObject.createSimpleButton();
m_Interaction.setActive(true);
m_Interaction.setEnabled(true);
Expand Down Expand Up @@ -62,7 +80,8 @@ public final class AudioToggleMute extends Behaviour implements InteractionActio
m_Interaction.setEnabled(false);

m_IsToggled = !m_IsToggled;
m_AudioController.SetPrimaryTrackMuted(m_IsToggled);
for(int i = 0; i < m_AudioControllers.length; ++i)
m_AudioControllers[i].SetPrimaryTrackMuted(m_IsToggled);

if(m_IsToggled)
m_SceneObject.getElementAt(1).setTextureAnimationIndex(1);
Expand Down
34 changes: 26 additions & 8 deletions scripts/AudioToggleShutOff.nlvm
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package scripts;

import com.nolimitscoaster.*;
import scripts.containers.*;
import scripts.utilities.StringUtil;

public final class AudioToggleShutOff extends Behaviour implements InteractionActionListener
{
private AudioController m_AudioController = null;
private AudioController[] m_AudioControllers = null;
private InteractionObject m_Interaction = null;
private Animation m_Animation = null;
private bool m_IsToggled = false;
Expand All @@ -24,14 +26,30 @@ public final class AudioToggleShutOff extends Behaviour implements InteractionAc

public void Start()
{
String groupId = GetStringParameter("audio_group");
IReferenceable reference = Registry.GetInstance().GetReferenceFromName("scripts.AudioController", groupId);
if(reference == null)
String controllerParams = GetStringParameter("audio_group");
String[] params = StringUtil.SplitString(controllerParams, ',');
if(params.length == 0)
{
Debug.Warn("Button - Master Switch | Could not find Audio Group with Group Id '" + groupId + "'");
Debug.Warn("Cue Trigger | Internal error when parsing Group Id/s, '" + controllerParams + "' is not a valid parameter entry");
return;
}
m_AudioController = (AudioController)reference;
List tempControllers = new List(params.length);
for(int i = 0; i < params.length; ++i)
{
IReferenceable reference = Registry.GetInstance().GetReferenceFromName("scripts.AudioController", params[i]);
if(reference == null)
{
Debug.Warn("Cue Trigger | Unable to find Audio Group with id '" + params[i] + "'");
continue;
}
tempControllers.Insert(reference);
}
m_AudioControllers = new AudioController[tempControllers.Count()];
IEnumerator enumerator = tempControllers.GetEnumerator();
int l = 0;
while(enumerator.MoveNext())
m_AudioControllers[l++] = (AudioController)enumerator.Get();

m_Interaction = InteractionObject.createSimpleButton();
m_Interaction.setActive(true);
m_Interaction.setEnabled(true);
Expand All @@ -43,7 +61,6 @@ public final class AudioToggleShutOff extends Behaviour implements InteractionAc
m_IsToggled = true;
m_Animation.Play(0, 10);
m_SceneObject.getElementAt(1).setTextureAnimationIndex(1);

m_SceneObject.getElementForName("Plaque").setVisible(!GetBoolParameter("hide_plaque"));
}

Expand Down Expand Up @@ -75,6 +92,7 @@ public final class AudioToggleShutOff extends Behaviour implements InteractionAc
m_SceneObject.getElementAt(1).setTextureAnimationIndex(1);
}
m_IsToggled = !m_IsToggled;
m_AudioController.SetControllerOn(m_IsToggled);
for(int i = 0; i < m_AudioControllers.length; ++i)
m_AudioControllers[i].SetControllerOn(m_IsToggled);
}
}
97 changes: 78 additions & 19 deletions scripts/Behaviour.nlvm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import scripts.math.*;

/// <class>
/// <desc>Base class to derrive any SceneObject attached scripts.</desc>
public abstract class Behaviour extends Script
public abstract class Behaviour extends Script implements IPropertyContainer
{
private static final List m_Updateables = new List();
private static Behaviour m_Caller = null;
Expand Down Expand Up @@ -91,30 +91,31 @@ public abstract class Behaviour extends Script
}
public final void onLateUpdate()
{
if(m_HasRecievedNextFrameUpdate == false)
{
LateUnblockedUpdate();
LateUnblockedUpdate();

if(m_Caller != this)
return;
if(m_Caller != this)
return;

IEnumerator enumerator = m_Updateables.GetEnumerator();
while(enumerator.MoveNext())
((IUpdateable)enumerator.Get()).LateUnblockedUpdate();
IEnumerator enumerator = m_Updateables.GetEnumerator();
while(enumerator.MoveNext())
((IUpdateable)enumerator.Get()).LateUnblockedUpdate();

return;
}


m_HasRecievedNextFrameUpdate = false;
LateUpdate(m_PreviousTick);


if(m_Caller != this)
return;
// Loop over the updateables and call their late updates
IEnumerator enumerator = m_Updateables.GetEnumerator();
while(enumerator.MoveNext())
((IUpdateable)enumerator.Get()).LateUpdate(m_PreviousTick);
if(m_HasRecievedNextFrameUpdate == true)
{
m_HasRecievedNextFrameUpdate = false;
LateUpdate(m_PreviousTick);

if(m_Caller != this)
return;
// Loop over the updateables and call their late updates
enumerator = m_Updateables.GetEnumerator();
while(enumerator.MoveNext())
((IUpdateable)enumerator.Get()).LateUpdate(m_PreviousTick);
}
}
public final void onExit()
{
Expand Down Expand Up @@ -270,6 +271,21 @@ public abstract class Behaviour extends Script
m_SceneObject.setTranslation(position.GetNative());
}
/// <method>
/// <desc>Gets this Behaviour's world-space rotation.</desc>
/// </method>
public final Vector3 GetRotation()
{
return Vector3.FromNative(m_SceneObject.getRotation());
}
/// <method>
/// <desc>Sets this Behaviour's world-space rotation.</desc>
/// <arg name="rotation">The world-space rotation to set.</arg>
/// </method>
public final void SetRotation(Vector3 rotation)
{
m_SceneObject.setRotation(rotation.GetNative());
}
/// <method>
/// <desc>Gets this Behaviour's local-space scale.</desc>
/// </method>
public final Vector3 GetScale()
Expand Down Expand Up @@ -301,6 +317,49 @@ public abstract class Behaviour extends Script
}





public static final int POSITION = 812449097; // Position
public static final int ROTATION = 24343454; // Rotation
public static final int SCALE = 79698218; // Scale
private static final int[] s_ValidProperties = new int[]
{
POSITION,
ROTATION,
SCALE
};

private bool IsPropertyValid(int property)
{
for(int i = 0; i < s_ValidProperties.length; ++i)
if(s_ValidProperties[i] == property)
return true;
return false;
}
public IPropertyHandle GetPropertyHandle(int id)
{
if(!IsPropertyValid(id))
Exception.Throw("There is no property '" + id + "' on this instance");

int myVar = 0;
switch(myVar)
{
case POSITION:
break;
}

return new BehaviourPropertyHandler(this, id);
}









/// <method>
/// <desc>Attempts to retrieve a float parameter, throws an exception if no parameter is found with the given id.</desc>
/// <arg name="name">Parameter id.</arg>
Expand Down
63 changes: 63 additions & 0 deletions scripts/BehaviourPropertyHandler.nlvm
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package scripts;

import scripts.math.*;

public class BehaviourPropertyHandler extends Object implements IPropertyHandle
{
private Behaviour m_Behaviour = null;
private int m_Property;
private String m_PropertyType = "";

public BehaviourPropertyHandler(Behaviour behaviour, int property)
{
m_Behaviour = behaviour;
m_Property = property;

switch(m_Property)
{
case Behaviour.POSITION:
case Behaviour.ROTATION:
case Behaviour.SCALE:
m_PropertyType = "scripts.math.Vector3";
break;
default:
m_PropertyType = "invalid";
break;
}
}

public String GetPropertyType()
{
return m_PropertyType;
}
public void SetProperty(Object value)
{
switch(m_Property)
{
case Behaviour.POSITION:
m_Behaviour.SetPosition((Vector3)value);
break;
case Behaviour.ROTATION:
m_Behaviour.SetRotation((Vector3)value);
break;
case Behaviour.SCALE:
m_Behaviour.SetScale((Vector3)value);
break;
}
}
public Object GetProperty()
{
switch(m_Property)
{
case Behaviour.POSITION:
return m_Behaviour.GetPosition();
case Behaviour.ROTATION:
return m_Behaviour.GetRotation();
case Behaviour.SCALE:
return m_Behaviour.GetScale();
default:
return null;
}
return null;
}
}
8 changes: 5 additions & 3 deletions scripts/CoasterCar.nlvm
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class CoasterCar extends Behaviour implements ISetableCar
}
}


// Create g-froce trackers for the cameras
m_GForceTrackers = new ElementGForceTracker[cameras.Count()];
for(int i = 0; i < m_GForceTrackers.length; ++i)
Expand All @@ -91,12 +92,13 @@ public class CoasterCar extends Behaviour implements ISetableCar
m_HandlerManager.RegisterHandler(m_Handler);
m_Handler.SetCarModifier(m_HandlerManager.GetDefaultCarModifier());
m_Handler.SetCarSeats(m_Descriptor.Cameras);

RideCameraHandler.GetInstance().RegisterTrainHandler(m_Handler);
}
if(m_Handler.GetCarModifier() == null) m_Handler.SetCarModifier(m_HandlerManager.GetDefaultCarModifier());

m_Handler.SetCarSeats(m_Descriptor.Cameras);
m_Handler.RegisterCar(this);

if(cameras.Count() > 0)
RideCameraHandler.GetInstance().RegisterTrainHandler(m_Handler);
}


Expand Down
5 changes: 2 additions & 3 deletions scripts/ElementGForceTracker.nlvm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ElementGForceTracker extends GForceTracker
{
private SceneObjectElement m_TrackingElement = null;

public bool DisplayForces = false;
public bool DisplayForces = true;

/// <constructor>
/// <desc>Creates a new tracker for a SceneObjectElement.</desc>
Expand Down Expand Up @@ -40,9 +40,8 @@ public class ElementGForceTracker extends GForceTracker
Vector3 rayEnd = position.Add(forces);

Color color = new Color(Mathf.Abs(forces.X), Mathf.Abs(forces.Y), Mathf.Abs(forces.Z));

if(DisplayForces)
Debug.DrawLine(position, rayEnd, tick, color);
Debug.DrawLine(position, rayEnd, tick * 1.2f, color);
}
}
/// </class>
Loading
Loading