public ScenePrivate.CreateClusterData SpawnGlobalObjective(ObjectiveEntity entity) { Vector location = new Vector(entity.definition.p.x, entity.definition.p.y, entity.definition.p.z); Vector eulerRotation = new Vector(entity.definition.r.x, entity.definition.r.y, entity.definition.r.z); Quaternion rotation = Quaternion.FromEulerAngles(eulerRotation); ScenePrivate.CreateClusterData createData = null; createData = (ScenePrivate.CreateClusterData)WaitFor(ScenePrivate.CreateCluster, objectiveCluster, location, rotation, Vector.Zero); ObjectPrivate.AddInteractionData addData = (ObjectPrivate.AddInteractionData)WaitFor(createData.ClusterReference.GetObjectPrivate(0).AddInteraction, entity.prompt, true); addData.Interaction.Subscribe((InteractionData data) => { AgentPrivate Quester = ScenePrivate.FindAgent(data.AgentId); if (Quester == null || !Quester.IsValid) { return; } HttpRequestOptions options = new HttpRequestOptions(); options.Method = HttpRequestMethod.PATCH; options.Headers = new Dictionary <string, string>() { { "content-type", "application/json" } }; options.Body = $"{{\"data\": {{\"state\":\"COMPLETED\"}} }}"; Guid PersonaId = Quester.AgentInfo.AvatarUuid; string completeObjectiveUrl = $"{BaseUrl}/players/{PersonaId}/storylines/{entity.storylineId}/objectives/{entity.handle}"; Quester.SendChat(completeObjectiveUrl); var result = WaitFor(ScenePrivate.HttpClient.Request, completeObjectiveUrl, options) as HttpClient.RequestData; }); return(createData); }
public override void Init() { ObjectPrivate.AddInteractionData addData = (ObjectPrivate.AddInteractionData)WaitFor(ObjectPrivate.AddInteraction, "Turn off", true); addData.Interaction.Subscribe((InteractionData data) => { // Send the "button_pressed" message PostScriptEvent("button_pressed"); }); }
public override void Init() { ObjectPrivate.AddInteractionData addData = (ObjectPrivate.AddInteractionData)WaitFor(ObjectPrivate.AddInteraction, Title, true); addData.Interaction.Subscribe((InteractionData data) => { AgentPrivate agent = ScenePrivate.FindAgent(data.AgentId); if (agent != null) { agent.SendChat($"Hello from {Title}!"); } }); }
// Logic! public override void Init() { if (!ObjectPrivate.TryGetFirstComponent(out _rb)) { Log.Write(LogLevel.Error, "ImpulseBump can't find a RigidBodyComponent!"); return; } if (_rb.GetMotionType() != RigidBodyMotionType.MotionTypeDynamic) { Log.Write(LogLevel.Error, "ImpulseBump only works on dynamic objects! Set the motion type to 'Dynamic' and try again."); return; } // Check the input parameters to determine what behaviors will be in use _applyLinearImpulse = (LinearImpulseDirection.LengthSquared() > 0.0f); _applyAngularImpulse = (AngularVariance.LengthSquared() > 0.0f); // Don't trust users to give us a normalized direction vector! if (_applyLinearImpulse) { LinearImpulseDirection = LinearImpulseDirection.Normalized(); } // Apply the impulse force when the object is clicked, if it has been configured to use this mode if (InteractionImpulse) { ObjectPrivate.AddInteractionData addData = (ObjectPrivate.AddInteractionData)WaitFor(ObjectPrivate.AddInteraction, "", true); addData.Interaction.Subscribe((InteractionData data) => { ApplyImpulse(); }); } // Apply the impulse force when a script event is received, if one has been specified if (!string.IsNullOrWhiteSpace(ImpulseScriptEvent)) { SubscribeToScriptEvent(ImpulseScriptEvent, (ScriptEventData data) => { // Force anyone holding the object to drop it _rb.ReleaseHeldObject(); ApplyImpulse(); }); } }
public override void Init() { // Set the public media source for the scene ScenePrivate.OverrideMediaSource(PublicMedia); // Override the media source to the private media source for each user that clicks on this object ObjectPrivate.AddInteractionData addData = (ObjectPrivate.AddInteractionData)WaitFor(ObjectPrivate.AddInteraction, "Show media", true); addData.Interaction.Subscribe((InteractionData data) => { AgentPrivate agent = ScenePrivate.FindAgent(data.AgentId); if (agent != null) { agent.OverrideMediaSource(PrivateMedia); } }); }
public override void Init() { // Check to make sure a sound has been configured in the editor if (Sound == null) { Log.Write("SoundScript has no configured sound to play!"); return; } ObjectPrivate.AddInteractionData addData = (ObjectPrivate.AddInteractionData)WaitFor(ObjectPrivate.AddInteraction, "Play sound", true); addData.Interaction.Subscribe((InteractionData data) => { PlaySettings playSettings = PlaySettings.PlayOnce; playSettings.Loudness = (60.0f * (Loudness / 100.0f)) - 48.0f; // Convert percentage to decibels (dB) ScenePrivate.PlaySound(Sound, playSettings); }); }
public override void Init() { // Check to make sure a sound has been configured in the editor if (LoopingSound == null) { Log.Write("LoopingSoundComponentScript has no configured sound to play!"); return; } if (!ObjectPrivate.TryGetFirstComponent(out _audio)) { Log.Write("LoopingSoundComponentScript is on an object that does not have an audio emitter."); return; } ObjectPrivate.AddInteractionData addData = (ObjectPrivate.AddInteractionData)WaitFor(ObjectPrivate.AddInteraction, "Play sound", true); addData.Interaction.Subscribe((InteractionData data) => { // If not sound is playing, start one up if (_playHandle == null) { PlaySettings playSettings = PlaySettings.Looped; playSettings.Loudness = (60.0f * (Loudness / 100.0f)) - 48.0f; // Convert percentage to decibels (dB) _playHandle = _audio.PlaySoundOnComponent(LoopingSound, playSettings); } // Else if a sound is playing, stop it else { if (_playHandle.IsPlaying()) { _playHandle.Stop(); } _playHandle = null; } }); }
public override void Init() { ObjectPrivate.AddInteractionData addData = (ObjectPrivate.AddInteractionData)WaitFor(ObjectPrivate.AddInteraction, "Turn on", true); addData.Interaction.Subscribe((InteractionData data) => { // Create the simple script message data payload SimpleData sd = new SimpleData(this); sd.ObjectId = ObjectPrivate.ObjectId; sd.SourceObjectId = ObjectPrivate.ObjectId; // Include the agent info for the avatar that triggered this event AgentPrivate agent = ScenePrivate.FindAgent(data.AgentId); if (agent != null) { sd.AgentInfo = agent.AgentInfo; sd.ObjectId = agent.AgentInfo.ObjectId; } // Send the "on" message with the SimpleData payload PostScriptEvent("on", sd); }); }