public static bool ButtonTextSubtle(Rect rect, string label, float barPercent = 0f, float textLeftMargin = -1f, SoundDef mouseoverSound = null) { var mouseOver = false; if (Mouse.IsOver(rect)) { mouseOver = true; GUI.color = GenUI.MouseoverColor; } if (mouseoverSound != null) { MouseoverSounds.DoRegion(rect, mouseoverSound); } Widgets.DrawAtlas(rect, ButtonSubtleAtlas); GUI.color = Color.white; if (barPercent > 0.001f) { var rect2 = rect.ContractedBy(1f); Widgets.FillableBar(rect2, barPercent, ButtonBarTex, null, false); } var innerRect = new Rect(rect); if (mouseOver) { innerRect.x += 2f; innerRect.y -= 2f; } Text.Anchor = TextAnchor.MiddleCenter; Text.Font = GameFont.Small; Text.WordWrap = false; Widgets.Label(innerRect, label); Text.Anchor = TextAnchor.UpperLeft; Text.WordWrap = true; return Widgets.ButtonInvisible(rect); }
public bool CanAddPlayingOneShot(SoundDef def, SoundInfo info) { bool result; if (!SoundDefHelper.CorrectContextNow(def, info.Maker.Map)) { result = false; } else if ((from s in this.samples where s.subDef.parentDef == def && s.AgeRealTime < 0.05f select s).Count <SampleOneShot>() >= def.MaxSimultaneousSamples) { result = false; } else { SampleOneShot sampleOneShot = this.LeastImportantOf(def); result = (sampleOneShot == null || this.ImportanceOf(def, info, 0f) >= this.ImportanceOf(sampleOneShot)); } return(result); }
// attack nearby enemies ==================================================================== // public static bool Attack(this JobDriver_Stumble driver, Zombie zombie) { var enemy = CanAttack(zombie); if (enemy == null) { return(false); } driver.destination = enemy.Position; zombie.state = ZombieState.Tracking; if (Constants.USE_SOUND && Prefs.VolumeAmbient > 0f) { var info = SoundInfo.InMap(enemy); SoundDef.Named("ZombieHit").PlayOneShot(info); } AttackThing(zombie, enemy, JobDefOf.AttackMelee); return(true); }
protected override void SetValue(Pawn pawn, bool value) { if (value) { Utils.AddDesignation(pawn, new Designation(pawn, DesignationDefOf.Hunt)); var tameDesignation = Utils.GetDesignation(pawn, DesignationDefOf.Tame); if (tameDesignation != null) { Utils.RemoveDesignation(pawn, tameDesignation); } if (pawn.RaceProps.manhunterOnDamageChance > Global.MIN_RETALIATION_CHANCE_ON_HUNT) { Verse.Sound.SoundStarter.PlayOneShotOnCamera(SoundDef.Named("MessageNegativeEvent")); } } else { var huntDesignation = Utils.GetDesignation(pawn, DesignationDefOf.Hunt); Utils.RemoveDesignation(pawn, huntDesignation); } }
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)); } }
//public override IEnumerable<Gizmo> GetGizmos() public override IEnumerable <Gizmo> CompGetGizmosExtra() { foreach (Gizmo c in base.CompGetGizmosExtra()) { yield return(c); } //if (Faction == Faction.OfColony) if (this.parent.Faction == Faction.OfPlayer) { { Command_Action light = new Command_Action(); light.defaultLabel = "Change Colour"; light.defaultDesc = "Change colour of light"; light.icon = ContentFinder <Texture2D> .Get("UI/Commands/Halt"); light.action = changeColour; light.activateSound = SoundDef.Named("Click"); yield return(light); } } }
public override IEnumerable <Gizmo> GetGizmos() { IList <Gizmo> source = (IList <Gizmo>) new List <Gizmo>(); if (!string.IsNullOrEmpty(this.StoredThingName) && this.StoredAmount > 0) { IList <Gizmo> gizmoList = source; Command_Action commandAction1 = new Command_Action(); commandAction1.icon = Crate.UnLockIco; commandAction1.defaultDesc = "Force Unpack. Warning: may damage some merchandise."; commandAction1.hotKey = KeyBindingDefOf.Misc4; commandAction1.activateSound = SoundDef.Named("Click"); commandAction1.action = new Action(this.ForceUnpack); commandAction1.groupKey = 887729001; Command_Action commandAction2 = commandAction1; gizmoList.Add((Gizmo)commandAction2); } IEnumerable <Gizmo> gizmos = base.GetGizmos(); return(gizmos == null?source.AsEnumerable <Gizmo>() : source.AsEnumerable <Gizmo>().Concat <Gizmo>(gizmos)); }
public static void PlayOneShotOnCamera(this SoundDef soundDef, Map onlyThisMap = null) { if (UnityData.IsInMainThread) { if (onlyThisMap != null) { if (Find.VisibleMap != onlyThisMap) { return; } if (WorldRendererUtility.WorldRenderedNow) { return; } } if (soundDef != null) { if (soundDef.subSounds.Count > 0) { bool flag = false; int num = 0; while (num < soundDef.subSounds.Count) { if (!soundDef.subSounds[num].onCamera) { num++; continue; } flag = true; break; } if (!flag) { Log.Error("Tried to play " + soundDef + " on camera but it has no on-camera subSounds."); } } soundDef.PlayOneShot(SoundInfo.OnCamera(MaintenanceType.None)); } } }
public override IEnumerable <Gizmo> CompGetGizmosWorn() { int num = 700000108; yield return(new Command_Action { action = Detonate, defaultLabel = "WearableExplosives_Detonate_Label".Translate(), defaultDesc = "WearableExplosives_Detonate_Desc".Translate(), icon = ContentFinder <Texture2D> .Get("Ui/Commands/CommandButton_BOOM", true), activateSound = SoundDef.Named("Click"), groupKey = num + 1 }); if (Armed) { yield return(new Command_Action { action = StopFuse, defaultLabel = "WearableExplosives_Timer_Stop_Label".Translate(), defaultDesc = "WearableExplosives_Timer_Desc".Translate(), icon = ContentFinder <Texture2D> .Get("Ui/Commands/CommandButton_BOOM", true), activateSound = SoundDef.Named("Click"), groupKey = num + 2 }); } else { yield return(new Command_Action { action = StartFuse, defaultLabel = "WearableExplosives_Timer_Start_Label".Translate(), defaultDesc = "WearableExplosives_Timer_Desc".Translate(), icon = ContentFinder <Texture2D> .Get("Ui/Commands/CommandButton_BOOM", true), activateSound = SoundDef.Named("Click"), groupKey = num + 2 }); } yield break; }
public Sustainer(SoundDef def, SoundInfo info) { this.def = def; this.info = info; if (def.subSounds.Count > 0) { foreach (KeyValuePair <string, float> keyValuePair in info.DefinedParameters) { this.externalParams[keyValuePair.Key] = keyValuePair.Value; } if (def.HasSubSoundsInWorld) { if (info.IsOnCamera) { Log.Error("Playing sound " + def.ToString() + " on camera, but it has sub-sounds in the world.", false); } this.worldRootObject = new GameObject("SustainerRootObject_" + def.defName); this.UpdateRootObjectPosition(); } else if (!info.IsOnCamera) { info = SoundInfo.OnCamera(info.Maintenance); } Find.SoundRoot.sustainerManager.RegisterSustainer(this); if (!info.IsOnCamera) { Find.SoundRoot.sustainerManager.UpdateAllSustainerScopes(); } for (int i = 0; i < def.subSounds.Count; i++) { this.subSustainers.Add(new SubSustainer(this, def.subSounds[i])); } } LongEventHandler.ExecuteWhenFinished(delegate { this.lastMaintainTick = Find.TickManager.TicksGame; this.lastMaintainFrame = Time.frameCount; }); }
private void UpdateCondition(int cond) { if ((condition ^ cond) == 0) { return; } int old_cond = condition; condition = cond; if (old_cond == 0) { if (cond == 0) { return; } parent.BroadcastCompSignal(CompPowerTrader.PowerTurnedOnSignal); SoundDef sound = SoundDefOf.PowerOnSmall; sound.PlayOneShot(new TargetInfo(this.parent.Position, this.parent.Map, false)); } else { if (cond != 0) { return; } parent.BroadcastCompSignal(CompPowerTrader.PowerTurnedOffSignal); if (parent.Spawned) { SoundDef sound = SoundDefOf.PowerOffSmall; sound.PlayOneShot(new TargetInfo(this.parent.Position, this.parent.Map, false)); } } }
public override IEnumerable <Command> GetCommands() { IList <Command> list = new List <Command>(); Command_Action command_Action = new Command_Action(); command_Action.icon = Table_Square.UI_change; if (!this.TClean) { command_Action.defaultDesc = "Next: Midworld "; } else { command_Action.defaultDesc = "Next: Spacer "; } command_Action.activateSound = SoundDef.Named("Click"); command_Action.action = new Action(this.SwitchTextureState); command_Action.groupKey = 887765321; list.Add(command_Action); IEnumerable <Command> commands = base.GetCommands(); return((commands == null) ? list.AsEnumerable <Command>() : list.AsEnumerable <Command>().Concat(commands)); }
public void DoFlick(bool active = true) { //Log.Warning("Trying DoFlick ", true); if (active) { SoundDef mySound = SwitchIsOn ? MyDefs.CampFireExtinguishSound : MyDefs.CampFireLightSound; mySound.PlayOneShot(new TargetInfo(parent.Position, parent.Map, false)); } Vector3 slightlyAbove = buildingPos + new Vector3(0, 0, .6f); // turning off if (SwitchIsOn) { FleckMaker.ThrowSmoke(slightlyAbove, myMap, compFuel.FuelPercentOfMax); if (GetGlowMote() is ThingWithComps glower) { glower.BroadcastCompSignal(SentSignal); } } // turning on else { HasEverBurnt = true; FleckMaker.ThrowMicroSparks(slightlyAbove, myMap); SpawnIfNoGlow(); } if (MyDebug) { Log.Warning("Sending " + SentSignal + " signal"); } //parent.BroadcastCompSignal(SentSignal); SwitchIsOn = !SwitchIsOn; UpdateComps(); }
public override void EjectContents() { foreach (Thing current in this.innerContainer) { Pawn pawn = current as Pawn; if (pawn != null) { if (this.IcookingTicking != IcookingTime) { PawnChanger.ExecuteBadThings(pawn); } } } if (!base.Destroyed) { SoundDef.Named("CryptosleepCasketEject").PlayOneShot(SoundInfo.InMap(new TargetInfo(base.Position, base.Map, false), MaintenanceType.None)); } this.IcookingTicking = 0; ChangeColour(this.red); base.EjectContents(); }
//咖喱技能4 public static Command_CastSkill Skill4() { var ck = new Command_CastSkill { defaultLabel = "MagSkill4.name".Translate(), icon = ContentFinder <Texture2D> .Get("Skills/MagSkill4"), targetingParams = WarframeStaticMethods.OnlyPawn(), cooldownTime = 4f, range = 12f, hotKey = KeyBindingDefOf.Misc7 }; // WarframeArmor sa = WarframeStaticMethods.getArmor(ck.self); ck.action = delegate(Pawn self) { SoundDef.Named("Mag_4Skill").PlayOneShot(self); { var mote = (Mote)ThingMaker.MakeThing(ThingDef.Named("Mote_2ExFlash")); mote.exactPosition = self.Position.ToVector3Shifted(); mote.Scale = Mathf.Max(10f, 15f); mote.rotationRate = 1.2f; GenSpawn.Spawn(mote, self.Position + new IntVec3(0, 1, 0), self.Map); } var thing = (Mag4SkillThing)ThingMaker.MakeThing(ThingDef.Named("MagSkill4Item")); thing.self = self; thing.range = (int)ck.range; thing.damage = 60 * (1 + (self.GetLevel() / 60f)); GenSpawn.Spawn(thing, self.Position, self.Map); self.stances.stunner.StunFor(180, self); WarframeStaticMethods.StartCooldown(self, ck.cooldownTime, 4, WarframeStaticMethods.GetArmor(self).TryGetComp <CompWarframeSkill>().skill4mana); }; return(ck); }
public override IEnumerable <Gizmo> GetGizmos() { List <Gizmo> list = new List <Gizmo>(base.GetGizmos()); if (list == null) { list = new List <Gizmo>(); } Command_Action a = new Command_Action(); a.icon = ContentFinder <Texture2D> .Get("UI/Icons/Rename", true); a.defaultDesc = "RimFridge.RenameTheRefrigerator".Translate(); a.defaultLabel = "Rename".Translate(); a.activateSound = SoundDef.Named("Click"); a.action = delegate { Find.WindowStack.Add(new Dialog_Rename(this)); }; a.groupKey = 887767542; list.Add(a); return(list); }
public static void Notify_SoundEvent(SoundDef def, SoundInfo info) { if (DebugViewSettings.writeSoundEventsRecord) { string str; if (def == null) { str = "null: "; } else if (def.isUndefined) { str = "Undefined: "; } else { str = ((!def.sustain) ? "OneShot: " : "SustainerSpawn: "); } string str2 = (def == null) ? "null" : def.defName; string str3 = str + str2 + " - " + info.ToString(); DebugSoundEventsLog.CreateRecord(str3); } }
//咖喱技能2 public static Command_CastSkill Skill2() { var ck = new Command_CastSkill { defaultLabel = "MesaSkill2.name".Translate(), icon = ContentFinder <Texture2D> .Get("Skills/MesaSkill2"), targetingParams = WarframeStaticMethods.OnlyPawn(), cooldownTime = 1f, range = 1f, hotKey = KeyBindingDefOf.Misc8 }; ck.action = delegate(Pawn self) { foreach (var hef in self.health.hediffSet.hediffs) { if (hef.def.defName != "WFMesa2Skill_Mesa") { continue; } Messages.Message("MesaSkillUsing".Translate(), MessageTypeDefOf.RejectInput, false); return; } SoundDef.Named("Mesa_2Skill").PlayOneShot(self); var hediff = (Hediff_Mesa2Skill)HediffMaker.MakeHediff(HediffDef.Named("WFMesa2Skill_Mesa"), self); hediff.level = (int)self.GetLevel(); self.health.AddHediff(hediff); WarframeStaticMethods.StartCooldown(self, ck.cooldownTime * (1 + (self.GetLevel() * 1f / 10f)), 2, WarframeStaticMethods.GetArmor(self).TryGetComp <CompWarframeSkill>().Props.mana2); }; return(ck); }
// Token: 0x06000008 RID: 8 RVA: 0x000022A8 File Offset: 0x000004A8 public override IEnumerable <Gizmo> CompGetGizmosWorn() { ThingWithComps owner = IsWorn ? GetWearer : parent; bool flag = Find.Selector.SelectedObjects.Contains(GetWearer); if (flag && GetWearer.IsColonist) { Texture2D CommandTex; int num = 700000101; if (Toggled) { CommandTex = ContentFinder <Texture2D> .Get("Ui/Commands/CommandButton_TurretModeOn", true); } else { CommandTex = ContentFinder <Texture2D> .Get("Ui/Commands/CommandButton_TurretModeOff", true); } yield return(new Command_Toggle { icon = CommandTex, defaultLabel = Toggled ? "Turret: on." : "Turret: off.", defaultDesc = "Switch mode.", isActive = (() => Toggled), toggleAction = delegate() { Toggled = !Toggled; this.SwitchTurretMode(); }, activateSound = SoundDef.Named("Click"), groupKey = num + 1, /* * disabled = GetWearer.stances.curStance.StanceBusy, * disabledReason = "Busy" */ }); } yield break; }
public override void CompTick() { if (firstTicks > 0) { firstTicks--; parent.Map.mapDrawer.MapMeshDirty(parent.Position, MapMeshFlag.Things, true, false); parent.Map.mapDrawer.MapMeshDirty(parent.Position, MapMeshFlag.PowerGrid, true, false); } if (this?.SteamNet?.HasActiveSteamSource ?? false) { if (Props.ticksOnTime.RandomInRange > 0 && ticksOn < 0 && ticksOff < 0) { ticksOn = Props.ticksOnTime.RandomInRange; ticksOff = Props.ticksOffTime; this.spraySustainer = SoundDefOf.GeyserSpray.TrySpawnSustainer(new TargetInfo(this.parent.PositionHeld, this.parent.MapHeld, false)); if (ticksOff > 100) { SoundDef.Named("Estate_SteamHiss").PlayOneShot(new TargetInfo(this.parent.Position, this.parent.Map, false)); } } if (ticksOn >= 0) { if (Rand.Value > 0.6f) { MoteMaker.ThrowAirPuffUp(this.parent.TrueCenter() + Props.steamOffset, this.parent.Map); } ticksOn--; } if (ticksOff >= 0) { ticksOff--; if (this.spraySustainer != null) { this.spraySustainer.End(); this.spraySustainer = null; } } } }
// ===================== Gizmos ===================== public override IEnumerable <Gizmo> GetGizmos() { IList <Gizmo> buttonList = new List <Gizmo>(); int groupKeyBase = 700000105; Command_Action setTargetButton = new Command_Action(); if (this.isPrimary) { setTargetButton.icon = ContentFinder <Texture2D> .Get("Ui/Commands/Commands_Primary"); setTargetButton.defaultLabel = "Primary"; setTargetButton.defaultDesc = "Spaceships will land there in priority if landing pad is clear. Otherwise, they will chose a random one."; } else { setTargetButton.icon = ContentFinder <Texture2D> .Get("Ui/Commands/Commands_Ancillary"); setTargetButton.defaultLabel = "Ancillary"; setTargetButton.defaultDesc = "Spaceships may only land there if primary landing pad is busy. Click to set it as primary."; } setTargetButton.activateSound = SoundDef.Named("Click"); setTargetButton.action = new Action(SetAsPrimary); setTargetButton.groupKey = groupKeyBase + 1; buttonList.Add(setTargetButton); IEnumerable <Gizmo> resultButtonList; IEnumerable <Gizmo> basebuttonList = base.GetGizmos(); if (basebuttonList != null) { resultButtonList = basebuttonList.Concat(buttonList); } else { resultButtonList = buttonList; } return(resultButtonList); }
// Token: 0x060000CA RID: 202 RVA: 0x00007AC0 File Offset: 0x00005CC0 protected override void Impact(Thing hitThing) { SoundDef soundExplode = this.def.projectile.soundExplode; bool flag = soundExplode != null; if (flag) { soundExplode.PlayOneShot(new TargetInfo(base.Position, base.Map, false)); } bool joinSameLordFromProjectile = this.SpawnerProps.joinSameLordFromProjectile; if (joinSameLordFromProjectile) { LordJob lordJob = this.SpawnerProps.CreateJobForLord(base.Position); this.lord = LordMaker.MakeNewLord(base.Faction, lordJob, Find.VisibleMap, null); } for (int i = 0; i < this.SpawnerProps.amount; i++) { this.DoSpawn(hitThing); } this.Destroy(DestroyMode.Vanish); }
///<summary> ///This creates the command buttons to control the alert speaker sound activation. ///</summary> ///<returns>The list of command buttons to display.</returns> public override IEnumerable <Gizmo> GetGizmos() { IList <Gizmo> buttonList = new List <Gizmo>(); int groupKeyBase = 700000100; Command_Action soundActivationButton = new Command_Action(); if (soundIsActivated) { soundActivationButton.icon = ContentFinder <Texture2D> .Get("Ui/Commands/CommandButton_SirenSoundEnabled"); soundActivationButton.defaultDesc = "Deactivate siren sound."; soundActivationButton.defaultLabel = "Siren sound activated."; } else { soundActivationButton.icon = ContentFinder <Texture2D> .Get("Ui/Commands/CommandButton_SirenSoundDisabled"); soundActivationButton.defaultDesc = "Activate siren sound."; soundActivationButton.defaultLabel = "Siren sound deactivated."; } soundActivationButton.activateSound = SoundDef.Named("Click"); soundActivationButton.action = new Action(PerformSirenSoundAction); soundActivationButton.groupKey = groupKeyBase + 1; buttonList.Add(soundActivationButton); IEnumerable <Gizmo> resultButtonList; IEnumerable <Gizmo> basebuttonList = base.GetGizmos(); if (basebuttonList != null) { resultButtonList = buttonList.AsEnumerable <Gizmo>().Concat(basebuttonList); } else { resultButtonList = buttonList.AsEnumerable <Gizmo>(); } return(resultButtonList); }
} //CompInspectStringExtra() public override IEnumerable <Gizmo> CompGetGizmosExtra() { //return base.CompGetGizmosExtra(); //Add the stock Gizmoes foreach (var g in base.CompGetGizmosExtra()) { yield return(g); } if (this.IsScanComplete() & this.HasSufficientShipResources()) { if (true) { Command_Action act = new Command_Action(); act.action = () => this.TriggerLaser(); act.icon = UI_LASER_ACTIVATE; act.defaultLabel = "Activate Laser"; act.defaultDesc = "Activate Laser"; act.activateSound = SoundDef.Named("Click"); //act.hotKey = KeyBindingDefOf.DesignatorDeconstruct; //act.groupKey = 689736; yield return(act); } if (true) { Command_Action act = new Command_Action(); act.action = () => this.TriggerLaserToFill(); act.icon = UI_LASER_ACTIVATEFILL; act.defaultLabel = "Activate Laser Fill"; act.defaultDesc = "Activate Laser Fill"; act.activateSound = SoundDef.Named("Click"); //act.hotKey = KeyBindingDefOf.DesignatorDeconstruct; //act.groupKey = 689736; yield return(act); } } } //CompGetGizmosExtra()
public static IEnumerable <VerbProperties> AllVerbDefs() { yield return(new VerbProperties { category = VerbCategory.BeatFire, label = "Beat fire", range = 1f, noiseRadius = 3f, targetParams = { canTargetFires = true, canTargetPawns = false, canTargetBuildings = false, mapObjectTargetsMustBeAutoAttackable = false }, warmupTime = 0f, defaultCooldownTime = 1.1f, soundCast = SoundDef.Named("Interact_BeatFire") }); /*Error: Unable to find new state assignment for yield return*/; }
public void ResolveReferencesSpecial() { if (soundDoorOpenPowered == null) { soundDoorOpenPowered = SoundDefOf.Door_OpenPowered; } if (soundDoorClosePowered == null) { soundDoorClosePowered = SoundDefOf.Door_ClosePowered; } if (soundDoorOpenManual == null) { soundDoorOpenManual = SoundDefOf.Door_OpenManual; } if (soundDoorCloseManual == null) { soundDoorCloseManual = SoundDefOf.Door_CloseManual; } if (turretGunDef != null) { LongEventHandler.ExecuteWhenFinished(delegate { turretTopMat = MaterialPool.MatFrom(turretGunDef.graphicData.texPath); }); } if (fixedStorageSettings != null) { fixedStorageSettings.filter.ResolveReferences(); } if (defaultStorageSettings == null && fixedStorageSettings != null) { defaultStorageSettings = new StorageSettings(); defaultStorageSettings.CopyFrom(fixedStorageSettings); } if (defaultStorageSettings != null) { defaultStorageSettings.filter.ResolveReferences(); } }
public override IEnumerable <Command> CompGetGizmosExtra() { foreach (Command compCom in base.CompGetGizmosExtra()) { yield return(compCom); } if (parent.Faction != Faction.OfPlayer) { yield break; } Command_Action com = new Command_Action(); if (IsMounted) { com.defaultLabel = txtCommandDismountLabel.Translate(); com.defaultDesc = txtCommandDismountDesc.Translate(); com.icon = ContentFinder <Texture2D> .Get("UI/Commands/IconUnmount"); com.activateSound = SoundDef.Named("Click"); com.action = Dismount; yield return(com); } else { Designator_Mount designator = new Designator_Mount(); designator.vehicle = parent; designator.defaultLabel = txtCommandMountLabel.Translate(); designator.defaultDesc = txtCommandMountDesc.Translate(); designator.icon = ContentFinder <Texture2D> .Get("UI/Commands/IconMount"); designator.activateSound = SoundDef.Named("Click"); yield return(designator); } }
public SoundHandle Play(SoundDef soundDef, Transform parent) { Profiler.BeginSample("SoundSystem.AllocEmitter"); var e = AllocEmitter(); Profiler.EndSample(); if (e == null) { return(new SoundHandle(null)); } e.source.transform.parent = parent; e.source.transform.localPosition = Vector3.zero; e.repeatCount = Random.Range(soundDef.repeatMin, soundDef.repeatMax); e.playing = true; e.soundDef = soundDef; Profiler.BeginSample("SoundSystem.StartEmitter"); StartEmitter(e); Profiler.EndSample(); return(new SoundHandle(e)); }
public override IEnumerable <Gizmo> GetGizmos() { //Add the stock Gizmoes foreach (var g in base.GetGizmos()) { yield return(g); } if (true) { Command_Action act = new Command_Action(); //act.action = () => Designator_Deconstruct.DesignateDeconstruct(this); act.action = () => this.ActivateDrill(); act.icon = UI_ACTIVATE_GATE; act.defaultLabel = "Activate Drill"; act.defaultDesc = "Activate Drill"; act.activateSound = SoundDef.Named("Click"); //act.hotKey = KeyBindingDefOf.DesignatorDeconstruct; //act.groupKey = 689736; yield return(act); } }
public void ResolveReferencesSpecial() { if (this.soundDoorOpenPowered == null) { this.soundDoorOpenPowered = SoundDefOf.Door_OpenPowered; } if (this.soundDoorClosePowered == null) { this.soundDoorClosePowered = SoundDefOf.Door_ClosePowered; } if (this.soundDoorOpenManual == null) { this.soundDoorOpenManual = SoundDefOf.Door_OpenManual; } if (this.soundDoorCloseManual == null) { this.soundDoorCloseManual = SoundDefOf.Door_CloseManual; } if (!this.turretTopGraphicPath.NullOrEmpty()) { LongEventHandler.ExecuteWhenFinished(delegate { this.turretTopMat = MaterialPool.MatFrom(this.turretTopGraphicPath); }); } if (this.fixedStorageSettings != null) { this.fixedStorageSettings.filter.ResolveReferences(); } if (this.defaultStorageSettings == null && this.fixedStorageSettings != null) { this.defaultStorageSettings = new StorageSettings(); this.defaultStorageSettings.CopyFrom(this.fixedStorageSettings); } if (this.defaultStorageSettings != null) { this.defaultStorageSettings.filter.ResolveReferences(); } }
/// <summary> /// This creates new selection buttons with a new graphic /// </summary> /// <returns></returns> public override IEnumerable <Gizmo> GetGizmos() { if (!productionActive && !gatheringSuppliesActive) { foreach (Gizmo cbase in base.GetGizmos()) { yield return(cbase); } } if (!power.PowerOn && !productionActive) { yield break; } // Key-Binding B - Start Production Command_Action opt1; opt1 = new Command_Action(); opt1.disabled = productionActive; opt1.disabledReason = "Production running..."; if (!productionActive && !gatheringSuppliesActive) { opt1.defaultDesc = txtStartProduction; opt1.icon = UI_StartProduction; } else { opt1.defaultDesc = txtStopProduction; opt1.icon = UI_StopProduction; } opt1.hotKey = KeyBindingDefOf.Misc1; opt1.activateSound = SoundDef.Named("Click"); opt1.action = Button_StartStopProduction; opt1.groupKey = 313676141; yield return(opt1); }
/// <summary> /// Spawns the setup. /// </summary> public override void SpawnSetup() { base.SpawnSetup(); if (TrapDef == null) { throw new Exception("Could not load TrapDef for instance."); } SpringSound = SoundDef.Named(TrapDef.TrapTriggerSoundName); // Get base type. _baseType = typeof (RimWorld.Building_TrapRearmable); if (_baseType == null) throw new Exception("Building_TrapRearmable: Could not get RimWorld.Building_TrapRearmable type info."); // Get private armedInt bool from base class. _armedIntField = _baseType.GetField("armedInt", BindingFlags.NonPublic | BindingFlags.Instance); if (_armedIntField == null) throw new Exception("Building_TrapRearmable: Could not get armedInt field info."); // Get private autoRearm bool from base class. _autoRearmField = _baseType.GetField("autoRearm", BindingFlags.NonPublic | BindingFlags.Instance); if (_autoRearmField == null) throw new Exception("Building_TrapRearmable: Could not get autoRearm field info."); }
public void GetParametersFromXml() { Enhanced_Development.PersonalShields.ThingDef_PersonalNanoShield param = this.def as Enhanced_Development.PersonalShields.ThingDef_PersonalNanoShield; MinDrawSize = param.minDrawSize; MaxDrawSize = param.maxDrawSize; maxEnergy = param.maxEnergy; isRotating = param.isRotating; if (param.bubbleGraphicPath != null) { BubbleMat = MaterialPool.MatFrom(param.bubbleGraphicPath, ShaderDatabase.Transparent); } if (param.soundAbsorb != null) { SoundAbsorbDamage = SoundDef.Named(param.soundAbsorb); } if (param.soundBreak != null) { SoundBreak = SoundDef.Named(param.soundBreak); } if (param.soundReset != null) { SoundReset = SoundDef.Named(param.soundReset); } }
/// <summary> /// Get parameters from XML. /// </summary> public void GetParametersFromXml() { Projectile_Laser.ThingDef_LaserProjectile additionalParameters = def as Projectile_Laser.ThingDef_LaserProjectile; // Miscellaneous. if (additionalParameters.warmupProjectileDefName != null) { warmupProjectileDefName = additionalParameters.warmupProjectileDefName; } isWarmupProjectile = additionalParameters.isWarmupProjectile; preFiringDuration = additionalParameters.preFiringDuration; postFiringDuration = additionalParameters.postFiringDuration; // Draw. preFiringInitialIntensity = additionalParameters.preFiringInitialIntensity; preFiringFinalIntensity = additionalParameters.preFiringFinalIntensity; postFiringInitialIntensity = additionalParameters.postFiringInitialIntensity; postFiringFinalIntensity = additionalParameters.postFiringFinalIntensity; if (additionalParameters.warmupGraphicPathSingle != null) { warmupTexture = MaterialPool.MatFrom(additionalParameters.warmupGraphicPathSingle, ShaderDatabase.Transparent); } // Sound. if (additionalParameters.warmupSound != null) { warmupSound = SoundDef.Named(additionalParameters.warmupSound); } }
public override GizmoResult GizmoOnGUI(UnityEngine.Vector2 topLeft) { Rect overRect = new Rect(topLeft.x, topLeft.y, curWidth, Height); Widgets.DrawWindowBackground(overRect); //Equipment slot Pawn wearer = backpack.wearer; ThingWithComps dummy; Rect thingIconRect = new Rect(topLeft.x, topLeft.y, widthPerItem, Height / 2); int numOfCurItem = 0; List<Thing> things = wearer.inventory.container.ToList(); //Draw Gizmo for (int i = 0;i < numOfMaxItemsPerRow * numOfRow; i++) { if ( i >= backpack.MaxItem ) { thingIconRect.x = topLeft.x + widthPerItem * (i % numOfMaxItemsPerRow); thingIconRect.y = topLeft.y + (Height / 2) * (i / numOfMaxItemsPerRow); Widgets.DrawTextureFitted(thingIconRect, NoAvailableTex, 1.0f); continue; } if (i >= things.Count) { thingIconRect.x = topLeft.x + widthPerItem * (i % numOfMaxItemsPerRow); thingIconRect.y = topLeft.y + (Height / 2) * (i / numOfMaxItemsPerRow); Widgets.DrawTextureFitted(thingIconRect, EmptyTex, 1.0f); continue; } Thing item = things[i]; Widgets.DrawBox(thingIconRect, 1); Widgets.ThingIcon(thingIconRect, item); if (thingIconRect.Contains(Event.current.mousePosition)) { Widgets.DrawTextureFitted(thingIconRect, FilledTex, 1.0f); } //Interaction with item if (Widgets.InvisibleButton(thingIconRect)) { thingIconSound = SoundDefOf.Click; if (Event.current.button == 0) { //Weapon if (item.def.equipmentType == EquipmentType.Primary) { if (wearer.equipment.Primary != null) wearer.equipment.TryTransferEquipmentToContainer(wearer.equipment.Primary, wearer.inventory.container, out dummy); else backpack.numOfSavedItems--; wearer.equipment.AddEquipment(item as ThingWithComps); wearer.inventory.container.Remove(item as ThingWithComps); if (wearer.jobs.curJob != null) wearer.jobs.EndCurrentJob(JobCondition.InterruptForced); } //Medicine else if (item.def.thingCategories.Contains(medicine)) { if (wearer.workSettings.WorkIsActive(WorkTypeDefOf.Doctor)) { Designator_ApplyMedicine designator = new Designator_ApplyMedicine(); designator.medicine = item; designator.doctor = wearer; designator.icon = item.def.uiIcon; designator.activateSound = SoundDef.Named("Click"); DesignatorManager.Select(designator); } else { Messages.Message(txtNoDoctor.Translate(), MessageSound.RejectInput); Messages.Update(); thingIconSound = SoundDefOf.ClickReject; } } //Food else if (item.def.thingCategories.Contains(foodMeals)) { if (wearer.needs.food.CurCategory != HungerCategory.Fed) { Job jobNew = new Job(JobDefOf.Ingest, item); jobNew.maxNumToCarry = 1; jobNew.ignoreForbidden = true; wearer.drafter.TakeOrderedJob(jobNew); } else { Messages.Message(txtCannotEatAnymore.Translate(), MessageSound.RejectInput); Messages.Update(); thingIconSound = SoundDefOf.ClickReject; } } //Apparel else if (item is Apparel) { //if (!wearer.apparel.CanWearWithoutDroppingAnything(item.def)) // wearer.apparel.WornApparel.Find(apparel => apparel.def.apparel.layers.Any); for (int index = wearer.apparel.WornApparel.Count - 1; index >= 0; --index) { Apparel ap = wearer.apparel.WornApparel[index]; if (!ApparelUtility.CanWearTogether(item.def, ap.def)) { Apparel resultingAp; wearer.apparel.TryDrop(ap, out resultingAp, wearer.Position, false); wearer.inventory.container.TryAdd(resultingAp); backpack.numOfSavedItems++; } } wearer.apparel.Wear(item as Apparel); wearer.inventory.container.Remove(item as ThingWithComps); backpack.numOfSavedItems--; } else { //Add another type of item you want to interact } } else if (Event.current.button == 1) { List<FloatMenuOption> options = new List<FloatMenuOption>(); options.Add(new FloatMenuOption(txtThingInfo, () => { Find.WindowStack.Add((Window)new Dialog_InfoCard(item)); })); options.Add(new FloatMenuOption(txtDropThing, () => { Thing dummy1; wearer.inventory.container.TryDrop(item, wearer.Position, ThingPlaceMode.Near, out dummy1); })); Find.WindowStack.Add((Window)new FloatMenu(options, item.LabelCap, false, false)); } SoundStarter.PlayOneShotOnCamera(thingIconSound); } numOfCurItem++; thingIconRect.x = topLeft.x + widthPerItem * (numOfCurItem % numOfMaxItemsPerRow); thingIconRect.y = topLeft.y + (Height / 2) * (numOfCurItem / numOfMaxItemsPerRow); } if (numOfCurItem == 0 ) { Rect textRect = new Rect(topLeft.x + Width / 2 - textWidth / 2, topLeft.y + Height / 2 - textHeight / 2, textWidth, textHeight); Widgets.Label(textRect, txtNoItem.Translate()); } return new GizmoResult(GizmoState.Clear); }