예제 #1
0
        private void Subscribe(ScriptEventData data)
        {
            unsubscribes = SubscribeToAll(EnableGrabEvent, (ScriptEventData subdata) =>
            {
                rigidBody.SetCanGrab(true);
            });

            unsubscribes += SubscribeToAll(DisableGrabEvent, (ScriptEventData subData) =>
            {
                rigidBody.SetCanGrab(false);
            });

            if (!string.IsNullOrWhiteSpace(GrabbedMessage))
            {
                grabSubscribe = rigidBody.SubscribeToHeldObject(HeldObjectEventType.Grab, (HeldObjectData holdData) =>
                {
                    if (ShouldSend(holdData))
                    {
                        SendToAll(GrabbedMessage, GrabReleaseData(holdData));
                    }
                });
            }

            if (!string.IsNullOrWhiteSpace(ReleasedMessage))
            {
                releaseSubscribe = rigidBody.SubscribeToHeldObject(HeldObjectEventType.Release, (HeldObjectData holdData) =>
                {
                    if (ShouldSend(holdData))
                    {
                        SendToAll(ReleasedMessage, GrabReleaseData(holdData));
                    }
                });
            }
        }
예제 #2
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);
            }
        }
예제 #3
0
    public override void Init()
    {
        if (ObjectPrivate.TryGetFirstComponent(out _rb))
        {
            _rb.SetCanGrab(false);  // Disable grabbing for this object

            if (_rb.GetMotionType() == RigidBodyMotionType.MotionTypeDynamic)
            {
                MyInteraction.Subscribe((InteractionData data) =>
                {
                    _rb.AddLinearImpulse(Vector.Up * 100.0f);
                });
            }
            else
            {
                Log.Write(LogLevel.Warning, "RigidBodyImpulseScript not running on a dynamic object!");
            }
        }
        else
        {
            Log.Write(LogLevel.Warning, "RigidBodyImpulseScript not running on an object with a physics volume!");
        }
    }