Esempio n. 1
0
        //check for newly placed or removed lcds
        //the timer for this should be biggish as all this is expensive
        internal void LCDScan(bool bCheckBlockDestroyed, IModApi api, float blockDist)
        {
            if (bCheckBlockDestroyed)
            {
                CheckAssociatedLCDs(api);
            }

            if (mStruct == null)
            {
                api.Log("Null struct in player struct list!");
                return;
            }
            if (!mStruct.IsReady)
            {
                api.Log("Struct: " + mStruct + " not ready...");
                return;
            }
            if (!mStruct.IsPowered)
            {
                //api.Log("Struct: " + mStruct + " not powered...");
                return;
            }

            /*
             * string	[]dTypeNames	=mStruct.GetDeviceTypeNames();
             * foreach(string dname in dTypeNames)
             * {
             *      api.Log("Device: " + dname);
             * }*/

            IDevicePosList idplAmmo      = mStruct.GetDevices("AmmoCntr");
            IDevicePosList idplContainer = mStruct.GetDevices("Container");
            IDevicePosList idplFridge    = mStruct.GetDevices("Fridge");
            IDevicePosList idplHarvest   = mStruct.GetDevices("HarvestCntr");

            CheckLCD(api, idplAmmo, idplContainer, idplFridge, idplHarvest, blockDist);
        }
Esempio n. 2
0
        /// <summary>
        /// Examines an IEntity instance to see if any feature will be interested in it.
        /// </summary>
        /// <param name="entity">The IEntity instance to be examined.</param>
        private void ProcessEntity(IEntity entity)
        {
            if (entity == null)
            {
                return;
            }

            EntityTokenizer entityTokens = null;

            // Process structure data of the entity.
            IStructure structure = entity.Structure;

            if (structure != null)
            {
                //DarkCity.LogDebug($"Processing structure {structure.Entity.Name}");

                if (EmpyrionExtension.LiveLcd &&
                    ((EmpyrionExtension.Application.Mode == ApplicationMode.PlayfieldServer) || (EmpyrionExtension.Application.Mode == ApplicationMode.SinglePlayer)))
                {
                    // Process LCD devices.
                    IDevicePosList list = structure.GetDevices(DeviceTypeName.LCD);
                    if (list != null)
                    {
                        for (int i = 0; i < list.Count; i++)
                        {
                            Eleon.Modding.VectorInt3 position = list.GetAt(i);
                            ILcd lcd = structure.GetDevice <ILcd>(position);
                            if (lcd != null)
                            {
                                // Prep structure tokens if not available yet.
                                if (entityTokens == null)
                                {
                                    entityTokens = new EntityTokenizer(entity);
                                }

                                // Hand off ILcd device to any potentially interested processors.
                                LiveLcd.Process(structure, lcd, position, entityTokens, this.PlayfieldTokens);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public void Add(IStructure structure)
        {
            if (structure == null)
            {
                return;
            }

            IDevicePosList containers = structure.GetDevices(DeviceTypeName.Container);

            if (containers != null)
            {
                for (int i = 0; i < containers.Count; i++)
                {
                    Eleon.Modding.VectorInt3 position = containers.GetAt(i);
                    IContainer container = structure.GetDevice <IContainer>(position);
                    if (container == null)
                    {
                        continue;
                    }
                    this.Add(container.GetContent());
                }
            }
        }