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);
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
0
    // 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);
    }
Esempio n. 3
0
        private void findColliders(List <RigidBodyComponent> colliders, ObjectId id)
        {
            if (!ToggleCollisions)
            {
                return;
            }

            ObjectPrivate op = ScenePrivate.FindObject(id);

            if (op != null)
            {
                for (uint rbi = 0; rbi < op.GetComponentCount(ComponentType.RigidBodyComponent); ++rbi)
                {
                    if (op.TryGetComponent(rbi, out RigidBodyComponent rb))
                    {
                        if (rb != null)
                        {
                            if (colliders.Contains(rb))
                            {
                                return;
                            }
                            colliders.Add(rb);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        bool ResetToInitialPosition(RigidBodyComponent rigidBody)
        {
            ObjectPrivate objectPrivate = ScenePrivate.FindObject(rigidBody.ComponentId.ObjectId);

            if (objectPrivate != null && objectPrivate.IsValid)
            {
                try
                {
                    var motionType = rigidBody.GetMotionType();
                    WaitFor(rigidBody.SetMotionType, RigidBodyMotionType.MotionTypeKeyframed);
                    rigidBody.SetAngularVelocity(Vector.Zero);
                    rigidBody.SetLinearVelocity(Vector.Zero);
                    rigidBody.SetOrientation(objectPrivate.InitialRotation);
                    rigidBody.SetPosition(objectPrivate.InitialPosition);
                    rigidBody.SetMotionType(motionType);
                    return(true);
                }
                catch
                {
                    Log.Write(LogLevel.Error, __SimpleTag, "Position Reset: error resetting object position.");
                }
            }

            return(false);
        }
Esempio n. 6
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");
        }
    }
    private void UpdateRightPosition()
    {
        //Log.Write("In UpdatePosition UserIn is: " + UserIn);
        //Log.Write("Right: " + agent.GetControlPointPosition(ControlPointType.RightTool));
        ObjectPrivate AgentObject = ScenePrivate.FindObject(agent.AgentInfo.ObjectId);

        if (MultiClick)
        {
            do
            {
                Vector     AgentPosition      = AgentObject.Position;
                Quaternion AgentRotation      = AgentObject.Rotation;
                Vector     RightPosition      = agent.GetControlPointPosition(ControlPointType.RightTool);
                Vector     WorldRightPosition = LocalToWorld(AgentPosition, AgentRotation, RightPosition);

                RightActionToPerform(RightPosition, WorldRightPosition, AgentPosition, AgentRotation);
                Wait(TimeSpan.FromMilliseconds(timeDelay));
            }while (UserIn && RightTriggerPressed);
        }
        else
        {
            //do once
            Vector     AgentPosition      = AgentObject.Position;
            Quaternion AgentRotation      = AgentObject.Rotation;
            Vector     RightPosition      = agent.GetControlPointPosition(ControlPointType.RightTool);
            Vector     WorldRightPosition = LocalToWorld(AgentPosition, AgentRotation, RightPosition);

            RightActionToPerform(RightPosition, WorldRightPosition, AgentPosition, AgentRotation);
        }

        //Log.Write("Out of Loop");
    }
Esempio n. 8
0
        public void Check()
        {
            List <ObjectId> keys = new List <ObjectId>(AllObjects.Keys);

            foreach (var opId in keys)
            {
                ObjectPrivate op = ScenePrivate.FindObject(opId);
                if (op == null ||
                    !op.IsValid)
                {
                    Error(op.Name);
                    AllObjects.Remove(opId);
                    continue;
                }

                int oldScriptCount = AllObjects[opId];
                int newScriptCount = op.LookupScripts().Length;
                if (oldScriptCount > newScriptCount)
                {
                    Error(op.Name);
                }

                // Either still initializing and adding scripts or only logging.
                AllObjects[opId] = newScriptCount;
            }
        }
    // 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);
    }
Esempio n. 10
0
    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);
    }
Esempio n. 11
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);
     }
 }
Esempio n. 12
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);
            }
        }
Esempio n. 13
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);
        }
Esempio n. 14
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);
        }
    }
Esempio n. 15
0
        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);
            }
        }
Esempio n. 16
0
    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);
    }
Esempio n. 17
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);
    }
Esempio n. 18
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);
         }
     }
 }
Esempio n. 19
0
        private void newUser(UserData data)
        {
            AgentPrivate  agentPrivate  = ScenePrivate.FindAgent(data.User);
            ObjectPrivate objectPrivate = ScenePrivate.FindObject(agentPrivate.AgentInfo.ObjectId);

            reset(agentPrivate, objectPrivate);
        }
Esempio n. 20
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));
        }
Esempio n. 21
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);
    }
    // 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);
    }
Esempio n. 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));
        }
Esempio n. 24
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);
        }
    }
Esempio n. 25
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);
                 }
             }
         }
     }
 }
Esempio n. 26
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);
        }
    }
Esempio n. 27
0
    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");
                }
            }
        }
    }
Esempio n. 28
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
    }
Esempio n. 29
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;
     }
 }
Esempio n. 30
0
        private void CancelOnMoveCoroutine(ObjectPrivate agentObject, AgentPrivate agent, SessionId sessionId)
        {
            Vector startPosition;

            try
            {
                startPosition = agentObject.Position;
            }
            catch
            {
                Log.Write(LogLevel.Warning, "Error getting agent position, agent might have left");
                return;
            }

            float timeCheck = 0.0f;

            bool monitoring = true;

            while (monitoring)
            {
                Vector agentPosition;
                string hintText;
                try
                {
                    agentPosition = agentObject.Position;
                    hintText      = agent.Client.UI.HintText;
                }
                catch
                {
                    Log.Write(LogLevel.Warning, "Error getting agent position, agent might have left");
                    return;
                }
                if (string.IsNullOrEmpty(hintText))
                {
                    return;
                }
                if ((agentPosition - startPosition).LengthSquared() > cAgentMoveToleranceSqr)
                {
                    try
                    {
                        agent.Client.UI.HintText = null;
                    }
                    catch
                    {
                        Log.Write(LogLevel.Warning, "Error clearing text, agent might have left");
                    }
                    break;
                }

                Wait(cAgentMoveCheckTimestep);

                timeCheck += cAgentMoveCheckTimestep;

                monitoring = agent != null && agent.IsValid;
            }
            CancelHideTimer(sessionId);
        }