コード例 #1
0
        protected sealed override void PrepareProtoItem()
        {
            base.PrepareProtoItem();
            this.CompatibleContainerSlotsIds = this.SharedGetCompatibleContainerSlotsIds();

            if (IsClient)
            {
                using (var tempSourcePaths = Api.Shared.GetTempList <string>())
                {
                    this.ClientFillSlotAttachmentSources(tempSourcePaths);
                    using (var tempSpritePaths = ClientEquipmentSpriteHelper.CollectSpriteFilePaths(
                               tempSourcePaths.ToList()))
                    {
                        this.SlotAttachmentsMale = ClientEquipmentSpriteHelper.CollectSlotAttachments(
                            tempSpritePaths.AsList(),
                            this.Id,
                            isMale: true,
                            requireEquipmentTextures: this.RequireEquipmentTextures);

                        // we have not completed female sprites yet
                        this.SlotAttachmentsFemale = this.SlotAttachmentsMale;

                        foreach (var file in tempSpritePaths)
                        {
                            file.FilesInFolder.Dispose();
                        }
                    }
                }
            }

            var defenseDescription = new DefenseDescription();

            if (this.DefenseMultiplier < 0 ||
                this.DefenseMultiplier > 1)
            {
                throw new Exception(
                          $"{nameof(this.DefenseMultiplier)} must be in range from 0 to 1 (inclusive) for {this}. Current value is: {this.DefenseMultiplier:F2}");
            }

            defenseDescription.SetMultiplier(this.DefenseMultiplier);
            this.PrepareDefense(defenseDescription);
            var defense = defenseDescription.ToReadOnly();

            var effects = new Effects();

            defense.FillEffects(this, effects);
            this.PrepareEffects(effects);
            this.ProtoEffects = effects.ToReadOnly();

            this.PrepareProtoItemEquipment();
        }
コード例 #2
0
        protected sealed override void PrepareProtoWorldObject()
        {
            base.PrepareProtoWorldObject();

            var defaultTexture = this.PrepareDefaultTexture(this.GetType());

            if (defaultTexture is ITextureAtlasResource defaultTextureAtlas &&
                !(defaultTexture is ITextureAtlasChunkResource))
            {
                // use the first chunk of the atlas texture
                defaultTexture = defaultTextureAtlas.Chunk(0, 0);
            }

            this.DefaultTexture = defaultTexture;

            var layout = new StaticObjectLayout();

            this.CreateLayout(layout);
            this.Layout = layout.ToReadOnly();

            var defenseDescription = new DefenseDescription();

            // Set default defense for static objects. By default there is no defense except for psi and radiation which are set to Max.
            // Individual objects will override this value with some specific tier of defense in their own class.
            defenseDescription.Set(ObjectDefensePresets.Default);

            this.PrepareDefense(defenseDescription);
            var defense = defenseDescription.ToReadOnly();

            using (var effects = TempStatsCache.GetFromPool(isMultipliersSummed: true))
            {
                defense.FillEffects(this, effects, maximumDefensePercent: double.MaxValue);
                this.DefenseStats = effects.CalculateFinalStatsCache();
            }

            this.PrepareProtoStaticWorldObject();
        }