private void AutoRecoveryCheck(Situation situation) { if (WarGlobal.Random.NextUnfairBool(1.0 / 3)) { _unit.Conditions.Remove(((IAbnormalCondition)this).ID, situation); } }
public int SelectMove(Situation situation, Move[] moves, Piece side, int roll) { Move[] c = new Move[moves.Length]; Array.Copy(moves, c, moves.Length); Array.Sort<Move>(c, CompareMoves); return Array.IndexOf<Move>(moves, c[0]); }
public void RemovedConditonTable(Situation situation, WarUnit unit) { // 追加したデリゲートは全て削除する unit.ReviseStatus -= ReviseStatus; unit.DamageEvent -= WakeUpCheck; Phases.TurnPhase.Start -= AutoRecoveryCheck; }
private static int GetKey(Situation s) { byte[] arr = new byte[] { (byte)s.pieces[0], (byte)s.pieces[1], (byte)s.pieces[2], (byte)s.pieces[3] }; Array.Sort<byte>(arr); return (arr[0] << 24) + (arr[1] << 16) + (arr[2] << 8) + arr[3]; }
public WarPresentationModel(Situation situation) { CancelCommandStack = new Stack<Func<bool>>(); Situation = situation; _chipAnimations = new AnimationManager<AnimationSprite>(); _screenAnimations = new AnimationManager<AnimationSurface>(); }
public PrintableScope(IScope scope, IList<Point2> rangePoints, IList<Point2> validRangePoints, Situation situation, WarUnit doer) { this.scope = scope; this.situation = situation; this.doer = doer; this.RangeChips = rangePoints; this.ValidRangeChips = validRangePoints; }
private void WakeUpCheck(Situation situation, WarUnit unit, WarUnit doer, int value) { // 攻撃者がいた場合のみ、復帰処理を行う if (doer != null && WarGlobal.Random.NextUnfairBool(1.0 / 3)) { unit.Conditions.Remove(((IAbnormalCondition)this).ID, situation); } }
public void AddedConditonTable(Situation situation, WarUnit unit) { _unit = unit; // 麻痺時のコマンドテーブル変化を適用する unit.ReviseCommands += CommandEnableTableRevise; // ターン開始時に状態異常が自動回復するかの判定処理を追加する Phases.TurnPhase.Start += AutoRecoveryCheck; }
public PrintableScope(IScope scope, Situation situation, WarUnit doer) { this.scope = scope; this.situation = situation; this.doer = doer; IEnumerable<Point2> rangeScope; this.ValidRangeChips = scope.GetValidRangeScope(situation, doer, out rangeScope).ToArray(); this.RangeChips = rangeScope.ToArray(); }
public IPhase ChangePhase(Situation situation, IPhase phase) { var oldPhase = _phaseStack.Pop(); oldPhase.Exit(situation); _phaseStack.Push(phase); phase.Start(situation); return oldPhase; }
public override IEnumerable<Point2> GetAreaScope(Situation situation, WarUnit doer, Point2 center) { var v = ScopeUtil.GetDirectionalVector(center - doer.Location); var p = doer.Location; for (int i = 0; i < _range; i++) { p += v; yield return p; } }
public void DoubleSelfTackleAddsTwoBeers() { var pos = getStartPositions(); pos[0] = Position.Green5; pos[1] = Position.Green5; pos[4] = Position.RedStart; var sit = new Situation(pos); var moves = sit.GetMoves(Piece.Green, 2); sit.ApplyMove(moves[0]); Assert.AreEqual(2, sit.beers[(int)Piece.Green]); }
public bool AddingConditonTable(Situation situation, WarUnit unit, IAbnormalCondition oldCond) { Contract.Requires(oldCond.GetType() == GetType()); var cond = (AttackCountChangeCondition)oldCond; var newCount = cond._changeAttackCount + _changeAttackCount; // 変化量が0ならば削除、そうでなければ値を更新 if (newCount == 0) unit.Conditions.Remove(ID, situation); else cond._changeAttackCount = _changeAttackCount; return false; }
public Game(IGameDisplay display, IPlayer[] players) { rand = new Random(); if (players == null || players.Length != 4) { throw new Exception("Need 4 players to play"); } this.display = display; this.players = players; this.history = new List<HistoryEntry>(); situation = Situation.GameStart(); }
public void AddedConditonTable(Situation situation, WarUnit unit) { _unit = unit; // 睡眠中は行動不可能 unit.ReviseStatus += ReviseStatus; // 攻撃を受けたときの復帰処理を追加する unit.DamageEvent += WakeUpCheck; // ターン開始時に状態異常が自動回復するかの判定処理を追加する Phases.TurnPhase.Start += AutoRecoveryCheck; }
public void GetOutOfHomeIfPossible() { var pos = getStartPositions(); pos[0] = Position.Blue2; var sit = new Situation(pos); var moves = sit.GetMoves(Piece.Green, 6); int selected = p.SelectMove(sit, moves, Piece.Green, 6); var selectedMove = moves[selected]; Assert.AreEqual(Position.GreenStart, selectedMove.EndPosition); }
public void MoveToGoalIfPossible() { var pos = getStartPositions(); pos[0] = Position.Yellow6; pos[1] = Position.Green1; var sit = new Situation(pos); var moves = sit.GetMoves(Piece.Green, 2); int selected = p.SelectMove(sit, moves, Piece.Green, 2); var selectedMove = moves[selected]; Assert.AreEqual(Position.Yellow6, selectedMove.StartPosition); }
public TaxEstimate Estimate(Situation situation) { var estimate = new TaxEstimate(situation); var bracket = _bracketSelector.SelectBracket(situation); estimate.TaxOnIncome = bracket.CalculateTaxPayable(situation); foreach (var modifier in _modifiers) { modifier.Apply(estimate); } return estimate; }
private int GetKey(Situation s, Piece side) { int start = ((int)side - 1) * 4; byte[] arr = new byte[4]; for (int i = 0; i < 4; i++) { arr[i] = (byte)GetGreenEquivalent(s.pieces[start + i], side); } Array.Sort<byte>(arr); return (arr[0] << 24) + (arr[1] << 16) + (arr[2] << 8) + arr[3]; }
public void EatIfYouCan() { var pos = getStartPositions(); pos[0] = Position.Blue1; pos[1] = Position.Green1; pos[4] = Position.Green3; var sit = new Situation(pos); var moves = sit.GetMoves(Piece.Green, 2); int selected = p.SelectMove(sit, moves, Piece.Green, 2); var selectedMove = moves[selected]; Assert.AreEqual(Position.Green1, selectedMove.StartPosition); }
public virtual IEnumerable<Point2> GetValidAreaScope(Situation situation, WarUnit doer, Point2 center, out IEnumerable<Point2> areaScope) { var validAreaPoints = new List<Point2>(); areaScope = GetAreaScope(situation, doer, center); foreach (var p in areaScope) { if (IsValidPoint(situation, doer, p)) { validAreaPoints.Add(p); } } return validAreaPoints; }
public override IList<Point2> GetValidRangeScope(Situation situation, WarUnit doer, out IEnumerable<Point2> rangeScope) { var validRangePoints = new List<Point2>(); rangeScope = new[] { doer.Location }; foreach (var p in situation.Map.ValidPoints) { if (IsValidPoint(situation, doer, p)) { validRangePoints.Add(doer.Location); break; } } return validRangePoints; }
public void CannotWinWhileTheresBeerLeft() { var pos = getStartPositions(); pos[0] = Position.GreenGoal1; pos[1] = Position.GreenGoal2; pos[2] = Position.GreenGoal3; pos[3] = Position.GreenGoal4; var sit = new Situation(pos); sit.beers[(int)Piece.Green] = 1; Assert.AreEqual(Piece.None, sit.GetWinner()); sit.DrinkBeers(Piece.Green, 1); Assert.AreEqual(Piece.Green, sit.GetWinner()); }
public void DoubleUnfoldsToStartPosition() { var pos = getStartPositions(); pos[4] = pos[5] = Position.RedGoal1; var sit = new Situation(pos); var moves = sit.GetMoves(Piece.Red, 3); Assert.AreEqual(1, moves.Length); sit.ApplyMove(moves[0]); Assert.AreEqual(Piece.Red, sit.board[(int)Position.RedGoal1]); Assert.AreEqual(Piece.None, sit.board[(int)Position.RedGoal2]); Assert.AreEqual(Piece.None, sit.board[(int)Position.RedGoal3]); Assert.AreEqual(Piece.Red, sit.board[(int)Position.RedGoal4]); }
/// <summary> /// ユニットに状態異常が追加される直前に呼び出される。 /// </summary> /// <param name="situation"></param> /// <param name="unit"></param> /// <param name="oldCond"></param> public bool AddingConditonTable(Situation situation, WarUnit unit, IAbnormalCondition oldCond) { Contract.Requires(oldCond.GetType() == GetType()); var cond = (StatusChangeCondition)oldCond; // 効果がお互いに反対であった場合は状態異常を消す if (_changeStatusValue * cond._changeStatusValue < 0) { unit.Conditions.Remove(ID, situation); } // そうでない場合は、効果が大きいほうで上書きする else if (Math.Abs(_changeStatusValue) > Math.Abs(cond._changeStatusValue)) { cond._changeStatusValue = _changeStatusValue; } return false; }
public virtual IList<Point2> GetValidRangeScope(Situation situation, WarUnit doer, out IEnumerable<Point2> rangeScope) { var validRangePoints = new List<Point2>(); rangeScope = GetRangeScope(situation, doer); // 対象が存在するかどうかチェック foreach (var rangePoint in rangeScope) { foreach (var p in GetAreaScope(situation, doer, rangePoint)) { if (IsValidPoint(situation, doer, p)) { validRangePoints.Add(rangePoint); break; } } } return validRangePoints; }
public int SelectMove(Situation situation, Move[] moves, Piece side, int roll) { Console.WriteLine("Side: " + side); Console.WriteLine("Roll: " + roll); Console.WriteLine("Situation: "); Console.WriteLine(situation.ToString()); int selectedMove = -1; do { Console.WriteLine("Moves"); for (int i = 0; i < moves.Length; i++) { Console.WriteLine(i + ": " + moves[i].ToString()); } Console.WriteLine("Select move: "); selectedMove = Convert.ToInt32(Console.ReadLine()); } while (selectedMove < 0 || selectedMove >= moves.Length); return selectedMove; }
protected virtual bool IsValidPoint(Situation situation, WarUnit doer, Point2 p) { var unit = situation.Map[p].Unit; // チップの情報からターゲットタイプの値を算出 TargetType type; if (unit == null) { type = TargetType.NONE; } else { if (doer.IsOpponent(unit)) type = TargetType.ENEMY; else type = TargetType.FRIEND; } // スコープのターゲットタイプに内包されるかチェック return (_targetType & type) != 0; }
//get bundle by filter //search start public HttpResponseMessage Post([FromBody] Situation situationIn) { var noSqlWorker = new NoSqlWorker(); noSqlWorker.Initialization(); var bundle = noSqlWorker.Select(); var ss = new SituationSearcher { SituationsInBase = bundle }; ss.SearchStart(situationIn); bundle = ss.SituationsInBase; var liteBundle = bundle.Select(situation => new LiteBundleElement { id = situation.id, name = situation.name, type = situation.type, rate = situation.rate }).ToList(); return(Request.CreateResponse(HttpStatusCode.OK, liteBundle)); }
private static RelevantNodes GetRelevantNodes(RelevantNodes relevantNodes, Situation situation, string relation) { var node = GetNodeByRelation(relation, situation); if (relation == Relations.Agent) { node = GetParentAgent(node); } if (relation != Relations.Agent) { var relevantAgents = GetRelevant(node, relation, Relations.Agent).ToList(); relevantNodes.Agents = relevantNodes.Agents .Intersect(relevantAgents .Union(relevantAgents.SelectMany(x => x.ToIsANested())) .Distinct() ); } if (relation != Relations.Action) { relevantNodes.Actions = relevantNodes.Actions .Intersect(GetRelevant(node, relation, Relations.Action)); } if (relation != Relations.Object) { relevantNodes.Objects = relevantNodes.Objects .Intersect(GetRelevant(node, relation, Relations.Object)); } if (relation != Relations.Locative) { relevantNodes.Locatives = relevantNodes.Locatives .Intersect(GetRelevant(node, relation, Relations.Locative)); } return(relevantNodes); }
public void Register(IGuild guild, string e, string added, string removed, ulong?state) { var sit = new Situation() { Event = e, PermAdded = added, PermRemoved = removed, State = state }; if (Situations.TryGetValue(guild.Id, out var ls)) { ls[e] = sit; } else { Situations[guild.Id] = new Actions() { { e, sit } } }; }
private void PrintZigZagLines(DowPivotOld dowPivot, Situation situation) { if (lows.Count != 0 && highs.Count != 0 && dowPivot.DrawProp.ShowZigZag) { switch (situation) { case Situation.AddLow: lowTagName = "Low line" + dowPivot.CurrentBar; Draw.Line(dowPivot, lowTagName, false, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, GetHigh(0).BarIndex), GetHigh(0).Price, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, GetLow(0).BarIndex), GetLow(0).Price, dowPivot.DrawProp.ZigZagColor, DashStyleHelper.Solid, dowPivot.DrawProp.ZigZagWidth); break; case Situation.AddHigh: highTagName = "High line" + dowPivot.CurrentBar; Draw.Line(dowPivot, highTagName, false, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, GetLow(0).BarIndex), GetLow(0).Price, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, GetHigh(0).BarIndex), GetHigh(0).Price, dowPivot.DrawProp.ZigZagColor, DashStyleHelper.Solid, dowPivot.DrawProp.ZigZagWidth); break; case Situation.UpdateLow: Draw.Line(dowPivot, lowTagName, false, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, GetHigh(0).BarIndex), GetHigh(0).Price, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, GetLow(0).BarIndex), GetLow(0).Price, dowPivot.DrawProp.ZigZagColor, DashStyleHelper.Solid, dowPivot.DrawProp.ZigZagWidth); break; case Situation.UpdateHigh: Draw.Line(dowPivot, highTagName, false, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, GetLow(0).BarIndex), GetLow(0).Price, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, GetHigh(0).BarIndex), GetHigh(0).Price, dowPivot.DrawProp.ZigZagColor, DashStyleHelper.Solid, dowPivot.DrawProp.ZigZagWidth); break; } } }
private void PrintPivots(DowPivotOld dowPivot, Situation state) { line1 = "Line 1 " + dowPivot.CurrentBar; line2 = "Line 2 " + dowPivot.CurrentBar; switch (state) { case Situation.AddHigh: lastHighLegTagLine3 = "Line 3 " + dowPivot.CurrentBar; Draw.Line(dowPivot, line1, false, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, high.FirstLow.BarIndex), high.FirstLow.Price, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, high.FirstHigh.BarIndex), high.FirstHigh.Price, Brushes.Green, DashStyleHelper.Solid, dowPivot.DrawProp.ZigZagWidth); Draw.Line(dowPivot, line2, false, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, high.FirstHigh.BarIndex), high.FirstHigh.Price, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, high.SecondLow.BarIndex), high.SecondLow.Price, Brushes.Green, DashStyleHelper.Solid, dowPivot.DrawProp.ZigZagWidth); Draw.Line(dowPivot, lastHighLegTagLine3, false, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, high.SecondLow.BarIndex), high.SecondLow.Price, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, high.SecondHigh.BarIndex), high.SecondHigh.Price, Brushes.Green, DashStyleHelper.Solid, dowPivot.DrawProp.ZigZagWidth); break; case Situation.AddLow: lastLowLegTagLine3 = "Line 3 " + dowPivot.CurrentBar; Draw.Line(dowPivot, line1, false, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, low.FirstHigh.BarIndex), low.FirstHigh.Price, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, low.FirstLow.BarIndex), low.FirstLow.Price, Brushes.Red, DashStyleHelper.Solid, dowPivot.DrawProp.ZigZagWidth); Draw.Line(dowPivot, line2, false, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, low.FirstLow.BarIndex), low.FirstLow.Price, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, low.SecondHigh.BarIndex), low.SecondHigh.Price, Brushes.Red, DashStyleHelper.Solid, dowPivot.DrawProp.ZigZagWidth); Draw.Line(dowPivot, lastLowLegTagLine3, false, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, low.SecondHigh.BarIndex), low.SecondHigh.Price, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, low.SecondLow.BarIndex), low.SecondLow.Price, Brushes.Red, DashStyleHelper.Solid, dowPivot.DrawProp.ZigZagWidth); break; case Situation.UpdateHigh: Draw.Line(dowPivot, lastHighLegTagLine3, false, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, high.SecondLow.BarIndex), high.SecondLow.Price, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, high.SecondHigh.BarIndex), high.SecondHigh.Price, Brushes.Green, DashStyleHelper.Solid, dowPivot.DrawProp.ZigZagWidth); break; case Situation.UpdateLow: Draw.Line(dowPivot, lastLowLegTagLine3, false, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, low.SecondHigh.BarIndex), low.SecondHigh.Price, Miscellaneous.ConvertBarIndexToBarsAgo(dowPivot, low.SecondLow.BarIndex), low.SecondLow.Price, Brushes.Red, DashStyleHelper.Solid, dowPivot.DrawProp.ZigZagWidth); break; } }
/// <summary> /// The GetSituationInfo method. /// </summary> /// <param name="situation">The <paramref name="situation"/> to get information for.</param> public void GetSituationInfo(Situation situation) { if (situation == null) { return; } // Use reflection to get each available property from the situation. foreach (var prop in situation.GetType().GetProperties()) { // Get the value from the property. var val = prop.GetValue(situation, null); // Get each item if the value is a List type and generate a string. string valList; if (val.GetType() == typeof(List <string>)) { valList = string.Join(", ", (List <string>)val); } else if (val.GetType() == typeof(List <int>)) { valList = string.Join(", ", (List <int>)val); } else if (prop.Name == "Severity") { valList = Math.Abs((int)val - 11).ToString(); } else { valList = val.ToString(); } // Add the property name and value to the list view. var lvItem = new ListViewItem(prop.Name); lvItem.SubItems.Add(valList); lvSituationDetails.Items.Add(lvItem); } }
public static void SetupDataFields() { try { ThoughtRecordId = 0; ThoughtRecordItem = new ThoughtRecord(); SituationItem = new Situation(); MoodItems = new List <Mood>(); MoodListItems = new List <MoodList>(); AutomaticThoughtsItems = new List <AutomaticThoughts>(); EvidenceForHotThoughtItems = new List <EvidenceForHotThought>(); EvidenceAgainstHotThoughtItems = new List <EvidenceAgainstHotThought>(); AlternativeThoughtsItems = new List <AlternativeThoughts>(); RerateMoodsItems = new List <RerateMood>(); ThoughtRecordsItems = new List <ThoughtRecord>(); Log.Info(TAG, "Exiting SetupDataFields with ThoughtRecordId = " + ThoughtRecordId.ToString()); } catch (System.Exception e) { Log.Error(TAG, "SetupDataFields: Error occurred initialising default data objects - " + e.Message); } }
public ActionResult <SituationDTO> PutSituation(int id, Situation situation) { if (id != situation.SituationId) { return(BadRequest()); } try { return(Ok(_mapper.Map <SituationDTO>(_service.RegisterOrUpdateSituation(situation)))); } catch (DbUpdateConcurrencyException) { if (!_service.SituationExists(id)) { return(NotFound()); } else { throw; } } }
public CalcBattle(Situation At, Situation De, Field Fi) { //攻撃側ポケモン--------------------------------------------------------------------------------------------------------------------------------------------- //わざ(威力・特殊/物理・命中率・味方ポケモンのタイプ一致) //攻撃数値(ポケモンの性格・種族値・個体値・努力値) //ランク(A/C) //道具(火力系) //特性(火力系) //その他(てだすけ・さきどり・そうでん・ハロウィン・バッテリー・やけど・じゅうでん・フラワーギフト・もりののろい) //急所 //防御側ポケモン--------------------------------------------------------------------------------------------------------------------------------------------- //防御数値(ポケモンの性格・種族値・個体値・努力値) //ランク(B/D) //道具(耐久系) //特性(耐久系) //その他(リフレクター・ひかりのかべ・まもる・みずあそび・みやぶる・でんじふゆう・ハロウィン・フレンドガード・どろあそび・ミラクルアイ・フラワーギフト・もりののろい) //攻守決定してから決まる事象---------------------------------------------------------------------------------------------------------------------------------- //タイプ相性(わざ・敵ポケモンより自動決定) //cMI,cErrorLogを使える }
public Situation NearSituation(string sitKey) { Situation near = situations[sitKey]; int max = 0; foreach (string s in situations.Keys) { int c = 0; for (int i = 0; i < 8; ++i) { if (s[i] != sitKey[i]) { c++; } } if (c > max) { max = c; near = situations[s]; } } return(near); }
// Externalized to Tagger // Oh dear this is hacky, someone teach me to reflect custom types? :P public static Dictionary <string, object> GetNPCPartyInvolvingLot(Lot lot) { if (lot == null || lot.ObjectId == ObjectGuid.InvalidObjectGuid) { return(null); } if (lot.Household != null) { Dictionary <string, object> dic = new Dictionary <string, object>(); foreach (HousePartySituation sit in Situation.GetSituations <HousePartySituation>()) { if (sit.Lot == lot) { dic.Add("Host", sit.Host); dic.Add("StartTime", Common.LocalizeEAString(false, "Gameplay/MapTags/NpcPartyMapTag:Time", new object[] { sit.StartTime })); dic.Add("DressCode", sit.GetClothingStyle().ToString()); return(dic); } } } return(null); }
public static bool PreferEvadeSpell() { if (!Situation.ShouldUseEvadeSpell()) { return(false); } foreach (KeyValuePair <int, Spell> entry in SpellDetector.Spells) { Spell spell = entry.Value; if (!GameData.HeroInfo.ServerPos2D.InSkillShot(spell, GameData.HeroInfo.BoundingRadius)) { continue; } if (ActivateEvadeSpell(spell, true)) { return(true); } } return(false); }
private void AddButton(Situation s, Situation actualSituation, GameObject panelWindow, int hour) { Transform scroll = gameObject.FindByName <Transform>("ScrollSituations"); GameObject go = Instantiate(SituationPrefab); go.SetActive(true); go.transform.SetParent(scroll); go.transform.localScale = new Vector3(1, 1, 1); go.FindByName <Image>("ButtonTextSituation").color = s.DayNightType.Color; go.FindByName <Text>("TextSituation").text = s.Text; go.FindByName <Text>("TextSituation").color = s.DayNightType == Situation.Type.Day ? Color.black : Color.white; if (s == actualSituation) { go.FindByName <Image>("ButtonTextSituation").color = Color.gray; go.FindByName <Text>("TextSituation").text += " (obecna sytuacja) "; } go.FindByName <Button>("ButtonTextSituation").onClick.AddListener(AddSituation(hour, s)); go.FindByName <Button>("ButtonTextSituation").onClick.AddListener(() => { Game.Me.CloseWindow(panelWindow); }); go.FindByName <Text>("TextSituationInfo").text = "Informacje"; go.FindByName <Button>("ButtonSituationInfo").onClick.AddListener(OpenInfo(s)); }
private IDictionary <Situation, RobotAction> GetSimpleStrategy(RobotAction robotAction) { var strategy = new Dictionary <Situation, RobotAction>(); var contentPossibilities = Enum.GetValues(typeof(Situation.BoardContents)).Cast <Situation.BoardContents>().ToArray(); foreach (var north in contentPossibilities) { foreach (var south in contentPossibilities) { foreach (var east in contentPossibilities) { foreach (var west in contentPossibilities) { foreach (var current in contentPossibilities) { Situation s = new Situation(current, north, south, east, west); strategy[s] = robotAction; } } } } } return(strategy); }
internal void ReplaceSituation(int from, int duration, Situation situation, bool permament) { //if duration bigger than 1 then cut it to pieces; if (duration < 1) { throw new Exception("You can not add situation with duration 0"); } if (duration > 1) { for (int i = 0; i < duration; i++) { int hour = from + i; if (hour > 23) { hour -= 24; } ReplaceSituation(hour, 1, situation, permament); } return; } ScheduledSituation ss = new ScheduledSituation(from, duration, situation, permament); ScheduledSituation[] s = Situations.ToArray(); foreach (ScheduledSituation ssTmp in s) { if (AreOverlapping(ssTmp, ss)) { Situations.Remove(ssTmp); break; } } Situations.Add(ss); Situations.Sort((t, y) => t.From.CompareTo(y.From)); ScheduleUpdated(); }
private void CheckHeroInDanger() { bool playerInDanger = false; foreach (KeyValuePair <int, Spell> entry in SpellDetector.Spells) { Spell spell = entry.Value; if (LastPosInfo != null) //&& lastPosInfo.dodgeableSpells.Contains(spell.spellID)) { if (GameData.MyHero.ServerPosition.To2D().InSkillShot(spell, GameData.HeroInfo.BoundingRadius)) { playerInDanger = true; break; } if (ConfigValue.EnableEvadeDistance.GetBool() && EvadeUtils.TickCount < LastPosInfo.EndTime) { playerInDanger = true; break; } } } if (IsDodging && !playerInDanger) { LastDodgingEndTime = EvadeUtils.TickCount; } if (IsDodging == false && !Situation.ShouldDodge()) { return; } IsDodging = playerInDanger; }
void NextPatrolStep() { if (EtapesPatrouille.Count > 0) { bool InteractionValid = VerifyInteraction(); if (!InteractionValid || (InteractionValid && AlreadyInteracted)) { if (myNavMeshAgent.isStopped) { myNavMeshAgent.isStopped = false; } StepPatrolIndex += 1; if (AlreadyInteracted) { UseSecondaryPatrol = true; StepPatrolIndex = 0; } if (StepPatrolIndex >= LogicPatrol().Count) { UseSecondaryPatrol = false; StepPatrolIndex = 0; } myNavMeshAgent.SetDestination(LogicPatrol()[StepPatrolIndex]); mySituation = Situation.PatrolMove; AlreadyInteracted = false; myAnimator.SetTrigger("Move"); } else { mySituation = Situation.Interaction; AlreadyInteracted = true; } } }
internal void UpdateActiveSituation(Situation actualSituation, GameState gameState) { gameObject.FindByName <Text>("QuestText").text = gameState.ActualPlotElement.GetInfo(); //show buttons on second panel Transform panelButtons = gameObject.FindByName <Transform>("PanelButtons"); int i = 0; foreach (Transform button in panelButtons) { button.gameObject.SetActive(actualSituation != null && i < actualSituation.Buttons.Count); if (actualSituation != null && i < actualSituation.Buttons.Count) { LOL.Button b = actualSituation.Buttons[i]; button.GetComponentInChildren <Text>().text = b.Text; // + "\n\nKoszt: " + b.Changes.Where(change => change.ValueCalculation != null && change.ValueCalculation.Calculate() < 0).Select(change => change.What.Text + " " + change.ValueCalculation.Calculate().ToString("0.0")).Aggregate((t, y) => t + ", " + y); button.GetComponent <Button>().onClick.RemoveAllListeners(); button.GetComponent <Button>().onClick.AddListener(() => { foreach (Change c in b.Changes) { bool isRightType = actualSituation.DayNightType.IsRightType(gameState.Schedule.GetActualDayNightType((int)Game.Me.GameState.HourOfDay)); c.UpdateParams(isRightType); } foreach (Parameter p in gameState.Parameters) { p.UpdateValuesFromPreviousLoop(); } }); bool canIt = b.Changes.All(change => change.CanUpdateWithoutOverflow(change)); button.GetComponent <Image>().color = canIt ? Color.white : Color.red; button.GetComponent <Button>().enabled = canIt; } i++; } }
private static void ContinueLastBlockedCommand() { if (!ObjectCache.MenuCache.Cache["ContinueMovement"].As <MenuBool>().Enabled || !Situation.ShouldDodge()) { return; } var movePos = LastBlockedUserMoveTo.TargetPosition; var extraDelay = ObjectCache.MenuCache.Cache["ExtraPingBuffer"].As <MenuSlider>().Value; if (IsDodging || LastBlockedUserMoveTo.IsProcessed || !(Environment.TickCount - LastEvadeCommand.Timestamp > ObjectCache.GamePing + extraDelay) || !(Environment.TickCount - LastBlockedUserMoveTo.Timestamp < 1500)) { return; } movePos = movePos + (movePos - ObjectCache.MyHeroCache.ServerPos2D).Normalized() * EvadeUtils.Random.Next(1, 65); if (EvadeHelper.CheckMovePath(movePos, ObjectCache.GamePing + extraDelay)) { return; } EvadeCommand.MoveTo(movePos); LastBlockedUserMoveTo.IsProcessed = true; }
public SituationPage(Situation situation) { InitializeComponent(); Situation = situation; }
private void Game_OnCastSpell(Obj_AI_Base sender, SpellBookCastSpellEventArgs args) { if (!sender.IsMe) { return; } var sData = sender.SpellBook.GetSpell(args.Slot); if (SpellDetector.ChanneledSpells.TryGetValue(sData.Name, out _)) { LastStopEvadeTime = Environment.TickCount + ObjectCache.GamePing + 100; } if (EvadeSpell.LastSpellEvadeCommand != null && EvadeSpell.LastSpellEvadeCommand.Timestamp + ObjectCache.GamePing + 150 > Environment.TickCount) { args.Process = false; } LastSpellCast = args.Slot; LastSpellCastTime = Environment.TickCount; if (Situation.ShouldDodge()) { if (IsDodging && SpellDetector.Spells.Any()) { if (SpellDetector.WindupSpells.Select(entry => entry.Value).Any(spellData => spellData.SpellKey == args.Slot)) { args.Process = false; return; } } } foreach (var evadeSpell in EvadeSpell.EvadeSpells) { if (evadeSpell.IsItem || evadeSpell.SpellKey != args.Slot || evadeSpell.Untargetable) { continue; } switch (evadeSpell.EvadeType) { case EvadeType.Blink: { var blinkPos = args.Start.To2D(); var posInfo = EvadeHelper.CanHeroWalkToPos(blinkPos, evadeSpell.Speed, ObjectCache.GamePing, 0); if (posInfo != null && posInfo.PosDangerLevel == 0) { EvadeCommand.MoveTo(posInfo.Position); LastStopEvadeTime = Environment.TickCount + ObjectCache.GamePing + evadeSpell.SpellDelay; } break; } case EvadeType.Dash: { var dashPos = args.Start.To2D(); if (args.Target != null) { dashPos = args.Target.Position.To2D(); } if (evadeSpell.FixedRange || dashPos.Distance(MyHero.ServerPosition.To2D()) > evadeSpell.Range) { var dir = (dashPos - MyHero.ServerPosition.To2D()).Normalized(); dashPos = MyHero.ServerPosition.To2D() + dir * evadeSpell.Range; } var posInfo = EvadeHelper.CanHeroWalkToPos(dashPos, evadeSpell.Speed, ObjectCache.GamePing, 0); if (posInfo != null && posInfo.PosDangerLevel > 0) { args.Process = false; return; } if (IsDodging || Environment.TickCount < LastDodgingEndTime + 500) { EvadeCommand.MoveTo(Game.CursorPos.To2D()); LastStopEvadeTime = Environment.TickCount + ObjectCache.GamePing + 100; } break; } } return; } }
private void Game_OnIssueOrder(Obj_AI_Base hero, Obj_AI_BaseIssueOrderEventArgs args) { if (!hero.IsMe) { return; } if (!Situation.ShouldDodge()) { return; } if (args.OrderType == OrderType.MoveTo) { if (IsDodging && SpellDetector.Spells.Any()) { var limitDelay = ObjectCache.MenuCache.Cache["TickLimiter"].As <MenuSlider>(); //Tick limiter if (Environment.TickCount - LastTickCount < limitDelay.Value) { LastTickCount = Environment.TickCount; args.ProcessEvent = false; return; } CheckHeroInDanger(); LastBlockedUserMoveTo = new EvadeCommand { Order = EvadeOrderCommand.MoveTo, TargetPosition = args.Position.To2D(), Timestamp = Environment.TickCount, IsProcessed = false }; var posInfoTest = EvadeHelper.CanHeroWalkToPos(args.Position.To2D(), ObjectCache.MyHeroCache.MoveSpeed, 0, 0, false); if (posInfoTest.IsDangerousPos) { args.ProcessEvent = false; } else { LastPosInfo.Position = args.Position.To2D(); args.ProcessEvent = true; } } else { var movePos = args.Position.To2D(); var extraDelay = ObjectCache.MenuCache.Cache["ExtraPingBuffer"].As <MenuSlider>().Value; if (EvadeHelper.CheckMovePath(movePos, ObjectCache.GamePing + extraDelay)) { LastBlockedUserMoveTo = new EvadeCommand { Order = EvadeOrderCommand.MoveTo, TargetPosition = args /*.Target*/.Position.To2D(), Timestamp = Environment.TickCount, IsProcessed = false }; args.ProcessEvent = false; if (Environment.TickCount - LastMovementBlockTime < 500 && LastMovementBlockPos.Distance(args./*Target.*/ Position) < 100) { return; } LastMovementBlockPos = args./*Target.*/ Position; LastMovementBlockTime = Environment.TickCount; var posInfo = EvadeHelper.GetBestPositionMovementBlock(movePos); if (posInfo != null) { EvadeCommand.MoveTo(posInfo.Position); } return; } LastBlockedUserMoveTo.IsProcessed = true; } } else { if (IsDodging) { args.ProcessEvent = false; } else { if (args.OrderType == OrderType.AttackUnit) { var target = args.Target; if (target != null && target.IsValid) { var baseTarget = target as Obj_AI_Base; if (baseTarget != null && ObjectCache.MyHeroCache.ServerPos2D.Distance(baseTarget.ServerPosition.To2D()) > MyHero.AttackRange + ObjectCache.MyHeroCache.BoundingRadius + baseTarget.BoundingRadius) { var movePos = args.Position.To2D(); var extraDelay = ObjectCache.MenuCache.Cache["ExtraPingBuffer"].As <MenuSlider>().Value; if (EvadeHelper.CheckMovePath(movePos, ObjectCache.GamePing + extraDelay)) { args.ProcessEvent = false; return; } } } } } } if (!args.ProcessEvent) { return; } LastIssueOrderGameTime = Game.ClockTime * 1000; LastIssueOrderTime = Environment.TickCount; LastIssueOrderArgs = args; switch (args.OrderType) { case OrderType.MoveTo: LastMoveToPosition = args /*.Target*/.Position.To2D(); LastMoveToServerPos = MyHero.ServerPosition.To2D(); break; case OrderType.Stop: LastStopPosition = MyHero.ServerPosition.To2D(); break; } }
private void ProcessRadarGameEvent1(NcaafbGameEvent ncaafbGameEvent) { if (ncaafbGameEvent.Metadata == null) { Logger.Error("ProcessRadarGameEvent1(): game event metadata was null"); return; } try { string eventType = ncaafbGameEvent.Metadata.EventType; string possession = "N"; // todo create an object from NFL event definition NcaafbGameState.Status = ncaafbGameEvent.Metadata.Status; Event payloadEvent = ncaafbGameEvent.Payload.Event; Situation endSituation = payloadEvent.EndSituation; NcaafbGameState.YardsToGo = endSituation.Yfd; NcaafbGameState.Down = endSituation.Down; NcaafbGameState.Clock = endSituation.Clock; NcaafbGameState.Seconds = Utils.ConvertPeriodToGameString(payloadEvent.Period.Sequence, payloadEvent.EndSituation.Clock, 3600); NcaafbGameState.Possession = 0; if (ncaafbGameEvent.Payload.Event.EndSituation.Possession.Id == AwayTeam.TeamId) { NcaafbGameState.Possession = 1; possession = "V"; } if (ncaafbGameEvent.Payload.Event.EndSituation.Possession.Id == HomeTeam.TeamId) { NcaafbGameState.Possession = 2; possession = "H"; } NcaafbGameState.FieldPosition = ToInt32(ncaafbGameEvent.Payload.Event.EndSituation.Location.Yardline); NcaafbGameState.Quarter = ncaafbGameEvent.Payload.Game.Quarter; ModelData[NcaafbModelDataKeys.Egt] = new Dictionary <string, double> { { "S", ToDouble(NcaafbGameState.Seconds) }, { "FP", ToDouble(NcaafbGameState.FieldPosition) }, { "DN", ToDouble(NcaafbGameState.Down) }, { "YF", ToDouble(NcaafbGameState.YardsToGo) }, { "P", ToDouble(NcaafbGameState.Possession) } }; //ModelData[NcaafbModelDataKeys.Egt] = new Dictionary<string, double>(); int awayScore = ncaafbGameEvent.Payload.Game.Summary.Away.Points; int homeScore = ncaafbGameEvent.Payload.Game.Summary.Home.Points; Dictionary <string, double> evsDictionary = ModelData[NcaafbModelDataKeys.Evs]; // todo are the if checks necessary? if (!evsDictionary.ContainsKey("H,Q1")) { evsDictionary["V,Q1"] = 0; evsDictionary["H,Q1"] = 0; } if (!evsDictionary.ContainsKey("H,H1")) { evsDictionary["V,H1"] = 0; evsDictionary["H,H1"] = 0; } if (!evsDictionary.ContainsKey("H,Q2")) { evsDictionary["V,Q2"] = 0; evsDictionary["H,Q2"] = 0; } if (!evsDictionary.ContainsKey("H,H2")) { evsDictionary["V,H2"] = 0; evsDictionary["H,H2"] = 0; } if (!evsDictionary.ContainsKey("H,Q3")) { evsDictionary["V,Q3"] = 0; evsDictionary["H,Q3"] = 0; } if (!evsDictionary.ContainsKey("H,Q4")) { evsDictionary["V,Q4"] = 0; evsDictionary["H,Q4"] = 0; } evsDictionary["H,CG"] = homeScore; evsDictionary["V,CG"] = awayScore; switch (NcaafbGameState.Quarter) { case 1: evsDictionary["V,Q1"] = awayScore; evsDictionary["H,Q1"] = homeScore; break; case 2: evsDictionary["V,Q2"] = awayScore - evsDictionary["V,Q1"]; evsDictionary["H,Q2"] = homeScore - evsDictionary["H,Q1"]; break; case 3: evsDictionary["V,Q3"] = awayScore - (evsDictionary["V,Q1"] + evsDictionary["V,Q2"]); evsDictionary["H,Q3"] = homeScore - (evsDictionary["H,Q1"] + evsDictionary["H,Q2"]); break; case 4: evsDictionary["V,Q4"] = awayScore - (evsDictionary["V,Q1"] + evsDictionary["V,Q2"] + evsDictionary["V,Q3"]); evsDictionary["H,Q4"] = homeScore - (evsDictionary["H,Q1"] + evsDictionary["H,Q2"] + evsDictionary["H,Q3"]); break; } evsDictionary["H,H1"] = evsDictionary["H,Q1"] + evsDictionary["H,Q2"]; evsDictionary["V,H1"] = evsDictionary["V,Q1"] + evsDictionary["V,Q2"]; evsDictionary["H,H2"] = evsDictionary["H,Q3"] + evsDictionary["H,Q4"]; evsDictionary["V,H2"] = evsDictionary["V,Q3"] + evsDictionary["V,Q4"]; ModelUpdateRequired = true; string quarter = $"Q{NcaafbGameState.Quarter}"; string clock = NcaafbGameState.Clock; switch (NcaafbGameState.Status) { case "halftime": quarter = "HT"; break; case "closed": quarter = "FN"; break; } if (eventType == "period_end") { int qplus = NcaafbGameState.Quarter + 1; quarter = $"Q{qplus}"; clock = "15:00"; } string messageJson = $@"{{ ""game"": ""{GameId}"", ""Status"": ""{NcaafbGameState.Status}"", ""away_score"": {awayScore}, ""home_score"": {homeScore}, ""away_q1"": {evsDictionary["V,Q1"]}, ""home_q1"": {evsDictionary["H,Q1"]}, ""away_q2"": {evsDictionary["V,Q2"]}, ""home_q2"": {evsDictionary["H,Q2"]}, ""away_q3"": {evsDictionary["V,Q3"]}, ""home_q3"": {evsDictionary["H,Q3"]}, ""away_q4"": {evsDictionary["V,Q4"]}, ""home_q4"": {evsDictionary["H,Q4"]}, ""period"": ""{quarter}"", ""clock"": ""{clock}"", ""possession"": ""{possession}"", ""down"": {NcaafbGameState.Down}, ""Y2F"": {NcaafbGameState.YardsToGo}, ""FP"": {NcaafbGameState.FieldPosition} }}"; if (!Utils.IsValidJson(messageJson)) { throw new Exception("JSON is invalid: {jsonString}"); } string messageKey = GameId + "score"; const string eventName = "NFLTEAM"; Logger.Info(messageJson); _pusherUtil.SendScoreMessage(messageJson, eventName, messageKey); } catch (Exception exception) { Logger.Error(exception); } //NcaafbGameState.Quarter = ncaafbGameEvent.Metadata.Quarter; //NcaafbGameState.Possession = ncaafbGameEvent.Metadata.Possession; //Event payloadEvent = ncaafbGameEvent.Payload.Event; // check to make sure its moving forward //int sequence = payloadEvent.SequenceNumber; //if (sequence <= NcaafbGameState.Sequence) //{ // return; //} //NcaafbGameState.Sequence = sequence; //bool isHit = false; /* TO DO ADD PROCESSING LOGIC FOR NFL STREAMING EVENTS */ }
public void RemovedConditonTable(Situation situation, WarUnit unit) { unit.ReviseStatus -= ReviseStatus; }
public FStockItem() { Module = "Cadastros Iniciais"; ObjectControl = new List <StockItem>(); InvokeMethod = new InvokeMethod(typeof(StockItemController), new Dictionary <TypeExecute, string>() { { TypeExecute.InsertOrUpdate, "Save" }, { TypeExecute.Remove, "RemoveId" }, { TypeExecute.FindId, "FindId" }, { TypeExecute.Search, "Search" }, { TypeExecute.SearchAll, "ListStockItem" } }, typeof(StockItem)); InitializeComponent(); ImageSource = Properties.Resources.Icon_stock; Situation.SetEnumItems <Situation>(Core.Domain.EnumBase.Situation.Active); UnitMeasureId.FormType = typeof(FUnitMeasure); UnitMeasureId.ObjetoApp = new InvokeMethod(typeof(UnitMeasureController), TypeExecute.SearchAll, "ListUnitMeasure", typeof(UnitMeasure)); UnitMeasureId.ValueMember = "Id"; UnitMeasureId.DisplayMember = "Initials"; OriginItem.SetEnumItems <OriginItem>(Core.Domain.EnumBase.OriginItem.Origin0); MerchandiseUse.SetEnumItems <MerchandiseUse>(Core.Domain.EnumBase.MerchandiseUse.Commercialization); FamilyId.FormType = typeof(FFamily); FamilyId.ObjetoApp = new InvokeMethod(typeof(FamilyController), TypeExecute.SearchAll, "ListFamily", typeof(Family)); FamilyId.DisplayMember = "FamilyName"; FamilyId.ValueMember = "Id"; NcmId.FormType = typeof(FNcm); NcmId.ObjetoApp = new InvokeMethod(typeof(NcmController), TypeExecute.SearchAll, "ListNcm", typeof(Ncm)); NcmId.DisplayMember = "NcmName"; NcmId.ValueMember = "Id"; FeaturedNcmId.ObjetoApp = new InvokeMethod(typeof(FeaturedNcmController), TypeExecute.SearchAll, "ListFeaturedNcm", typeof(FeaturedNcm)); FeaturedNcmId.DisplayMember = "Description"; FeaturedNcmId.ValueMember = "Id"; TypeValueCommission.SetEnumItems <TypeValue>(TypeValue.Porcent); TypeValueProfit.SetEnumItems <TypeValue>(TypeValue.Porcent); ValidityType.SetEnumItems <ValidityType>(Core.Domain.EnumBase.ValidityType.Day); MarkId.FormType = typeof(FMark); MarkId.ObjetoApp = new InvokeMethod(typeof(MarkController), TypeExecute.SearchAll, "ListMark", typeof(Mark)); MarkId.DisplayMember = "Description"; MarkId.ValueMember = "Id"; ModelId.FormType = typeof(FModel); ModelId.ObjetoApp = new InvokeMethod(typeof(ModelController), TypeExecute.SearchAll, "ListModel", typeof(Model)); ModelId.DisplayMember = "Description"; ModelId.ValueMember = "Id"; SpecialTaxs.FormType = typeof(FSpecialTax); SpecialTaxs.ObjetoApp = new InvokeMethod(typeof(SpecialTaxController), TypeExecute.Search, "Search", typeof(SpecialTax)); SpecialTaxs.IsDependecyUkey = true; SpecialTaxs.ScreenSecondary = true; SpecialTaxs.Caption = "Impostos específicos"; Compositions.FormType = typeof(FComposition); Compositions.ObjetoApp = new InvokeMethod(typeof(CompositionController), TypeExecute.Search, "Search", typeof(Composition)); Compositions.IsDependecyUkey = true; Compositions.ScreenSecondary = true; Compositions.Caption = "Composição"; ItemSuppliers.FormType = typeof(FItemSuppliers); ItemSuppliers.ObjetoApp = new InvokeMethod(typeof(ItemSuppliersController), TypeExecute.Search, "Search", typeof(ItemSuppliers)); ItemSuppliers.IsDependecyUkey = true; ItemSuppliers.ScreenSecondary = true; ItemSuppliers.Caption = "Fornecedores"; ImageSource = Properties.Resources.Icon_stock; }
public bool Test(ProtoCrewMember pcm) { bool res = true; if (pcm == null) { Core.Log("ProtoCrewMember argument in Logic.Test is null!", LogLevel.Error); return(res); } Vessel v = Core.KerbalVessel(pcm); if (Situation != null) { if (v != null) { switch (Situation.ToLower()) { case "prelaunch": Op(ref res, v.situation == Vessel.Situations.PRELAUNCH); break; case "landed": Op(ref res, v.situation == Vessel.Situations.LANDED); break; case "splashed": Op(ref res, v.situation == Vessel.Situations.SPLASHED); break; case "ground": Op(ref res, (v.situation == Vessel.Situations.LANDED) || (v.situation == Vessel.Situations.SPLASHED)); break; case "flying": Op(ref res, v.situation == Vessel.Situations.FLYING); break; case "suborbital": Op(ref res, v.situation == Vessel.Situations.SUB_ORBITAL); break; case "orbiting": Op(ref res, v.situation == Vessel.Situations.ORBITING); break; case "escaping": Op(ref res, v.situation == Vessel.Situations.ESCAPING); break; case "in space": Op(ref res, (v.situation == Vessel.Situations.SUB_ORBITAL) || (v.situation == Vessel.Situations.ORBITING) || (v.situation == Vessel.Situations.ESCAPING)); break; } } else { Op(ref res, false); } } if (InSOI != null) { Op(ref res, v != null ? InSOI.Equals(v.mainBody.name, StringComparison.CurrentCultureIgnoreCase) : false); } if (KerbalStatus != null) { Op(ref res, KerbalStatus.Equals(pcm.rosterStatus.ToString(), StringComparison.CurrentCultureIgnoreCase)); } if (!Double.IsNaN(MissionTime)) { Op(ref res, v != null ? v.missionTime >= MissionTime : false); } if (Gender != null) { ProtoCrewMember.Gender g = pcm.gender; switch (Gender.ToLower()) { case "female": Op(ref res, g == ProtoCrewMember.Gender.Female); break; case "male": Op(ref res, g == ProtoCrewMember.Gender.Male); break; } } if (GenderPresent != null) { ProtoCrewMember.Gender g; switch (GenderPresent.ToLower()) { case "female": g = ProtoCrewMember.Gender.Female; break; case "male": g = ProtoCrewMember.Gender.Male; break; case "same": g = pcm.gender; break; case "other": g = pcm.gender == ProtoCrewMember.Gender.Female ? ProtoCrewMember.Gender.Male : ProtoCrewMember.Gender.Female; break; default: Core.Log("Unrecognized value for gender in 'genderPresent = " + GenderPresent + "'. Assuming 'other'."); goto case "other"; } bool found = false; if (v != null) { foreach (ProtoCrewMember crewmate in v.GetVesselCrew()) { if ((crewmate.gender == g) && (crewmate != pcm)) { found = true; break; } } } Op(ref res, found); } if (TraitPresent != null) { bool found = false; if (v != null) { foreach (ProtoCrewMember crewmate in v.GetVesselCrew()) { if ((crewmate.trait.ToLower() == TraitPresent.ToLower()) && (crewmate != pcm)) { found = true; break; } } } Op(ref res, found); } if (ConditionPresent != null) { bool found = false; if (v != null) { foreach (ProtoCrewMember crewmate in v.GetVesselCrew()) { if ((Core.KerbalHealthList[crewmate].HasCondition(ConditionPresent)) && (crewmate != pcm)) { found = true; break; } } } Op(ref res, found); } foreach (Logic l in Operands) { Op(ref res, l.Test(pcm)); } return(res ^ Inverse); }
public void Update(Situation situation) { _situationRepository.Update(situation); }
public void Add(Situation situation) { _situationRepository.Add(situation); }
public static void CheckChangeInActiveHousehold(Household newHousehold, bool bForce) { if (newHousehold == null) { return; } if (sCurrentNonNullHousehold == null) { sCurrentNonNullHousehold = PlumbBob.sCurrentNonNullHousehold; PlumbBob.sCurrentNonNullHousehold = null; } try { if (sCurrentNonNullHousehold != newHousehold || bForce) { Lot lot = null; if (sCurrentNonNullHousehold != null) { lot = sCurrentNonNullHousehold.LotHome; } if (sCurrentNonNullHousehold != null && sCurrentNonNullHousehold != newHousehold) { Situation.OnActiveHouseholdChanged(sCurrentNonNullHousehold, newHousehold); if (!NiecHelperSituation.__acorewIsnstalled__) { Party.CancelAllHouseParties(sCurrentNonNullHousehold.LotHome); } //sCurrentNonNullHousehold.ResetSocialWorkerTrigger(); foreach (Sim allActor in sCurrentNonNullHousehold.AllActors) { try { allActor.OnBecameUnselectable(); } catch (Exception) { if (!NiecHelperSituation.__acorewIsnstalled__) { throw; } } } if (lot != null) { lot.OnBecameUnselected(); } sCurrentNonNullHousehold.ResetParentVacationsTrigger(); } if (newHousehold != null) { foreach (Sim actor in newHousehold.AllActors) { if (!Household.RoommateManager.IsNPCRoommate(actor)) { try { actor.OnBecameSelectable(); } catch (Exception) { if (!NiecHelperSituation.__acorewIsnstalled__) { throw; } } } } if (sCurrentNonNullHousehold != newHousehold) { if (lot != null) { //lot.TryTurnOffHolidayHouseLights(); } newHousehold.GiveIngredients(); } if (newHousehold.LotHome != null) { newHousehold.LotHome.OnBecameSelected(); } Lot.UpdatePlayerNeighbors(); TombRoomManager.OnChangeHousehold(newHousehold); try { if (sCurrentNonNullHousehold != newHousehold) { newHousehold.SetParentFreeVacationTrigger(false, false); } } catch (Exception) { if (!NiecHelperSituation.__acorewIsnstalled__) { throw; } } } EventTracker.SendEvent(new HouseholdUpdateEvent(EventTypeId.kHouseholdSelected, newHousehold)); } sCurrentNonNullHousehold = newHousehold; PlumbBob.sCurrentNonNullHousehold = newHousehold; } catch (Exception ex) { niec_native_func.OutputDebugString("CheckChangeInActiveHousehold(Household newHousehold, bool bForce) failed."); NiecException.SendTextExceptionToDebugger(ex); } }
public async Task <IActionResult> Add(int Owner, string name, string Area, string Address, Situation _situation) { House _house = new House() { OwnerID = Owner, Name = name, HouseArea = Area, situation = _situation, Address = Address }; await _houseRepository.Add(_house); await _houseRepository.SaveChangesAsync(); return(RedirectToAction("ShowAll")); }
public static bool IsSerializable(Situation situation) { return (situation & Situation.Serializable) != 0; }
public override void OnDelayedWorldLoadFinished() { Overwatch.Log("CleanupSituations"); Dictionary <Situation, bool> existing = new Dictionary <Situation, bool>(); List <Situation> removed = new List <Situation>(); for (int i = Situation.sAllSituations.Count - 1; i >= 0; i--) { Situation situation = Situation.sAllSituations[i]; bool remove = false; GroupingSituation grouping = situation as GroupingSituation; if (grouping != null) { if ((grouping.mLeader == null) || (grouping.mLeader.HasBeenDestroyed)) { remove = true; } else if (grouping.Participants != null) { foreach (Sim sim in grouping.Participants) { if (sim == null) { grouping.mParticipants.Clear(); remove = true; break; } } } } else { HostedSituation hosted = situation as HostedSituation; if (hosted != null) { if ((hosted.Host == null) || (hosted.Host.HasBeenDestroyed)) { remove = true; } } } if (remove) { removed.Add(situation); Situation.sAllSituations.RemoveAt(i); Overwatch.Log("Removed Broken Situation: " + situation.GetType()); } else { existing[situation] = true; } } foreach (Situation situation in removed) { try { situation.Exit(); } catch (Exception e) { Common.DebugException(situation.GetType().ToString(), e); } } foreach (Sim sim in LotManager.Actors) { if (sim.Autonomy == null) { continue; } if (sim.Autonomy.SituationComponent == null) { continue; } List <Situation> situations = sim.Autonomy.SituationComponent.Situations; if (situations == null) { continue; } for (int i = situations.Count - 1; i >= 0; i--) { if (existing.ContainsKey(situations[i])) { continue; } Overwatch.Log("Dropped Broken Situation: " + sim.FullName); situations.RemoveAt(i); } } }