// Override Init to set up event handlers and start coroutines.
    public override void Init()
    {
        // Sensible default setting values
        if (OpenAngleDegrees == 0)
        {
            OpenAngleDegrees = 90;
        }
        if (Channel == 0)
        {
            Channel = 1000;
        }
        if (SecondsToOpen == 0)
        {
            SecondsToOpen = 1;
        }
        if (SecondsBeforeClose == 0)
        {
            SecondsBeforeClose = 5;
        }

        // Parse the pipe-delimited sensor names into a clean list
        if (SensorNames != null)
        {
            foreach (string Name in SensorNames.Split(','))
            {
                if (Name.Trim() == "")
                {
                    continue;
                }
                SensorNameList.Add(Name.Trim());
            }
        }

        // Find the door we'll manipulate.
        if (DoorBody == null)
        {
            ObjectPrivate.TryGetFirstComponent(out DoorBody);
        }

        // Compute some basics
        OpenAngle         = OpenAngleDegrees / Mathf.DegreesPerRadian;
        ClosedOrientation = DoorBody.GetOrientation();
        HingeOffset       = new Vector(HingeOffsetX, HingeOffsetY, 0, 0).Rotate(ref ClosedOrientation);
        ClosedPosition    = DoorBody.GetPosition() + HingeOffset;

        // Only subscribe to collision events if the experience creator requested it
        if (OpenOnCollision)
        {
            DoorBody.Subscribe(CollisionEventType.CharacterContact, Collide);
        }

        // Only listen for chat if the experience creator wants outside sensors to trip this
        if (SensorNames != null)
        {
            ScenePrivate.Chat.Subscribe(Channel, null, ChatMessage);
        }

        // Start a continuous loop updating the door's position and orientation
        StartCoroutine(UpdateLoop);
    }
 private void LocalTeleport(ScriptEventData data)
 {
     Log.Write("A");
     foreach (AgentPrivate agent in ScenePrivate.GetAgents())
     {
         Log.Write(agent.AgentInfo.Name);
         if (agent.AgentInfo.Name == "GranddadGotMojo")
         {
             Log.Write("Camaeraman found");
             ObjectPrivate objectPrivate = ScenePrivate.FindObject(agent.AgentInfo.ObjectId);
             if (objectPrivate != null)
             {
                 AnimationComponent anim = null;
                 if (objectPrivate.TryGetFirstComponent(out anim))
                 {
                     if (RelativeDestination)
                     {
                         anim.SetPosition(Destination + ObjectPrivate.Position);
                     }
                     else
                     {
                         anim.SetPosition(Destination);
                     }
                 }
             }
         }
     }
 }
        protected override void SimpleInit()
        {
            if (RigidBodies.Count > 0)
            {
                int removed = RigidBodies.RemoveAll(rb => rb == null || !rb.IsValid || rb.GetMotionType() == RigidBodyMotionType.MotionTypeStatic);
                if (removed > 0)
                {
                    Log.Write(LogLevel.Error, __SimpleTag, "Position Reset: " + removed + " volumes removed because they were not set correctly or are static.");
                }
                if (RigidBodies.Count == 0)
                {
                    Log.Write(LogLevel.Error, __SimpleTag, "Position Reset requires a non-static rigid bodies to work properly. Volumes were set, but none could be used.");
                    return;
                }
            }
            else
            {
                RigidBodyComponent RigidBody;
                if (!ObjectPrivate.TryGetFirstComponent <RigidBodyComponent>(out RigidBody) || RigidBody.GetMotionType() == RigidBodyMotionType.MotionTypeStatic)
                {
                    Log.Write(LogLevel.Error, __SimpleTag, "Position Reset requires a non-static rigid body to work properly.");
                    return;
                }
                RigidBodies.Add(RigidBody);
            }
            if (StartEnabled)
            {
                Subscribe(null);
            }

            SubscribeToAll(EnableEvent, Subscribe);
            SubscribeToAll(DisableEvent, Unsubscribe);
        }
        protected override void SimpleInit()
        {
            AnimationComponent animComponent;

            if (!ObjectPrivate.TryGetFirstComponent <AnimationComponent>(out animComponent))
            {
                Log.Write(LogLevel.Error, "SimpleAnimation.Init", "Object must have an animation added at edit time for SimpleAnimation to work");
                return;
            }
            animation = animComponent.DefaultAnimation;

            initialAnimationParameters = animation.GetParameters();

            Subscribe(null);

            if (EnableEvent != "")
            {
                SubscribeToAll(EnableEvent, Subscribe);
            }

            if (DisableEvent != "")
            {
                SubscribeToAll(DisableEvent, Unsubscribe);
            }
        }
Exemple #5
0
    public override void Init()
    {
        if (!Enabled)
        {
            return;
        }

        if (ObjectPrivate.TryGetFirstComponent(out _animComp))
        {
            int animIndex = 0;

            foreach (var anim in _animComp.GetAnimations())
            {
                int    frameCount = anim.GetFrameCount();
                string name       = anim.GetName();

                Log.Write($"Object {ObjectPrivate.Name}: animation {animIndex} name '{name}' with {frameCount} frames");

                animIndex += 1;
            }

            _totalAnimations = animIndex;

            Log.Write($"Object {ObjectPrivate.Name}: has {_totalAnimations} animations");

            ListenForCommands();
        }
        else
        {
            Log.Write($"Object {ObjectPrivate.Name}: no animation");
        }
    }
Exemple #6
0
 public override void Init()
 {
     Wait(TimeSpan.FromSeconds(2.0));
     if (RigidBody == null)
     {
         if (!ObjectPrivate.TryGetFirstComponent(out RigidBody))
         {
             // Since object scripts are initialized when the scene loads, no one will actually see this message.
             ScenePrivate.Chat.MessageAllUsers("There is no RigidBodyComponent attached to this object.");
             return;
         }
         {
             //ScreenPos = RigidBody.GetPosition();
             //XScreenPos = ScreenPos[0];
             //YScreenPos = ScreenPos[1];
             //ZScreenPos = ScreenPos[2];
             //ScreenQuat = RigidBody.GetOrientation();
             //ScreenRot = ScreenQuat.GetEulerAngles();
             //XScreenRot = ScreenRot[0];
             //YScreenRot = ScreenRot[1];
             //ZScreenRot = ScreenRot[2];
             //ScreenRot = new Vector(XScreenRot, YScreenRot, ZScreenRot);
             ScenePrivate.Chat.Subscribe(0, GetChatCommand);
         }
     }
 }
Exemple #7
0
 private void LocalTeleport(int MoveNumber, ScriptEventData data)
 {
     Log.Write("MoveNumber: " + MoveNumber);
     LastCameraMan = CameraMan;
     foreach (AgentPrivate agent in ScenePrivate.GetAgents())
     {
         Log.Write(agent.AgentInfo.Name);
         if (agent.AgentInfo.Name == CameraMan)
         {
             Log.Write("Camaeraman found");
             ObjectPrivate objectPrivate = ScenePrivate.FindObject(agent.AgentInfo.ObjectId);
             if (objectPrivate != null)
             {
                 AnimationComponent anim = null;
                 if (objectPrivate.TryGetFirstComponent(out anim))
                 {
                     RigidBody.SetPosition(MoveVector[MoveNumber]);
                     Wait(TimeSpan.FromSeconds(0.05));
                     anim.SetPosition(MoveVector[MoveNumber]);
                     Wait(TimeSpan.FromSeconds(0.05));
                     Quaternion rotation = Quaternion.FromEulerAngles(Mathf.RadiansPerDegree * RotateVector[MoveNumber]);
                     RigidBody.SetOrientation(rotation);
                     //PlayMovement(MoveNumber, data);
                 }
             }
         }
     }
 }
Exemple #8
0
 public override void Init()
 {
     if (RigidBody == null)
     {
         if (!ObjectPrivate.TryGetFirstComponent(out RigidBody))
         {
             // Since object scripts are initialized when the scene loads, no one will actually see this message.
             ScenePrivate.Chat.MessageAllUsers("There is no RigidBodyComponent attached to this object.");
             return;
         }
         //ScenePrivate.Chat.Subscribe(0, "user", hit.AgentInfo.SessionId, GetChatCommand);
         ScenePrivate.Chat.Subscribe(0, GetChatCommand);
     }
     CurPos        = RigidBody.GetPosition();
     XWarehousePos = CurPos[0];
     YWarehousePos = CurPos[1];
     ZWarehousePos = CurPos[2];
     CurQuat       = RigidBody.GetOrientation();
     //XWarehouseRot = CurQuat[1];
     //YWarehouseRot = CurQuat[2];
     //ZWarehouseRot = CurQuat[3];
     //CurRot = new Vector(XWarehouseRot * pi / 180, YWarehouseRot * pi / 180, ZWarehouseRot * pi / 180);
     SlideMass = RigidBody.GetMass();
     //RigidBody.SetMotionType(RigidBodyMotionType.MotionTypeStatic);
     Log.Write("EXECUTING INIT");
     if (SubscribeToScriptEvent("SendScreenPos", getScreenPos).Active)
     {
         Log.Write("Subscription Was Active");
     }
     else
     {
         Log.Write("Subscription Was Not Active");
         SubscribeToScriptEvent("SendScreenPos", getScreenPos);
     }
 }
Exemple #9
0
    public override void Init()
    {
        if (!ObjectPrivate.TryGetFirstComponent <AnimationComponent>(out animComponent))
        {
            Log.Write(LogLevel.Error, "NPCAnimation.Init", "Object must have an animation added at edit time for NPCAnimation to work");
            return;
        }

        animation = animComponent.DefaultAnimation;
        animation.JumpToFrame(0);
        initialAnimationParameters = animation.GetParameters();
        SubscribeToAll("Kill", KillAnimation);

        if (EnableEvent != "")
        {
            Log.Write("Enable Event was not null: " + EnableEvent);
            SubscribeToAll(EnableEvent, Subscribe);
        }
        else
        {
            Subscribe(null);  //executes it by passing null data
        }

        if (DisableEvent != "")
        {
            SubscribeToAll(DisableEvent, Unsubscribe);
        }
    }
Exemple #10
0
    public override void Init()
    {
        //Log.Write("In Hide/UnHide");
        if (!ObjectPrivate.TryGetFirstComponent <MeshComponent>(out component))
        {
            Log.Write("No mesh component found!");
            return;
        }

        //Log.Write("initialVisibility: " + initialVisibility);
        if (initialVisibility)
        {
            component.SetIsVisible(true);
            currentVisibility = true;
        }
        else
        {
            component.SetIsVisible(false);
            currentVisibility = false;
        }
        //if (OnEvent.Length > 0) SubscribeToAll(OnEvent, OnEventExecute);
        if (HideEvent.Length > 0)
        {
            SubscribeToAll(HideEvent, HideEventExecute);
        }
        if (UnhideEvent.Length > 0)
        {
            //Log.Write("Subscribed to Unhide Event");
            SubscribeToAll(UnhideEvent, UnhideEventExecute);
        }
    }
    // Override Init to set up event handlers and start coroutines.
    public override void Init()
    {
        // When unhandled exceptions occur, they may be caught with this event handler.
        // Certain exceptions may not be recoverable at all and may cause the script to
        // immediately be removed.
        Script.UnhandledException += UnhandledException;

        // If the object had its components set in the editor they should now have the member initialized
        // The component can also be found dynamically
        if (RigidBody == null)
        {
            if (!ObjectPrivate.TryGetFirstComponent(out RigidBody))
            {
                // Since object scripts are initialized when the scene loads, no one will actually see this message.
                ScenePrivate.Chat.MessageAllUsers("There is no RigidBodyComponent attached to this object.");
                return;
            }
        }

        // Convert the supplied bools to the correct CollisionEventType to track
        CollisionEventType trackedEvents = 0;

        if (TrackAgentHits)
        {
            trackedEvents |= CollisionEventType.CharacterContact;
        }
        if (TrackObjectHits)
        {
            trackedEvents |= CollisionEventType.RigidBodyContact;
        }

        // StartCoroutine will queue CheckForCollisions to run
        // Arguments after the coroutine method are passed as arguments to the method.
        StartCoroutine(CheckForCollisions, trackedEvents);
    }
    // Override Init to set up event handlers and start coroutines.
    public override void Init()
    {
        Script.UnhandledException += UnhandledException;
        if (RigidBody == null)
        {
            if (!ObjectPrivate.TryGetFirstComponent(out RigidBody))
            {
                // Since object scripts are initialized when the scene loads, no one will actually see this message.
                ScenePrivate.Chat.MessageAllUsers("There is no RigidBodyComponent attached to this object.");
                return;
            }
        }

        CurPos        = RigidBody.GetPosition();
        XWarehousePos = CurPos[0];
        YWarehousePos = CurPos[1];
        ZWarehousePos = CurPos[2];

        // Convert the supplied bools to the correct CollisionEventType to track
        CollisionEventType trackedEvents = 0;

        trackedEvents |= CollisionEventType.RigidBodyContact;

        StartCoroutine(CheckForCollisions, trackedEvents);
    }
    public override void Init()
    {
        AnimationComponent component;

        if (!ObjectPrivate.TryGetFirstComponent <AnimationComponent>(out component))
        {
            Log.Write("No animation component");
            return;
        }
        anim = component.DefaultAnimation;

        if (anim == null)
        {
            Log.Write("This animation component has no default animation");
            return;
        }
        animParams = anim.GetParameters();

        animParams.PlaybackSpeed = PlaybackSpeed;
        animParams.PlaybackMode  = PingPong ? AnimationPlaybackMode.PingPong : AnimationPlaybackMode.Loop;

        //int totalFrameCount = anim.GetFrameCount();
        animParams.RangeStartFrame = StartFrame;
        animParams.RangeEndFrame   = EndFrame;
        animParams.ClampToRange    = true;

        WaitFor(anim.Play);
    }
    public override void Init()
    {
        //Log.Write("VR Init");
        Script.UnhandledException += UnhandledException; // Catch errors and keep running unless fatal

        if (RigidBody == null)
        {
            if (!ObjectPrivate.TryGetFirstComponent(out RigidBody))
            {
                // Since object scripts are initialized when the scene loads, no one will actually see this message.
                Log.Write("There is no RigidBodyComponent attached to this object.");
                //ScenePrivate.Chat.MessageAllUsers("There is no RigidBodyComponent attached to this object.");
                return;
            }
            else
            if (RigidBody.IsTriggerVolume())
            {
                Log.Write("Collision Subscription: " + collisionSubscription);
                if (collisionSubscription == null)
                {
                    collisionSubscription = RigidBody.Subscribe(CollisionEventType.AllCollisions, OnCollision, true);
                    //Log.Write("Subscribed to Collision");
                }
            }
        }
    }
Exemple #15
0
        public override void Init()
        {
            Script.UnhandledException += (object o, Exception e) => { if (DebugSpam)
                                                                      {
                                                                          Log.Write("UnhandledException", "[" + (o?.ToString() ?? "NULL") + "] " + e.ToString());
                                                                      }
            };

            SoundSettings.Loudness = LoudnessPercentToDb(LoudnessPct);
            Admins.AddRange(AdminHandles.Trim().ToLower().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries));
            Admins.Add(ScenePrivate.SceneInfo.AvatarId);
            OriginalOrientation = ObjectPrivate.InitialRotation;
            OriginalPosition    = ObjectPrivate.InitialPosition;

            if (ObjectPrivate.TryGetFirstComponent(out RigidBody))
            {
                if (!RigidBody.GetCanGrab())
                {
                    RigidBody.SetCanGrab(true, (data) => { if (!data.Success)
                                                           {
                                                               Log.Write("Could not set ModHammer to grabbable - won't be able to pick up the gun.");
                                                           }
                                         });
                }
                RigidBody.SubscribeToHeldObject(HeldObjectEventType.Grab, OnPickup);
                RigidBody.SubscribeToHeldObject(HeldObjectEventType.Release, OnDrop);
            }

            ScenePrivate.User.Subscribe("AddUser", AddUser);

            if (BanDuration > 0)
            {
                Timer.Create(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1), CleanupBans);
            }
        }
Exemple #16
0
    public override void Init()
    {
        //if (CameraManName != null) CameraMan = CameraManName;
        if (!ObjectPrivate.TryGetFirstComponent(out RigidBody))
        {
            Log.Write(LogLevel.Error, __SimpleTag, "Simple Mover requires a Rigidbody set to motion type Keyframed");
            return;
        }

        if (RigidBody.GetMotionType() != RigidBodyMotionType.MotionTypeKeyframed)
        {
            Log.Write(LogLevel.Error, __SimpleTag, "Simple Mover requires a Rigidbody set to motion type Keyframed");
            return;
        }

        SubscribeToAll("SetCameraMan", InitializeCameraMan);
        SubscribeToAll("SetDirector", InitializeDirector);

        if (EnableEvent != "")
        {
            Log.Write("Enable Event was not null: " + EnableEvent);
            SubscribeToAll(EnableEvent, ReadInParameters);
        }
        else
        {
            ReadInParameters(null);  //executes it by passing null data
        }

        if (DisableEvent != "")
        {
            SubscribeToAll(DisableEvent, Unsubscribe);
        }
    }
Exemple #17
0
    private void OnOwnerJoined(SessionId userId)
    {
        AgentPrivate agent = ScenePrivate.FindAgent(userId);

        // Lookup the scene object for this agent
        ObjectPrivate agentObejct = ScenePrivate.FindObject(agent.AgentInfo.ObjectId);

        if (agentObejct == null)
        {
            Log.Write($"Unable to find a ObjectPrivate component for user {userId}");
            return;
        }

        // Lookup the animation component. There should be just one, so grab the first
        AnimationComponent animationComponent = null;

        if (!agentObejct.TryGetFirstComponent(out animationComponent))
        {
            Log.Write($"Unable to find an animation component on user {userId}");
            return;
        }

        animationComponent.Subscribe(StartKey, StartSound);
        animationComponent.Subscribe(StopKey, StopSound);
    }
Exemple #18
0
        protected override void InitObjective()
        {
            RigidBodyComponent triggerVolume;

            if (ObjectPrivate.TryGetFirstComponent <RigidBodyComponent>(out triggerVolume) && triggerVolume.IsTriggerVolume())
            {
                if (!TriggerObjectives.Contains(triggerVolume))
                {
                    QLog(LogLevel.Info, "Adding scripted object as trigger volume.");
                    TriggerObjectives.Insert(0, triggerVolume);
                }
            }

            TriggerObjectives = TriggerObjectives.Distinct().ToList();
            TriggerHints      = TriggerHints.Distinct().ToList();
            int rbs = 0;

            for (int i = 0; i < TriggerObjectives.Count; ++i)
            {
                var trigger = TriggerObjectives[i];

                RigidBodyComponent hint = null;
                int index = i;
                if (trigger != null && trigger.IsValid && trigger.IsTriggerVolume())
                {
                    ++rbs;
                    QLog(LogLevel.Info, "Subscribing to collision " + trigger.Name + ", index " + index);

                    Collectors[i] = new Dictionary <SessionId, CollectionState>();
                    trigger.Subscribe(CollisionEventType.Trigger, (data) => OnCollide(data, index));

                    if (TriggerHints.Count > i)
                    {
                        hint = TriggerHints[i];
                    }
                    else if (TriggerHints.Count > 0)
                    {
                        hint = TriggerHints[0];
                    }

                    if (hint != null && hint.IsValid && hint.IsTriggerVolume())
                    {
                        QLog(LogLevel.Info, "Subscribing to hint " + hint.Name + ", index " + index);
                        hint.Subscribe(CollisionEventType.Trigger, (data) => HintCollide(data, index));
                    }
                }
            }

            if (rbs == 0)
            {
                QLog(LogLevel.Error, "Must be attached to a trigger volume or have Trigger Volumes set in Extra Objectives.");
                return;
            }

            SubscribeToAll(EnableEvent, (ScriptEventData) => { ScriptEnabled = true; });
            SubscribeToAll(DisableEvent, (ScriptEventData) => { ScriptEnabled = false; });
            ScriptEnabled = StartEnabled;

            Timer.Create(300, 500, Cleanup);
        }
Exemple #19
0
    public override void Init()
    {
        Script.UnhandledException += UnhandledException;
        if (RigidBody == null)
        {
            if (!ObjectPrivate.TryGetFirstComponent(out RigidBody))
            {
                // Since object scripts are initialized when the scene loads, no one will actually see this message.
                ScenePrivate.Chat.MessageAllUsers("There is no RigidBodyComponent attached to this object.");
                return;
            }
        }
        CurPos        = RigidBody.GetPosition();
        XWarehousePos = CurPos[0];
        //Log.Write(BeatBlockName + " initial X: " + XWarehousePos);
        YWarehousePos = CurPos[1];
        //Log.Write(BeatBlockName + " initial Y: " + YWarehousePos);
        ZWarehousePos = CurPos[2];
        //Log.Write(BeatBlockName + " initial Z: " + ZWarehousePos);
        CollisionEventType trackedEvents = 0;

        trackedEvents |= CollisionEventType.RigidBodyContact;
        //SubscribeToScriptEvent("Genre", getGenre);

        string myObject;

        myObject = ObjectPrivate.ObjectId.ToString();
        string BeatBlockConfigEvent       = "BeatBlockConfig" + myObject;
        string BeatBlockSampleConfigEvent = "BeatBlockSampleConfig" + myObject;

        BeatBlockConfigSub       = SubscribeToScriptEvent(BeatBlockConfigEvent, getBeatBlockcfg);
        BeatBlockSampleConfigSub = SubscribeToScriptEvent(BeatBlockSampleConfigEvent, getSamplescfg);
        StartCoroutine(CheckForCollisions, trackedEvents);
    }
    private void SubscribeToHotkey(SessionId userId)
    {
        AgentPrivate agent = ScenePrivate.FindAgent(userId);

        // Lookup the scene object for this agent
        ObjectPrivate agentObejct = ScenePrivate.FindObject(agent.AgentInfo.ObjectId);

        if (agentObejct == null)
        {
            Log.Write($"Unable to find a ObjectPrivate component for user {userId}");
            return;
        }

        // Lookup the animation component. There should be just one, so grab the first
        AnimationComponent animationComponent = null;

        if (!agentObejct.TryGetFirstComponent(out animationComponent))
        {
            Log.Write($"Unable to find an animation component on user {userId}");
            return;
        }

        // Listen for a key press. Since the agent will be teleporting away, do no request a persistent subscription
        animationComponent.Subscribe(TeleportHotkey, TeleportToNext, false);
    }
Exemple #21
0
        // Override Init to set up event handlers and start coroutines.
        public override void Init()
        {
            // When unhandled exceptions occur, they may be caught with this event handler.
            // Certain exceptions may not be recoverable at all and may cause the script to
            // immediately be removed. This will also break out of any loops in coroutines!
            Script.UnhandledException += UnhandledException;

            // If the object had its components set in the editor they should now have the member initialized
            // [Editor support for Component types is not yet implemented]
            // The component can also be found dynamically
            if (RigidBody == null)
            {
                if (!ObjectPrivate.TryGetFirstComponent(out RigidBody))
                {
                    // Since object scripts are initialized when the scene loads, no one will actually see this message.
                    Log.Write("There is no RigidBodyComponent attached to this object.");
                    return;
                }
            }

            // Initialize the Home position
            Home = RigidBody.GetPosition();

            // StartCoroutine will queue CheckForCollisions to run
            // Arguments after the coroutine method are passed as arguments to the method.
            StartCoroutine(CheckForCollisions);

            // Clamp our chaos to [0,1]
            StartCoroutine(Movement, Speed, Chaos.Clamp(0.0f, 1.0f));
        }
Exemple #22
0
    public override void Init()
    {
        //myVolume = ScenePrivate.PlayStream(StreamChannel.MediaChannel, 0);
        scenePlayHandle = ScenePrivate.PlayStream(StreamChannel.AudioChannel1, 0.0f);  //turns off scene audio
        ObjectPrivate.TryGetFirstComponent(out audio);
        if (audio == null)
        {
            Log.Write("Did Not Find Audio Component");
            ScenePrivate.Chat.MessageAllUsers("Media Screen for Youtube Viewer requires an Audio Emitter");
        }
        else
        {
            Log.Write("Found Audio Component");
            currentPlayHandle = audio.PlayStreamOnComponent(StreamChannel.AudioChannel1, volume);
            currentPlayHandle.SetLoudness(volume);

            SubscribeToAll("VolumeUp", VolumeUp);
            SubscribeToAll("VolumeDown", VolumeDown);
            SubscribeToAll("VolumeOn", VolumeOn);
            SubscribeToAll("VolumeOff", VolumeOff);
        }

        Log.Write("Script Started");

        Script.UnhandledException += UnhandledException; // Catch errors and keep running unless fatal
    }
Exemple #23
0
        protected override void SimpleInit()
        {
            if (TheObject == null)
            {
                Log.Write(LogLevel.Error, __SimpleTag, "SimpleDispenser requires a ClusterResource set to work properly.");
                return;
            }

            rnd = new Random();

            if (!ObjectPrivate.TryGetFirstComponent(out dispenserRigidBody))
            {
                dispenserRigidBody = null;
            }

            dispensedObjects = new LinkedList <ScenePrivate.CreateClusterData>();

            if (StartEnabled)
            {
                Subscribe(null);
            }

            SubscribeToAll(EnableEvent, Subscribe);
            SubscribeToAll(DisableEvent, Unsubscribe);

            hasPositionVariance        = (PositionVariance.LengthSquared() > 0.0f);
            hasRotationVariance        = (RotationVariance.LengthSquared() > 0.0f);
            hasLinearVelocityVariance  = (LinearVelocityVariance.LengthSquared() > 0.0f);
            hasAngularVelocityVariance = (AngularVelocityVariance.LengthSquared() > 0.0f);
            hasInitialAngularVelocity  = (InitialAngularVelocity.LengthSquared() > 0.0f) || hasAngularVelocityVariance || (InheritMotion && (dispenserRigidBody != null));
        }
Exemple #24
0
 public override void Init()
 {
     if (!ObjectPrivate.TryGetFirstComponent(out RigidBody))
     {
         Log.Write(LogLevel.Error, "Chopped couldn't find a RigidBody component.  That component is needed in order to detect when an avatar walks into them");
         return;
     }
 }
Exemple #25
0
    public override void Init()
    {
        if (!ObjectPrivate.TryGetFirstComponent <AnimationComponent>(out animComponent))
        {
            Log.Write(LogLevel.Error, "NPCAnimation.Init", "Object must have an animation added at edit time for NPCAnimation to work");
            return;
        }

        if (!ObjectPrivate.TryGetFirstComponent <RigidBodyComponent>(out rigidBodyComponent))
        {
            Log.Write(LogLevel.Error, "NPCAnimation.Init", "Object must have a rigid body added at edit time for NPCAnimation to work");
            return;
        }

        InitialPosition = rigidBodyComponent.GetPosition();
        Log.Write("Initial Position: " + InitialPosition);
        CurrentPosition = InitialPosition;

        animations = animComponent.GetAnimations();
        if (animations == null)
        {
            Log.Write("This animation component contains a single animation");
        }
        else
        {
            int i = 0;

            Log.Write("This animation component contains multiple animations");
            //hasMultipleAnimations = true;

            foreach (Animation animation in animations)
            {
                Log.Write($"[{i++}] {animation.GetName()} with {animation.GetFrameCount()} frames");
                animationList.Add(animation);
            }
        }

        animation = animComponent.DefaultAnimation;
        animation.JumpToFrame(0);
        initialAnimationParameters = animation.GetParameters();

        if (EnableEvent != "")
        {
            Log.Write("Enable Event was not null: " + EnableEvent);
            SubscribeToAll(EnableEvent, Subscribe);
        }
        else
        {
            Subscribe(null);  //executes it by passing null data
        }

        //if (DisableEvent != "")
        //{
        //    SubscribeToAll(DisableEvent, Unsubscribe);
        //}
    }
 public override void Init()
 {
     if (ObjectPrivate.TryGetFirstComponent(out RigidBody) && RigidBody.IsTriggerVolume())
     {
         RigidBody.Subscribe(CollisionEventType.Trigger, OnTrigger);
     }
     else
     {
         Log.Write(LogLevel.Error, "Could not start " + GetType().Name + " because no trigger volume was found.");
     }
 }
    public override void Init()
    {
        Log.Write("In TriggerMegaphone");
        if (!ObjectPrivate.TryGetFirstComponent(out RigidBody))
        {
            Log.Write(LogLevel.Error, "Could not start " + GetType().Name + " because no RigidBodyComponent was found.");
            return;
        }

        collisionSubscription = RigidBody.Subscribe(CollisionEventType.AllCollisions, OnCollision);
    }
Exemple #28
0
    public override void Init()
    {
        // set up private members
        playSettings.Looping  = Looped;
        playSettings.Loudness = RelativePercentToRelativeLoudnessDB(Volume_Diff_Percent);

        ObjectPrivate.TryGetFirstComponent(out audioComp);

        // Listen for new agents to join the scene
        ScenePrivate.User.Subscribe(User.AddUser, NewUser);
    }
Exemple #29
0
        protected override void SimpleInit()
        {
            ObjectPrivate.TryGetFirstComponent(out audio);

            if (StartEnabled)
            {
                SubscribeToMessages();
            }

            SubscribeToAll(EnableEvent, (ScriptEventData data) => { SubscribeToMessages(); });
            SubscribeToAll(DisableEvent, (ScriptEventData data) => { UnsubscribeFromMessages(); });
        }
Exemple #30
0
 public override void Init()
 {
     if (ObjectPrivate.TryGetFirstComponent(out RigidBody))
     {
         RigidBody.Subscribe(CollisionEventType.RigidBodyContact, OnChop);
     }
     else
     {
         Log.Write(LogLevel.Error, "Choppable couldn't find a RigidBody component.  That component is needed in order to detect when an avatar walks into them");
         return;
     }
 }