Ejemplo n.º 1
0
        public static void Register(CustomBlock block)
        {
            Console.WriteLine($"Registering block: {block.GetType()} #{block.BlockID} '{block.Name}'");
            int blockID = block.BlockID;

            CustomBlocks.Add(blockID, block);
            int      hashCode     = ItemTypeInfo.GetHashCode(ObjectTypes.Block, blockID);
            ManSpawn spawnManager = ManSpawn.inst;

            spawnManager.VisibleTypeInfo.SetDescriptor <FactionSubTypes>(hashCode, block.Faction);
            spawnManager.VisibleTypeInfo.SetDescriptor <BlockCategories>(hashCode, block.Category);
            spawnManager.AddBlockToDictionary(block.Prefab);
            RecipeManager.inst.m_BlockPriceLookup.Add(blockID, block.Price);
        }
Ejemplo n.º 2
0
        private void Initialize(GameObject prefab, bool clearGridInfo)
        {
            _customBlock        = new CustomBlock();
            _customBlock.Prefab = prefab;
            _customBlock.Prefab.SetActive(false);
            GameObject.DontDestroyOnLoad(_customBlock.Prefab);

            _customBlock.Prefab.tag   = "TankBlock";
            _customBlock.Prefab.layer = Globals.inst.layerTank;

            _visible        = _customBlock.Prefab.EnsureComponent <Visible>();
            _damageable     = _customBlock.Prefab.EnsureComponent <Damageable>();
            _moduleDamage   = _customBlock.Prefab.EnsureComponent <ModuleDamage>();
            _spriteRenderer = _customBlock.Prefab.EnsureComponent <AutoSpriteRenderer>();

            _block = _customBlock.Prefab.EnsureComponent <TankBlock>();
            if (clearGridInfo)
            {
                _block.attachPoints = new Vector3[] { };
                _block.filledCells  = new IntVector3[] { new Vector3(0, 0, 0) };
                _block.partialCells = new IntVector3[] { };
            }
        }