Esempio n. 1
0
 static public int Begin(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 1)
         {
             UnityEngine.Profiling.CustomSampler self = (UnityEngine.Profiling.CustomSampler)checkSelf(l);
             self.Begin();
             pushValue(l, true);
             return(1);
         }
         else if (argc == 2)
         {
             UnityEngine.Profiling.CustomSampler self = (UnityEngine.Profiling.CustomSampler)checkSelf(l);
             UnityEngine.Object a1;
             checkType(l, 2, out a1);
             self.Begin(a1);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function Begin to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 2
0
 static public int End(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.Profiling.CustomSampler self = (UnityEngine.Profiling.CustomSampler)checkSelf(l);
         self.End();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
    protected override void OnCreate()
    {
        base.OnCreate();
        bufferSystem  = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();
        sampleForEach = UnityEngine.Profiling.CustomSampler.Create("SAMPLE ForEach stuff");

        teamUnitsAlive = GetEntityQuery(ComponentType.ReadOnly <Team>(), ComponentType.ReadOnly <Translation>(), ComponentType.ReadOnly <Health>());
    }
Esempio n. 4
0
    public void Init()
    {
#if UNITY_EDITOR
        sendSampler = UnityEngine.Profiling.CustomSampler.Create("sendSampler");
        recvSampler = UnityEngine.Profiling.CustomSampler.Create("recvSampler");
#endif
        //*******************获取配置START**********************************
        if (int.TryParse(AppCfg.expose.UdpPort, out udpPort) == false)
        {
            Debug.LogError("UDP端口配置错误");
        }
        if (int.TryParse(AppCfg.expose.TcpPort, out tcpPort) == false)
        {
            Debug.LogError("Tcp端口配置错误");
        }
        autoConnect      = AppCfg.expose.AutoConnect;
        netGroup         = AppCfg.expose.NetGroup;
        isHost           = AppCfg.expose.IsHost;
        differentUdpPort = AppCfg.expose.differentUdpPort;
        Debug.Log("isHost:" + isHost + " autoConnect:" + autoConnect + " netGroup:" + netGroup + " tcpPort:" + tcpPort + " udpPort:" + udpPort);
        //*******************获取配置END**********************************
        if (differentUdpPort)
        {
            broadCastList = new Dictionary <int, IPEndPoint>();
        }

        //通知逻辑层的事件
        eventLib = new NetNotiLib <byte>();

        //作为主机
        if (isHost)
        {
            server = new GameServer(autoConnect, tcpPort, broadCastPort, netGroup);
        }

        //通过主机UDP广播自动连接
        if (autoConnect)
        {
            if (isHost)
            {
                ConenctTcp("127.0.0.1");
            }
            else
            {
                //建立UDP获取主机广播IP
                recvBroadCastIP  = true;
                syncIpConnection = new UdpBase(broadCastPort, "SyncIP_Client");
                Debug.Log("等待主机发送IP");
            }
        }
        else
        {
            //不自动连接会直接连接配置里的主机IP
            ConenctTcp(AppCfg.expose.IpAddress);
        }
    }
Esempio n. 5
0
 static public int End(IntPtr l)
 {
     try {
         UnityEngine.Profiling.CustomSampler self = (UnityEngine.Profiling.CustomSampler)checkSelf(l);
         self.End();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int Begin__Object(IntPtr l)
 {
     try {
         UnityEngine.Profiling.CustomSampler self = (UnityEngine.Profiling.CustomSampler)checkSelf(l);
         UnityEngine.Object a1;
         checkType(l, 2, out a1);
         self.Begin(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 7
0
 static public int Begin(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 1)
         {
             UnityEngine.Profiling.CustomSampler self = (UnityEngine.Profiling.CustomSampler)checkSelf(l);
             self.Begin();
             pushValue(l, true);
             return(1);
         }
         else if (argc == 2)
         {
             UnityEngine.Profiling.CustomSampler self = (UnityEngine.Profiling.CustomSampler)checkSelf(l);
             UnityEngine.Object a1;
             checkType(l, 2, out a1);
             self.Begin(a1);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function Begin to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Esempio n. 8
0
    /// <summary>
    /// Starts the main part of the game.
    /// Checks if a game exists to load, and if so loads it.
    /// If not, we generate a game <see cref="GameManager.GenerateGame(int)"/>
    /// If we generate a game, at current we set the players location
    /// </summary>
    void Start()
    {
        Debug.BeginDeepProfile("game_start");
        if (GameToLoad == null || GameToLoad == "none")
        {
            Stopwatch s = new Stopwatch();
            s.Start();
            //UnityEngine.Profiling.CustomSampler gen = UnityEngine.Profiling.CustomSampler.Create("GenSampler");
            int seed = 0;
            Debug.Log("No game to load, generating with seed " + seed);

            GenerateGame(seed);
            PathFinder = new PathFinder(WorldManager.World);
            PathFinder.SetPlayerPosition(PlayerManager.Player.TilePos);

            System.GC.Collect();
            s.Stop();
            Debug.Log("Generation took total time: " + s.ElapsedMilliseconds / 1000f);
            DebugGUI.SetData("genTime", s.ElapsedMilliseconds / 1000f);
        }
        else
        {
            UnityEngine.Profiling.CustomSampler load = UnityEngine.Profiling.CustomSampler.Create("LoadSampler");
            load.Begin();
            GameLoadSave gls   = LoadSave.Load();
            World        world = new World();
            world.LoadWorld(gls);
            EntityManager.Load(gls);
            WorldManager.SetWorld(world);
            Player player = new Player();
            TestSettle = WorldManager.World.GetSettlement(0);
            Vec2i set = TestSettle.Centre;
            //player.SetPosition(new Vector3(set.x * World.ChunkSize, 0, set.z * World.ChunkSize));
            player.SetPosition(new Vector3(World.WorldSize / 2 * World.ChunkSize, 0, World.WorldSize / 2 * World.ChunkSize));
            PlayerManager.SetPlayer(player);

            load.End();
        }
        Debug.EndDeepProfile("game_start");



        RNG = new GenerationRandom(System.DateTime.Now.Millisecond);
    }
        public static CustomSampler Create(string name)
        {
            CustomSampler customSampler = CustomSampler.CreateInternal(name);

            return(customSampler ?? CustomSampler.s_InvalidCustomSampler);
        }
 public void End()
 {
     CustomSampler.End_Internal(this.m_Ptr);
 }
 public void Begin(UnityEngine.Object targetObject)
 {
     CustomSampler.BeginWithObject_Internal(this.m_Ptr, targetObject);
 }
 public void Begin()
 {
     CustomSampler.Begin_Internal(this.m_Ptr);
 }