コード例 #1
0
        void HandleUpdate(uint eventType, ScriptVariantMap eventData)
        {
            float time = eventData.GetFloat("timestep");

            ElapsedTime += time;

#if !ATOMIC_IOS
            deltaTime += time;

            if (deltaTime < 1.0f / 60.0f)
            {
                return;
            }

            deltaTime = 0.0f;
#endif

            ShipInput.Update();

            if (!paused)
            {
                PlayerStatus.Update();
                EntityManager.Update();
                EnemySpawner.Update();
                ParticleManager.Update();
                Grid.Update();
            }
        }
コード例 #2
0
    void HandleNodeCollision(uint eventType, ScriptVariantMap eventData)
    {
        PhysicsNodeCollision nodeCollision = eventData.GetPtr <PhysicsNodeCollision>("PhysicsNodeCollision");

        if (nodeCollision == null)
        {
            return;
        }

        // TODO: We need to be able to subscribe to specific object's events
        if (nodeCollision.OtherNode == Node)
        {
            var nodePosition = Node.Position;

            for (uint i = 0; i < nodeCollision.Contacts.Size; i++)
            {
                var contact = nodeCollision.Contacts.At(i);

                var contactPosition = contact.Position;

                // TODO: This needs to be flipped when can listen to specific node

                // If contact is below node center and pointing up, assume it's a ground contact
                if (contactPosition.Y > (nodePosition.Y - 1.0f))
                {
                    float level = contact.Normal.Y;

                    if (level < 0.75f)
                    {
                        onGround = true;
                    }
                }
            }
        }
    }
コード例 #3
0
        void HandleRenderPathEvent(uint eventType, ScriptVariantMap eventData)
        {
            if (eventData.GetString("name") != "customrender")
            {
                return;
            }

            CustomRenderer.Begin();

            Draw();

            CustomRenderer.End();
        }
コード例 #4
0
        public static void Main(string[] args)
        {
            // create the service
            var app = NETServiceApplication.Create();

            // Subscribe to IPC NET commands
            app.SubscribeToEvent("IPCCmd", (eventType, eventData) =>
            {
                // get the command
                string command = eventData["command"];

                switch (command)
                {
                // parse assembly for component information
                case "parse":

                    // Get the assembly to parse
                    string assemblyPath = eventData["assemblyPath"];

                    // Inspect the assembly for components
                    var assemblyJSON = AtomicTools.InspectAssembly(assemblyPath);

                    // Return result
                    var vmap = new ScriptVariantMap();

                    // FIXME: update index operator to a generic
                    vmap.SetUInt("id", eventData.GetUInt("id"));

                    vmap["command"] = command;
                    vmap["result"]  = assemblyJSON;

                    AtomicNET.GetSubsystem <IPC>().SendEventToBroker("IPCCmdResult", vmap);

                    break;

                // exit service
                case "exit":

                    app.SendEvent("ExitRequested");
                    break;
                }
            });

            // Managed code in charge of main loop
            while (app.RunFrame())
            {
            }

            // Shut 'er down
            app.Shutdown();
        }