コード例 #1
0
        public bool AreAllPlayersSleeping()
        {
            int quantitySleeping = 0;
            int quantityAwake    = 0;

            foreach (IPlayer player in sapi.World.AllOnlinePlayers)
            {
                IServerPlayer splr = player as IServerPlayer;
                if (splr.ConnectionState != EnumClientState.Playing || splr.WorldData.CurrentGameMode == EnumGameMode.Spectator)
                {
                    continue;
                }

                IMountable mount = player.Entity?.MountedOn;
                if (mount != null && mount is BlockEntityBed)
                {
                    quantitySleeping++;
                }
                else
                {
                    quantityAwake++;
                }
            }

            return(quantitySleeping > 0 && quantityAwake == 0);
        }
コード例 #2
0
        public void WakeAllPlayers()
        {
            GameSpeedBoost = 0;
            api.World.Calendar.SetTimeSpeedModifier("sleeping", (int)GameSpeedBoost);

            if (api.Side == EnumAppSide.Client)
            {
                capi.World.Player?.Entity.TryUnmount();
                AllSleeping = false;
                return;
            }

            foreach (IPlayer player in sapi.World.AllOnlinePlayers)
            {
                IServerPlayer splr = player as IServerPlayer;
                if (splr.ConnectionState != EnumClientState.Playing || splr.WorldData.CurrentGameMode == EnumGameMode.Spectator)
                {
                    continue;
                }

                IMountable mount = player.Entity?.MountedOn;
                if (mount != null && mount is BlockEntityBed)
                {
                    player.Entity.TryUnmount();
                }
            }

            AllSleeping = false;
        }
コード例 #3
0
        public static void Register(FrameworkElement element, IMountable mountable)
        {
            if (!(element?.DataContext is IMountable))
            {
                throw new InvalidOperationException("The DataContext of the given element must inherit from IMountable");
            }

            element.Loaded   += (sender, args) => mountable.MountView();
            element.Unloaded += (sender, args) => mountable.UnmountView();
        }
コード例 #4
0
        /// <summary>
        /// Attempts to mount the player on a target.
        /// </summary>
        /// <param name="onmount">The mount to mount</param>
        /// <returns>Whether it was mounted or not.</returns>
        public bool TryMount(IMountable onmount)
        {
            this.MountedOn = onmount;
            controls.StopAllMovement();

            if (MountedOn?.SuggestedAnimation != null)
            {
                string anim = MountedOn.SuggestedAnimation.ToLowerInvariant();
                AnimManager?.StartAnimation(anim);
            }

            onmount.DidMount(this);

            return(true);
        }
コード例 #5
0
ファイル: EntityAgent.cs プロジェクト: anegostudios/vsapi
        /// <summary>
        /// Attempts to mount the player on a target.
        /// </summary>
        /// <param name="onmount">The mount to mount</param>
        /// <returns>Whether it was mounted or not.</returns>
        public bool TryMount(IMountable onmount)
        {
            if (MountedOn != onmount)
            {
                if (!TryUnmount())
                {
                    return(false);
                }
            }

            TreeAttribute mountableTree = new TreeAttribute();

            onmount?.MountableToTreeAttributes(mountableTree);
            WatchedAttributes["mountedOn"] = mountableTree;
            WatchedAttributes.MarkPathDirty("mountedOn"); // -> this calls updateMountedState()
            return(true);
        }
コード例 #6
0
ファイル: Mount.cs プロジェクト: ajinkya2020/FPS-GAME
        /// <summary>
        /// Removes mountable from the list of objects attached to the current mount, and adds to the list of the new mount.
        /// </summary>
        /// <param name="newMount"></param>
        public static void ChangeMounting(IMountable mountable, Mount prevMount, Mount newMount)
        {
            //Debug.Log("Change Mounting " + (prevMount ? prevMount.photonView.OwnerActorNr.ToString() : "null") + " -> " + (newMount ? newMount.photonView.OwnerActorNr.ToString() : "null"));

            if (!ReferenceEquals(prevMount, null))
            {
                prevMount.mountedObjs.Remove(mountable);
            }

            if (!ReferenceEquals(newMount, null))
            {
                var mountedObjs = newMount.mountedObjs;

                if (!mountedObjs.Contains(mountable))
                {
                    mountedObjs.Add(mountable);
                }
            }
        }
コード例 #7
0
ファイル: Mount.cs プロジェクト: emotitron/platformTest
        /// <summary>
        /// Removes mountable from the list of objects attached to the current mount, and adds to the list of the new mount.
        /// </summary>
        /// <param name="newmount"></param>
        public static void ChangeMounting(IMountable mountable, Mount newmount)
        {
            var currentMount = mountable.CurrentMount;

            if (!ReferenceEquals(currentMount, null))
            {
                currentMount.mountedObjs.Remove(mountable);
            }

            if (!ReferenceEquals(newmount, null))
            {
                var mountedObjs = newmount.mountedObjs;

                if (!mountedObjs.Contains(mountable))
                {
                    mountedObjs.Add(mountable);
                }
            }
        }