示例#1
0
        private void PlayExplosionSound(SoundDef explosionSound)
        {
            bool flag;

            if (Prefs.DevMode)
            {
                flag = (explosionSound != null);
            }
            else
            {
                flag = !explosionSound.NullOrUndefined();
            }
            if (flag)
            {
                explosionSound.PlayOneShot(new TargetInfo(base.Position, base.Map, false));
            }
            else
            {
                this.damType.soundExplosion.PlayOneShot(new TargetInfo(base.Position, base.Map, false));
            }
        }
示例#2
0
        public static bool CorrectContextNow(SoundDef def, Map sourceMap)
        {
            if (sourceMap != null && (Find.CurrentMap != sourceMap || WorldRendererUtility.WorldRenderedNow))
            {
                return(false);
            }
            switch (def.context)
            {
            case SoundContext.Any:
                return(true);

            case SoundContext.MapOnly:
                return(Current.ProgramState == ProgramState.Playing && !WorldRendererUtility.WorldRenderedNow);

            case SoundContext.WorldOnly:
                return(WorldRendererUtility.WorldRenderedNow);

            default:
                throw new NotImplementedException();
            }
        }
示例#3
0
        public static SoundDef Named(string defName)
        {
            SoundDef namedSilentFail = DefDatabase <SoundDef> .GetNamedSilentFail(defName);

            if (namedSilentFail != null)
            {
                return(namedSilentFail);
            }
            if (!Prefs.DevMode)
            {
                lock (undefinedSoundDefsLock)
                {
                    if (undefinedSoundDefs.ContainsKey(defName))
                    {
                        return(UndefinedDefNamed(defName));
                    }
                }
            }
            List <SoundDef> allDefsListForReading = DefDatabase <SoundDef> .AllDefsListForReading;

            for (int i = 0; i < allDefsListForReading.Count; i++)
            {
                if (allDefsListForReading[i].eventNames.Count <= 0)
                {
                    continue;
                }
                for (int j = 0; j < allDefsListForReading[i].eventNames.Count; j++)
                {
                    if (allDefsListForReading[i].eventNames[j] == defName)
                    {
                        return(allDefsListForReading[i]);
                    }
                }
            }
            if (DefDatabase <SoundDef> .DefCount == 0)
            {
                Log.Warning("Tried to get SoundDef named " + defName + ", but sound defs aren't loaded yet (is it a static variable initialized before play data?).");
            }
            return(UndefinedDefNamed(defName));
        }
        // Token: 0x06000008 RID: 8 RVA: 0x000022A8 File Offset: 0x000004A8
        public override IEnumerable <Gizmo> CompGetGizmosExtra()
        {
            bool flag = Find.Selector.SingleSelectedThing == GetWearer;

            if (flag)
            {
                int            num            = 700000101;
                Command_Action command_Action = new Command_Action();
                switch (this.lightMode)
                {
                case CompEquippableLight.LightMode.Automatic:
                    command_Action.icon = ContentFinder <Texture2D> .Get("Ui/Commands/CommandButton_LigthModeAutomatic", true);

                    command_Action.defaultLabel = "Ligth: automatic.";
                    break;

                case CompEquippableLight.LightMode.ForcedOn:
                    command_Action.icon = ContentFinder <Texture2D> .Get("Ui/Commands/CommandButton_LigthModeForcedOn", true);

                    command_Action.defaultLabel = "Ligth: on.";
                    break;

                case CompEquippableLight.LightMode.ForcedOff:
                    command_Action.icon = ContentFinder <Texture2D> .Get("Ui/Commands/CommandButton_LigthModeForcedOff", true);

                    command_Action.defaultLabel = "Ligth: off.";
                    break;
                }
                command_Action.defaultDesc   = "Switch mode.";
                command_Action.activateSound = SoundDef.Named("Click");
                command_Action.action        = new Action(this.SwitchLigthMode);
                command_Action.groupKey      = num + 1;

                yield return(command_Action);
            }
            yield break;
        }
示例#5
0
        public void ToggleableIcon(ref bool toggleable, Texture2D tex, string tooltip, SoundDef mouseoverSound = null, string tutorTag = null)
        {
            IncrementYIfWillExceedMaxWidth(24f);
            Rect rect = new Rect(LeftX(24f), curY, 24f, 24f);
            bool num  = Widgets.ButtonImage(rect, tex);

            IncrementPosition(24f + gap);
            if (!tooltip.NullOrEmpty())
            {
                TooltipHandler.TipRegion(rect, tooltip);
            }
            Rect      position = new Rect(rect.x + rect.width / 2f, rect.y, rect.height / 2f, rect.height / 2f);
            Texture2D image    = toggleable ? Widgets.CheckboxOnTex : Widgets.CheckboxOffTex;

            GUI.DrawTexture(position, image);
            if (mouseoverSound != null)
            {
                MouseoverSounds.DoRegion(rect, mouseoverSound);
            }
            if (num)
            {
                toggleable = !toggleable;
                if (toggleable)
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera();
                }
                else
                {
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                }
            }
            if (tutorTag != null)
            {
                UIHighlighter.HighlightOpportunity(rect, tutorTag);
            }
        }
        private static void GetNearestLifestageSound(Pawn pawn, Func <LifeStageAge, SoundDef> getter, out SoundDef def, out float pitch, out float volume)
        {
            int          num = pawn.ageTracker.CurLifeStageIndex;
            LifeStageAge lifeStageAge;

            for (;;)
            {
                lifeStageAge = pawn.RaceProps.lifeStageAges[num];
                def          = getter(lifeStageAge);
                if (def != null)
                {
                    break;
                }
                num++;
                if (num < 0 || num >= pawn.RaceProps.lifeStageAges.Count)
                {
                    goto IL_95;
                }
            }
            pitch  = pawn.ageTracker.CurLifeStage.voxPitch / lifeStageAge.def.voxPitch;
            volume = pawn.ageTracker.CurLifeStage.voxVolume / lifeStageAge.def.voxVolume;
            return;

IL_95:
            def   = null;
            pitch = (volume = 1f);
        }
 public static bool NullOrUndefined(this SoundDef def)
 {
     return(def?.isUndefined ?? true);
 }
 public Window()
 {
     this.soundAppear = SoundDefOf.DialogBoxAppear;
     this.soundClose  = SoundDefOf.Click;
 }
示例#9
0
 public static void DoExplosion(IntVec3 center, Map map, float radius, DamageDef damType, Thing instigator, int damAmount = -1, float armorPenetration = -1f, SoundDef explosionSound = null, ThingDef weapon = null, ThingDef projectile = null, Thing intendedTarget = null, ThingDef postExplosionSpawnThingDef = null, float postExplosionSpawnChance = 0f, int postExplosionSpawnThingCount = 1, bool applyDamageToExplosionCellsNeighbors = false, ThingDef preExplosionSpawnThingDef = null, float preExplosionSpawnChance = 0f, int preExplosionSpawnThingCount = 1, float chanceToStartFire = 0f, bool damageFalloff = false)
 {
     if (map == null)
     {
         Log.Warning("Tried to do explosion in a null map.", false);
     }
     else
     {
         if (damAmount < 0)
         {
             damAmount        = damType.defaultDamage;
             armorPenetration = damType.defaultArmorPenetration;
             if (damAmount < 0)
             {
                 Log.ErrorOnce("Attempted to trigger an explosion without defined damage", 91094882, false);
                 damAmount = 1;
             }
         }
         if (armorPenetration < 0f)
         {
             armorPenetration = (float)damAmount * 0.015f;
         }
         Explosion explosion = (Explosion)GenSpawn.Spawn(ThingDefOf.Explosion, center, map, WipeMode.Vanish);
         explosion.radius                               = radius;
         explosion.damType                              = damType;
         explosion.instigator                           = instigator;
         explosion.damAmount                            = damAmount;
         explosion.armorPenetration                     = armorPenetration;
         explosion.weapon                               = weapon;
         explosion.projectile                           = projectile;
         explosion.intendedTarget                       = intendedTarget;
         explosion.preExplosionSpawnThingDef            = preExplosionSpawnThingDef;
         explosion.preExplosionSpawnChance              = preExplosionSpawnChance;
         explosion.preExplosionSpawnThingCount          = preExplosionSpawnThingCount;
         explosion.postExplosionSpawnThingDef           = postExplosionSpawnThingDef;
         explosion.postExplosionSpawnChance             = postExplosionSpawnChance;
         explosion.postExplosionSpawnThingCount         = postExplosionSpawnThingCount;
         explosion.applyDamageToExplosionCellsNeighbors = applyDamageToExplosionCellsNeighbors;
         explosion.chanceToStartFire                    = chanceToStartFire;
         explosion.damageFalloff                        = damageFalloff;
         explosion.StartExplosion(explosionSound);
     }
 }
示例#10
0
 public static bool NullOrUndefined(this SoundDef def)
 {
     return(def == null || def.isUndefined);
 }
        private static void GetNearestLifestageSound(Pawn pawn, Func <LifeStageAge, SoundDef> getter, out SoundDef def, out float pitch, out float volume)
        {
            int num = pawn.ageTracker.CurLifeStageIndex;

            do
            {
                LifeStageAge lifeStageAge = pawn.RaceProps.lifeStageAges[num];
                def = getter(lifeStageAge);
                if (def != null)
                {
                    pitch  = pawn.ageTracker.CurLifeStage.voxPitch / lifeStageAge.def.voxPitch;
                    volume = pawn.ageTracker.CurLifeStage.voxVolume / lifeStageAge.def.voxVolume;
                    return;
                }
                num++;
            }while (num >= 0 && num < pawn.RaceProps.lifeStageAges.Count);
            def   = null;
            pitch = (volume = 1f);
        }
示例#12
0
        public static void DoExplosion(IntVec3 center, Map map, float radius, DamageDef damType, Thing instigator, int damAmount = -1, float armorPenetration = -1f, SoundDef explosionSound = null, ThingDef weapon = null, ThingDef projectile = null, Thing intendedTarget = null, ThingDef postExplosionSpawnThingDef = null, float postExplosionSpawnChance = 0f, int postExplosionSpawnThingCount = 1, bool applyDamageToExplosionCellsNeighbors = false, ThingDef preExplosionSpawnThingDef = null, float preExplosionSpawnChance = 0f, int preExplosionSpawnThingCount = 1, float chanceToStartFire = 0f, bool damageFalloff = false, float?direction = null, List <Thing> ignoredThings = null)
        {
            if (map == null)
            {
                Log.Warning("Tried to do explosion in a null map.");
                return;
            }
            if (damAmount < 0)
            {
                damAmount        = damType.defaultDamage;
                armorPenetration = damType.defaultArmorPenetration;
                if (damAmount < 0)
                {
                    Log.ErrorOnce("Attempted to trigger an explosion without defined damage", 91094882);
                    damAmount = 1;
                }
            }
            if (armorPenetration < 0f)
            {
                armorPenetration = (float)damAmount * 0.015f;
            }
            Explosion obj            = (Explosion)GenSpawn.Spawn(ThingDefOf.Explosion, center, map);
            IntVec3?  needLOSToCell  = null;
            IntVec3?  needLOSToCell2 = null;

            if (direction.HasValue)
            {
                CalculateNeededLOSToCells(center, map, direction.Value, out needLOSToCell, out needLOSToCell2);
            }
            obj.radius                               = radius;
            obj.damType                              = damType;
            obj.instigator                           = instigator;
            obj.damAmount                            = damAmount;
            obj.armorPenetration                     = armorPenetration;
            obj.weapon                               = weapon;
            obj.projectile                           = projectile;
            obj.intendedTarget                       = intendedTarget;
            obj.preExplosionSpawnThingDef            = preExplosionSpawnThingDef;
            obj.preExplosionSpawnChance              = preExplosionSpawnChance;
            obj.preExplosionSpawnThingCount          = preExplosionSpawnThingCount;
            obj.postExplosionSpawnThingDef           = postExplosionSpawnThingDef;
            obj.postExplosionSpawnChance             = postExplosionSpawnChance;
            obj.postExplosionSpawnThingCount         = postExplosionSpawnThingCount;
            obj.applyDamageToExplosionCellsNeighbors = applyDamageToExplosionCellsNeighbors;
            obj.chanceToStartFire                    = chanceToStartFire;
            obj.damageFalloff                        = damageFalloff;
            obj.needLOSToCell1                       = needLOSToCell;
            obj.needLOSToCell2                       = needLOSToCell2;
            obj.StartExplosion(explosionSound, ignoredThings);
        }
示例#13
0
        public static void DoExplosion(IntVec3 center, Map map, float radius, DamageDef damType, Thing instigator, int damAmount = -1, SoundDef explosionSound = null, ThingDef weapon = null, ThingDef projectile = null, ThingDef postExplosionSpawnThingDef = null, float postExplosionSpawnChance = 0f, int postExplosionSpawnThingCount = 1, bool applyDamageToExplosionCellsNeighbors = false, ThingDef preExplosionSpawnThingDef = null, float preExplosionSpawnChance = 0f, int preExplosionSpawnThingCount = 1, float chanceToStartFire = 0f, bool dealMoreDamageAtCenter = false)
        {
            if (map == null)
            {
                Log.Warning("Tried to do explosion in a null map.");
                return;
            }
            if (damAmount == 0)
            {
                damAmount = 1;
            }
            Explosion explosion = (Explosion)GenSpawn.Spawn(ThingDefOf.Explosion, center, map);

            explosion.radius     = radius;
            explosion.damType    = damType;
            explosion.instigator = instigator;
            explosion.damAmount  = ((damAmount <= 0) ? damType.explosionDamage : damAmount);
            explosion.weapon     = weapon;
            explosion.projectile = projectile;
            explosion.preExplosionSpawnThingDef            = preExplosionSpawnThingDef;
            explosion.preExplosionSpawnChance              = preExplosionSpawnChance;
            explosion.preExplosionSpawnThingCount          = preExplosionSpawnThingCount;
            explosion.postExplosionSpawnThingDef           = postExplosionSpawnThingDef;
            explosion.postExplosionSpawnChance             = postExplosionSpawnChance;
            explosion.postExplosionSpawnThingCount         = postExplosionSpawnThingCount;
            explosion.applyDamageToExplosionCellsNeighbors = applyDamageToExplosionCellsNeighbors;
            explosion.chanceToStartFire      = chanceToStartFire;
            explosion.dealMoreDamageAtCenter = dealMoreDamageAtCenter;
            explosion.StartExplosion(explosionSound);
        }