public void SaveImmediately(ProfileComponents components) { Debug.Log("PROFILE: Saving profile " + components.ToString() + " immediately"); if (Flags.Check((uint)components, (uint)ProfileComponents.Preferences, Flags.CheckType.MatchAny)) { GameData.IO.SavePreferences(Current.Name, CurrentPreferences); } if (Flags.Check((uint)components, (uint)ProfileComponents.Game, Flags.CheckType.MatchAny)) { //save the whole world CurrentGame.LastTimeSaved = DateTime.Now; CurrentGame.GameTimeOffset = WorldClock.AdjustedRealTimeWithoutOffset; GameData.IO.SaveGame(CurrentGame); } else if (Flags.Check((uint)components, (uint)ProfileComponents.Character, Flags.CheckType.MatchAny)) { //just save the character //don't bother with the rest of the world CurrentGame.LastTimeSaved = DateTime.Now; CurrentGame.GameTimeOffset = WorldClock.AdjustedRealTimeWithoutOffset; GameData.IO.SaveGame(CurrentGame); } if (Flags.Check((uint)components, (uint)ProfileComponents.Profile, Flags.CheckType.MatchAny)) { GameData.IO.SaveProfile(Current); } }
public static bool Is(FGameState state) { if (Cutscene.IsActive) { return(Flags.Check((uint)FGameState.Cutscene, (uint)state, Flags.CheckType.MatchAny)); } return(Flags.Check((uint)State, (uint)state, Flags.CheckType.MatchAny)); }
public bool SubscriptionCheck(TimeActionType subscription, TimeActionType action) { if (subscription != TimeActionType.NoAction && action != TimeActionType.NoAction) { return(Flags.Check((uint)subscription, (uint)action, Flags.CheckType.MatchAny)); } return(false); }
public override void OnGameLoadStart() { MissionStates.Clear(); Mods.Get.Runtime.LoadAvailableMods(MissionStates, "Mission"); for (int i = 0; i < MissionStates.Count; i++) { if (Flags.Check((uint)MissionStates [i].Status, (uint)MissionStatus.Active, Flags.CheckType.MatchAny)) { //if a mission is active create a gameobject for it CreateMissionFromState(MissionStates [i]); } } }
public List <MissionState> MissionStatesByStatus(MissionStatus status) { List <MissionState> missionStates = new List <MissionState> (); for (int i = 0; i < MissionStates.Count; i++) { if (Flags.Check((uint)MissionStates [i].Status, (uint)status, Flags.CheckType.MatchAny)) { missionStates.Add(MissionStates [i]); } } return(missionStates); }
public void Update() { if (mSaveNextAvailable != ProfileComponents.None) { if (Flags.Check((uint)mSaveNextAvailable, (uint)ProfileComponents.Preferences, Flags.CheckType.MatchAny)) { CurrentPreferences.Version = GameManager.VersionString; GameData.IO.SavePreferences(Current.Name, CurrentPreferences); mSaveNextAvailable &= ~ProfileComponents.Preferences; } if (!GameManager.Is(FGameState.InGame | FGameState.GamePaused | FGameState.Saving)) { //Debug.Log ("Can't save profile components yet, we're not InGame, GamePaused or Saving"); return; } if (Flags.Check((uint)mSaveNextAvailable, (uint)ProfileComponents.Game, Flags.CheckType.MatchAny)) { //save the whole world //TODO get all game data CurrentGame.LastTimeSaved = DateTime.Now; CurrentGame.GameTime = WorldClock.AdjustedRealTime; CurrentGame.Version = GameManager.VersionString; GameData.IO.SaveGame(CurrentGame); } else if (Flags.Check((uint)mSaveNextAvailable, (uint)ProfileComponents.Character, Flags.CheckType.MatchAny)) { //just save the character //don't bother with the rest of the world CurrentGame.LastTimeSaved = DateTime.Now; CurrentGame.GameTime = WorldClock.AdjustedRealTime; CurrentGame.Version = GameManager.VersionString; GameData.IO.SaveGame(CurrentGame); } if (Flags.Check((uint)mSaveNextAvailable, (uint)ProfileComponents.Profile, Flags.CheckType.MatchAny)) { Current.Version = GameManager.VersionString; GameData.IO.SaveProfile(Current); } mSaveNextAvailable = ProfileComponents.None; Debug.Log("Saved components in profile"); //GameData.IO.LogPaths(); enabled = false; } }
public static TimeOfYear TimeOfYearToSeason(TimeOfYear timeOfYear) { //this assumes non-overlapping time of year if (Flags.Check((uint)timeOfYear, (uint)TimeOfYear.SeasonSpring, Flags.CheckType.MatchAny)) { return(TimeOfYear.SeasonSpring); } else if (Flags.Check((uint)timeOfYear, (uint)TimeOfYear.SeasonSummer, Flags.CheckType.MatchAny)) { return(TimeOfYear.SeasonSummer); } else if (Flags.Check((uint)timeOfYear, (uint)TimeOfYear.SeasonAutumn, Flags.CheckType.MatchAny)) { return(TimeOfYear.SeasonAutumn); } else { return(TimeOfYear.SeasonWinter); } }
public void DrawGenericWorldItemSelector(GenericWorldItem item, ref bool open, bool useStrictness) { if (WorldItems.Get == null) { Manager.WakeUp <WorldItems>("Frontiers_WorldItems"); WorldItems.Get.Initialize(); } bool drawEditor = true; UnityEditor.EditorStyles.miniButton.stretchWidth = true; UnityEditor.EditorStyles.textField.stretchWidth = true; UnityEditor.EditorStyles.popup.stretchWidth = true; GUILayout.BeginVertical(); if (string.IsNullOrEmpty(item.PackName)) { drawEditor = false; UnityEngine.GUI.color = Color.green; if (GUILayout.Button("(Add)", UnityEditor.EditorStyles.miniButton)) { item.PackName = "AncientArtifacts"; item.PrefabName = string.Empty; drawEditor = true; } UnityEngine.GUI.color = Color.yellow; if (GUILayout.Button("(Done)", UnityEditor.EditorStyles.miniButton)) { drawEditor = false; selectedItemIndex = -1; selectedRowIndex = -1; } } else { UnityEngine.GUI.color = Color.red; if (GUILayout.Button("(Clear)", UnityEditor.EditorStyles.miniButton)) { item.Clear(); drawEditor = false; } } if (drawEditor) { UnityEngine.GUI.color = Color.yellow; int packIndex = 0; List <string> packNames = new List <string>(); WorldItemPack pack = null; WorldItem worlditem = null; for (int i = 0; i < WorldItems.Get.WorldItemPacks.Count; i++) { string packName = WorldItems.Get.WorldItemPacks[i].Name; packNames.Add(packName); if (item.PackName == packName) { packIndex = i; pack = WorldItems.Get.WorldItemPacks[i]; } } if (pack == null) { pack = WorldItems.Get.WorldItemPacks[0]; } packIndex = UnityEditor.EditorGUILayout.Popup("Pack:", packIndex, packNames.ToArray(), UnityEditor.EditorStyles.popup); List <string> prefabNames = new List <string>(); int prefabIndex = 0; for (int i = 0; i < pack.Prefabs.Count; i++) { prefabNames.Add(pack.Prefabs[i].name); if (item.PrefabName == pack.Prefabs[i].name) { prefabIndex = i; worlditem = pack.Prefabs[i].GetComponent <WorldItem>(); } } prefabIndex = UnityEditor.EditorGUILayout.Popup("Prefab:", prefabIndex, prefabNames.ToArray(), UnityEditor.EditorStyles.popup); item.PackName = packNames[packIndex]; item.PrefabName = prefabNames[prefabIndex]; if (worlditem != null) { UnityEngine.GUI.color = Color.yellow; item.DisplayName = worlditem.DisplayName; if (!useStrictness || Flags.Check((uint)Blueprint.Strictness, (uint)BlueprintStrictness.StackName, Flags.CheckType.MatchAny)) { GUILayout.BeginHorizontal(); GUILayout.Label("StackName: "); if (string.IsNullOrEmpty(item.StackName) || !worlditem.StackName.Contains(item.StackName)) { item.StackName = worlditem.StackName; } item.StackName = GUILayout.TextField(item.StackName); GUILayout.EndHorizontal(); } if (!useStrictness || Flags.Check((uint)Blueprint.Strictness, (uint)BlueprintStrictness.StateName, Flags.CheckType.MatchAny)) { GUILayout.BeginHorizontal(); int stateIndex = 0; List <string> stateNames = new List <string>(); stateNames.Add("Default"); WIStates states = worlditem.GetComponent <WIStates>(); if (states != null) { for (int i = 0; i < states.States.Count; i++) { stateNames.Add(states.States[i].Name); if (item.State == states.States[i].Name) { stateIndex = i + 1; //since the first one is Default } } } stateIndex = UnityEditor.EditorGUILayout.Popup("State:", stateIndex, stateNames.ToArray(), UnityEditor.EditorStyles.popup); GUILayout.EndHorizontal(); item.State = stateNames[stateIndex]; } } UnityEngine.GUI.color = Color.white; if (!useStrictness || Flags.Check((uint)Blueprint.Strictness, (uint)BlueprintStrictness.Subcategory, Flags.CheckType.MatchAny)) { GUILayout.BeginHorizontal(); GUILayout.Label("Subcategory: "); item.Subcategory = GUILayout.TextField(item.Subcategory); GUILayout.EndHorizontal(); } UnityEngine.GUI.color = Color.yellow; if (GUILayout.Button("(Done)", UnityEditor.EditorStyles.miniButton)) { open = false; } } GUILayout.EndVertical(); UnityEditor.EditorStyles.miniButton.stretchWidth = true; UnityEditor.EditorStyles.textField.stretchWidth = true; UnityEditor.EditorStyles.popup.stretchWidth = true; }
protected bool SubscriptionCheck(InterfaceActionType subscription, InterfaceActionType action) { return(Flags.Check((uint)subscription, (uint)action, Flags.CheckType.MatchAny)); }
public void SendDamage(DamagePackage damage, BodyPart bodyPart) { damageReceiver = damage.Target; damageHandler = null; damageWorldItem = null; damage.OnPackageSent.SafeInvoke(); if (damageReceiver != null) { //check if it's a player because it's the eaiest switch (damageReceiver.IOIType) { case ItemOfInterestType.Player: damageHandler = Player.Local.DamageHandler; break; case ItemOfInterestType.WorldItem: Damageable damageable = null; damageWorldItem = damageReceiver.worlditem; if (damageReceiver.worlditem.Is <Damageable> (out damageable)) { damageHandler = damageable; } else { //if it's an instant kill, destroy it now if (damage.InstantKill) { Debug.Log("Instant kill in damage manager"); damage.HitTarget = true; damage.TargetIsDead = true; damage.DamageDealt = damage.DamageSent; damageReceiver.worlditem.RemoveFromGame(); return; } } break; case ItemOfInterestType.Scenery: DamageableChild dc = null; if (damageReceiver.gameObject.HasComponent <DamageableChild> (out dc)) //get the parent from the damageable child { damageHandler = dc.DamageableParent; } else { //if it's not a world item and it's not a body part check for a general damage handler //this includes the player's damage handler damageHandler = (IDamageable)damageReceiver.gameObject.GetComponent(typeof(IDamageable)); } break; default: break; } } //apply damage using the damage handler if (damageHandler != null) { receiverMaterial = damageHandler.BaseMaterialType; receiverArmorMaterials = damageHandler.ArmorMaterialTypes; int receiverArmorLevel = 0; if (receiverArmorMaterials != WIMaterialType.None) { receiverArmorLevel = damageHandler.ArmorLevel(receiverArmorMaterials); } //get damage multiplier for material types //TODO re-enable these //damage.DamageSent = damage.DamageSent * BaseWeaponDamageMultiplier (damage.SenderMaterial, receiverMaterial); //damage.DamageSent = damage.DamageSent * BaseArmorReductionMultiplier (damage.SenderMaterial, receiverArmorMaterials); //check if there's a material bonus for this damage sender if (damage.MaterialBonus != WIMaterialType.None) { if (Flags.Check((uint)receiverMaterial, (uint)damage.MaterialBonus, Flags.CheckType.MatchAny)) { damage.DamageSent *= Globals.DamageMaterialBonusMultiplier; } } if (damage.MaterialPenalty != WIMaterialType.None) { if (Flags.Check((uint)receiverMaterial, (uint)damage.MaterialPenalty, Flags.CheckType.MatchAny)) { damage.DamageSent *= Globals.DamageMaterialPenaltyMultiplier; } } damageHandler.LastDamageSource = damage.Source; //this has a good chance of being null damageHandler.LastBodyPartHit = bodyPart; if (damage.InstantKill) { damageHandler.InstantKill(damage.Source); } else { damage.HitTarget = damageHandler.TakeDamage(damage.SenderMaterial, damage.Point, damage.DamageSent, damage.Force, damage.SenderName, out damage.DamageDealt, out damage.TargetIsDead); } if (damage.HitTarget) { SpawnDamageFX(damage.Point, receiverMaterial, damage.DamageDealt); PlayDamageSound(damage.Point, receiverMaterial, damage.DamageDealt); if (bodyPart != null && !damage.TargetIsDead) { switch (bodyPart.Type) { case BodyPartType.Eye: GUI.GUIManager.PostSuccess("Inflicted eye wound"); damage.DamageSent = Globals.DamageBodyPartEyeMultiplier; break; case BodyPartType.Head: case BodyPartType.Face: case BodyPartType.Neck: GUI.GUIManager.PostSuccess("Inflicted head wound"); damage.DamageSent *= Globals.DamageBodyPartHeadMultiplier; break; case BodyPartType.Chest: case BodyPartType.Hip: case BodyPartType.Segment: case BodyPartType.Shoulder: case BodyPartType.None: default: GUI.GUIManager.PostSuccess("Inflicted torso wound"); damage.DamageSent *= Globals.DamageBodyPartTorsoMultiplier; break; case BodyPartType.Finger: case BodyPartType.Hand: case BodyPartType.Wrist: case BodyPartType.Arm: case BodyPartType.Foot: case BodyPartType.Shin: case BodyPartType.Leg: GUI.GUIManager.PostSuccess("Inflicted limb wound"); damage.DamageSent *= Globals.DamageBodyPartLimbMultiplier; break; } } } damage.OnPackageReceived.SafeInvoke(); } else { //if we didn't find a damage handler but we did find a worlditem //send force to the worlditem so it doesn't just sit there if (damageWorldItem != null) { damageWorldItem.ApplyForce(damage.Force, damage.Point); } } //play the sender's fx no matter what SpawnDamageFX(damage.Point, damage.SenderMaterial, damage.DamageDealt); PlayDamageSound(damage.Point, damage.SenderMaterial, damage.DamageDealt); }
public static bool IsTimeOfYear(TimeOfYear timeOfYear) { return(Flags.Check((uint)SeasonCurrent, (uint)timeOfYear, Flags.CheckType.MatchAny)); }
public static bool IsTimeOfDay(TimeOfDay timeOfDay) { return(Flags.Check((uint)timeOfDay, (uint)gTimeOfDayCurrent, Flags.CheckType.MatchAll)); }