Ejemplo n.º 1
0
        public void LoadTypes(Game game)
        {
            List <IGameSystem> systemList = new List <IGameSystem>();

            InstantiateTypes(game, systemList, "game system");
            foreach (var s in systemList)
            {
                gameSystems.Add(s.GetType(), s);
            }

            InstantiateTypes(game, contextProviders, "context provider");

            // TODO: more evidence that these suck
            foreach (var def in defs.GetDefs <BldgDef>())
            {
                BldgProtoDef protoDef  = def.proto;
                Type         typeProto = protoDef.protoType;
                Type         typeDef   = protoDef.protoDefType;
                if (typeDef != def.GetType())
                {
                    BB.Assert(false, $"{def.GetType().Name}{def} registered with mismatched prototype (expected a {typeDef.Name}).");
                    continue;
                }

                var proto = TryInstantiate <IBuildingProto>("prototype", typeProto, game, def);
                if (proto != null)
                {
                    buildings.Add(def, proto);
                }
            }

            BB.LogInfo($"Found {buildings.Count} buildings:");
            foreach (var def in buildings.Keys)
            {
                BB.LogInfo($"    {def}");
            }
        }