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); } } } }
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(); } }); }
public void OnInteract(int entityId, bool isHost) { var entity = FSGameLoop.GetGameInstance(isHost).EntityManager.FindEntity(entityId); if (entity != null && PassesCondition(entity)) { _TriggerInteract(entity); } }
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); }
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); } }
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); } }
public static void DisableEventSystem() { var game = FSGameLoop.GetGameInstance(false); if (game) { var cm = game.Get <CanvasManager>(); if (cm && cm._uiEventSystem) { cm._uiEventSystem.enabled = false; } } }
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); } } }
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; }
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); } }
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(); }
protected abstract IUserPlugin _LoadPlugin(IUserPluginDescriptor descriptor, FSGameLoop game);
protected override void _Unload(FSGameLoop game) { Debug.Log("Test Gamemode Unloaded"); }
public ActorSync(FSGameLoop game) : base(game) { }
public ActorSync(int actorId, FSGameLoop game) : base(game) { UniqueActorId = actorId; }
public TestEntity(FSGameLoop game) : base(game) { }
protected NetEntity(FSGameLoop game) { Game = game; BuildNetProps(this); }
protected override void _Load(FSGameLoop game) { LockVars = false; Debug.Log("Test Gamemode Loaded"); }
public Equippable(FSGameLoop game) : base(game) { }
public Human(FSGameLoop game) : base(game) { }