Beispiel #1
0
        public void OnTouch(int entityId, bool isHost)
        {
            var entity = FSGameLoop.GetGameInstance(isHost).EntityManager.FindEntity(entityId);
            var sd     = StayingData.Get(isHost, entityId);

            if (entity != null)
            {
                if (PassesCondition(entity))
                {
                    if (!_staying.Contains(sd))
                    {
                        _TriggerEnter(entity);
                        _staying.Add(sd);
                        OnTriggerEnter?.Invoke(entity);
                    }
                    else
                    {
                        _TriggerStay(entity);
                        OnTriggerStay?.Invoke(entity);
                    }
                }
                else
                {
                    if (_staying.Contains(sd))
                    {
                        _TriggerExit(entity);
                        _staying.Remove(sd);
                        OnTriggerExit?.Invoke(entity);
                    }
                }
            }
        }
Beispiel #2
0
 private void Start()
 {
     _returnToGame.onClick.AddListener(() =>
     {
         Close();
         UGuiManager.Instance.CloseModal <Modal_Console>();
         UGuiManager.Instance.CloseModal <Modal_Settings>();
         UGuiManager.Instance.CloseModal("ServerBrowser");
     });
     _settings.onClick.AddListener(() =>
     {
         UGuiManager.Instance.OpenModal <Modal_Settings>();
     });
     _serverBrowser.onClick.AddListener(() =>
     {
         UGuiManager.Instance.OpenModal("ServerBrowser");
     });
     _disconnect.onClick.AddListener(() =>
     {
         var game = FSGameLoop.GetGameInstance(false);
         if (game)
         {
             var csm = game.Network as ClientSocketManager;
             csm.Disconnect();
         }
     });
     _quit.onClick.AddListener(() =>
     {
         var game = FSGameLoop.GetGameInstance(false);
         if (game)
         {
             game.Quit();
         }
     });
 }
Beispiel #3
0
        public void OnInteract(int entityId, bool isHost)
        {
            var entity = FSGameLoop.GetGameInstance(isHost).EntityManager.FindEntity(entityId);

            if (entity != null && PassesCondition(entity))
            {
                _TriggerInteract(entity);
            }
        }
Beispiel #4
0
        public bool LoadPlugin(IUserPluginDescriptor descriptor, FSGameLoop game)
        {
            if (DescriptorIsLoaded(descriptor))
            {
                return(false);
            }

            if (!File.Exists(descriptor.EntryFilePath(PluginExtension)))
            {
                return(false);
            }

            if (descriptor.Dependencies != null && descriptor.Dependencies.Length > 0)
            {
                LogSystem.PrintColor(descriptor.Name + " has " + descriptor.Dependencies.Length + " dependencies", UnityEngine.Color.cyan);
                foreach (string s in descriptor.Dependencies)
                {
                    LogSystem.PrintColor("> " + s, UnityEngine.Color.cyan);
                    var dependency = FindDescriptor(s);
                    if (dependency == null || !LoadPlugin(dependency, game))
                    {
                        var couldntFind = string.Format("Couldn't load plugin: {0}, missing dependency: {1}",
                                                        descriptor.Name,
                                                        s);
                        LogSystem.PrintWarning(couldntFind);
                        return(false);
                    }
                }
            }

            var plugin = _LoadPlugin(descriptor, game);

            if (plugin != null)
            {
                Plugins.Add(plugin);

                var successMessage = '[' + descriptor.Space.ToString() + ']'
                                     + "Plugin loaded: "
                                     + descriptor.Name
                                     + " ("
                                     + descriptor.Version
                                     + ") by "
                                     + descriptor.Author
                                     + " ["
                                     + PluginExtension
                                     + ']';

                LogSystem.PrintColor(successMessage, UnityEngine.Color.green);

                return(true);
            }

            return(false);
        }
Beispiel #5
0
        public void OnEndTouch(int entityId, bool isHost)
        {
            var entity = FSGameLoop.GetGameInstance(isHost).EntityManager.FindEntity(entityId);
            var sd     = StayingData.Get(isHost, entityId);

            if (entity != null && _staying.Contains(sd))
            {
                _TriggerExit(entity);
                _staying.Remove(sd);
                OnTriggerExit?.Invoke(entity);
            }
        }
Beispiel #6
0
        private async void Start()
        {
            GameObject.DontDestroyOnLoad(gameObject);

            var client       = GetComponent <BareGameClient>();
            var serverResult = await client.GameLoader.CreateServerAsync("LoadActiveScene", "TestGamemode", "Testing my map!", RandomString(8));

            if (serverResult == GameLoadResult.Success)
            {
                var server     = FSGameLoop.GetGameInstance(true) as GameServer;
                var joinResult = await client.GameLoader.JoinGameAsync("localhost", server.Socket.GameplayPort, server.Socket.ServerPassword);
            }
        }
Beispiel #7
0
        public static void DisableEventSystem()
        {
            var game = FSGameLoop.GetGameInstance(false);

            if (game)
            {
                var cm = game.Get <CanvasManager>();
                if (cm && cm._uiEventSystem)
                {
                    cm._uiEventSystem.enabled = false;
                }
            }
        }
Beispiel #8
0
        public void LoadPlugins(PluginSpace space, FSGameLoop game)
        {
            UnloadPlugins(space);

            _gameReference = game;

            foreach (IUserPluginDescriptor descriptor in PluginDescriptors)
            {
                if (space == PluginSpace.All || space == descriptor.Space)
                {
                    LoadPlugin(descriptor, game);
                }
            }
        }
Beispiel #9
0
        private void Update()
        {
            var txt = $"{TimeStep.Instance.FPSCounter.AverageFPS} FPS";

            var cl = FSGameLoop.GetGameInstance(false);

            if (cl)
            {
                var cln = cl.Network as ClientSocketManager;
                txt = $"{txt} / {(int)(cln.AverageRoundtripTime * 1000f)} MS";
            }

            _text.text = txt;
        }
Beispiel #10
0
        public void OnStartTouch(int entityId, bool isHost)
        {
            var entity = FSGameLoop.GetGameInstance(isHost).EntityManager.FindEntity(entityId);

            if (entity != null)
            {
                var sd = StayingData.Get(isHost, entityId);
                if (_staying.Contains(sd) || !PassesCondition(entity))
                {
                    return;
                }
                _TriggerEnter(entity);
                _staying.Add(sd);
                OnTriggerEnter?.Invoke(entity);
            }
        }
Beispiel #11
0
        protected override IUserPlugin _LoadPlugin(IUserPluginDescriptor descriptor, FSGameLoop game)
        {
            try
            {
                var plugin = new LuaPlugin(descriptor);
                plugin.Game      = game;
                plugin.LogSystem = LogSystem;
                plugin.Load();
                return(plugin);
            }
            catch (System.Exception e)
            {
                LogSystem?.PrintWarning(e.ToString());
            }

            return(null);
        }
    static void ShowMenu(GameObject obj, Vector3 hitPoint, Vector3 hitNormal)
    {
        var menu = new GenericMenu();

        if (obj)
        {
            menu.AddDisabledItem(new GUIContent(obj.name));
        }
        menu.AddDisabledItem(new GUIContent($"Position: {hitPoint}"));
        menu.AddDisabledItem(new GUIContent($"Normal: {hitNormal}"));
        menu.AddSeparator(string.Empty);

        AddCreationOptions(menu, hitPoint, hitNormal);

        menu.AddItem(new GUIContent("Play From Here"), false, () =>
        {
            if (!EditorApplication.isPlaying)
            {
                PlayStateNotifier.PlayFrom = hitPoint;
                EditorApplication.EnterPlaymode();
            }
            else
            {
                var gs = FSGameLoop.GetGameInstance(true);
                if (gs &&
                    Human.Local != null &&
                    gs.EntityManager.TryFindEntity(Human.Local.EntityId, out NetEntity pl) &&
                    pl is Human hu)
                {
                    hu.Origin       = hitPoint;
                    hu.Velocity     = Vector3.zero;
                    hu.BaseVelocity = Vector3.zero;
                }
            }
        });
        menu.AddSeparator(string.Empty);

        menu.AddItem(new GUIContent("Close"), false, () => { });
        menu.ShowAsContext();
    }
Beispiel #13
0
 protected abstract IUserPlugin _LoadPlugin(IUserPluginDescriptor descriptor, FSGameLoop game);
Beispiel #14
0
 protected override void _Unload(FSGameLoop game)
 {
     Debug.Log("Test Gamemode Unloaded");
 }
Beispiel #15
0
 public ActorSync(FSGameLoop game)
     : base(game)
 {
 }
Beispiel #16
0
 public ActorSync(int actorId, FSGameLoop game)
     : base(game)
 {
     UniqueActorId = actorId;
 }
Beispiel #17
0
 public TestEntity(FSGameLoop game)
     : base(game)
 {
 }
Beispiel #18
0
        protected NetEntity(FSGameLoop game)
        {
            Game = game;

            BuildNetProps(this);
        }
Beispiel #19
0
        protected override void _Load(FSGameLoop game)
        {
            LockVars = false;

            Debug.Log("Test Gamemode Loaded");
        }
Beispiel #20
0
 public Equippable(FSGameLoop game)
     : base(game)
 {
 }
Beispiel #21
0
 public Human(FSGameLoop game)
     : base(game)
 {
 }