internal void UpdatePlayerRemainingMovement(ActorData actor, bool send = true) { ActorTurnSM turnSm = actor.gameObject.GetComponent <ActorTurnSM>(); ActorController actorController = actor.gameObject.GetComponent <ActorController>(); ActorMovement actorMovement = actor.GetActorMovement(); float movementCost = GetActorMovementCost(actor, out float lastStepCost); bool cannotExceedMaxMovement = GameplayData.Get()?.m_movementMaximumType == GameplayData.MovementMaximumType.CannotExceedMax; List <ActorTargeting.AbilityRequestData> abilityRequest = actor.TeamSensitiveData_authority.GetAbilityRequestData(); bool abilitySet = !abilityRequest.IsNullOrEmpty() && abilityRequest[0].m_actionType != AbilityData.ActionType.INVALID_ACTION; actor.RemainingHorizontalMovement = actorMovement.CalculateMaxHorizontalMovement() - movementCost; actor.RemainingMovementWithQueuedAbility = abilitySet ? actor.RemainingHorizontalMovement : actorMovement.CalculateMaxHorizontalMovement(true) - movementCost; actor.QueuedMovementAllowsAbility = abilitySet || (cannotExceedMaxMovement ? actor.RemainingMovementWithQueuedAbility >= 0 : actor.RemainingMovementWithQueuedAbility + lastStepCost > 0); Log.Info($"UpdatePlayerMovement: Basic: {actor.m_postAbilityHorizontalMovement}/{actor.m_maxHorizontalMovement}, +", $"Remaining: {actor.RemainingMovementWithQueuedAbility}/{actor.RemainingHorizontalMovement}, " + $"Movement cost: {movementCost}, Ability set: {abilitySet}, Ability allowed: {actor.QueuedMovementAllowsAbility}, " + $"Movement max type: {GameplayData.Get()?.m_movementMaximumType}"); actorMovement.UpdateSquaresCanMoveTo(); if (send) { actorController.CallRpcUpdateRemainingMovement(actor.RemainingHorizontalMovement, actor.RemainingMovementWithQueuedAbility); } }
internal void RefreshMovementCache() { if (DateTime.Now.Subtract(LastUpdatedMovementData).TotalMilliseconds < 150) { return; } LastUpdatedMovementData = DateTime.Now; //These vars are used to accuratly predict what the bot is doing (Melee Movement/Combat) using (ZetaDia.Memory.AcquireFrame()) { // If we aren't in the game of a world is loading, don't do anything yet if (!ZetaDia.IsInGame || ZetaDia.IsLoadingWorld) { return; } try { ActorMovement botMovement = ZetaDia.Me.Movement; isMoving = botMovement.IsMoving; curSpeedXY = botMovement.SpeedXY; curRotation = botMovement.Rotation; curMoveState = botMovement.MovementState; stuckflags = botMovement.StuckFlags; } catch { } } }
public override void Initialize(BehaviourProcessor behaviourProcessor) { base.Initialize(behaviourProcessor); actorMovement = behaviourProcessor.GetComponent <ActorMovement>(); currentDirection.x = randomDirection ? GetRandomDirection() : startDirection; }
// Use this for initialization void Start() { // fetch movement scripts from red and blue cubes equationMovement = redCube.GetComponent <EquationMovement>(); actorMovement = blueCube.GetComponent <ActorMovement>(); Init(); }
public override void Initialize(BehaviourProcessor behaviourProcessor) { base.Initialize(behaviourProcessor); actorMovement = behaviourProcessor.GetComponent <ActorMovement>(); movementInput = actorMovement.MovementInput; actorMovement.OnInputChange += SetInput; }
public override void Initialize(BehaviourProcessor behaviourProcessor) { base.Initialize(behaviourProcessor); actorMovement = behaviourProcessor.GetComponent <ActorMovement>(); targetingBehaviour = behaviourProcessor.GetComponent <TargetingBehaviour>(); targetingDistance = behaviourProcessor.GetComponent <TargetingDistance>(); }
void Awake() { DontDestroyOnLoad(transform.gameObject); actorMovement = this.GetComponent <ActorMovement>(); spriteRenderer = this.GetComponent <SpriteRenderer>(); actorCollider = this.GetComponent <Collider2D>(); actorAudio = this.GetComponent <ActorAudio>(); }
void Awake() { DontDestroyOnLoad(transform.gameObject); actorMovement = this.GetComponent<ActorMovement>(); spriteRenderer = this.GetComponent<SpriteRenderer>(); actorCollider = this.GetComponent<Collider2D>(); actorAudio = this.GetComponent<ActorAudio>(); }
public void SetMovement(ActorMovement amovement) { _falling = Vector3.zero; _angular = Vector4.zero; transform.position = DataBridge.cnv(amovement.Location); transform.rotation = DataBridge.cnv(amovement.Rotation); _current_region = Common.ToRegion(transform.position, 0); }
void Start() { m_Stats = GetComponent<Actor>().m_Statistics; m_Movement = GetComponent<ActorMovement> (); m_JumpCR = null; JumpHeight = 6; JumpSpeed = 10; m_Player = gameObject.GetComponent<Actor>(); PickableObjects = LayerMask.GetMask("PickUps"); }
// movement public void DecodeMovement(ByteString movement) { ActorMovement amovement = ActorMovement.Parser.ParseFrom(movement); transform.localPosition = DataBridge.cnv(amovement.Location); _local_velocity = DataBridge.cnv(amovement.Velocity); transform.localRotation = DataBridge.cnv(amovement.Rotation); _local_angular = DataBridge.cnv(amovement.Angular); ConsoleOutput.Trace("AgentMove " + amovement.Angular.W + " @ " + amovement.Angular.Y); }
void Start() { _moverRef = GetComponent <ActorMovement>(); Debug.Assert(_moverRef != null, "Didn't manage to find a ActorMovement."); _statsRef = GetComponent <ActorStats>(); Debug.Assert(_statsRef != null, "Didn't manage to find a ActorStats."); _animatorRef = GetComponent <Animator>(); Debug.Assert(_animatorRef != null, "Didn't manage to find a Animator."); _animatorRef.SetFloat("AttackSpeedMultiplier", _statsRef.AttackSpeed * 2.0f); }
// Start is called before the first frame update void Start() { _moverRef = GetComponent <ActorMovement>(); Debug.Assert(_moverRef != null, "Didn't manage to find a ActorMovement."); _actionRef = GetComponent <ActionManager>(); Debug.Assert(_moverRef != null, "Didn't manage to find a ActionManager."); //PlayerAttackTypeText = GameObject.FindGameObjectWithTag("PlayerAttackType")?.GetComponent<Text>(); //Debug.Assert(_moverRef != null, "Didn't manage to find a ActionManager."); _flowRef = GameObject.FindGameObjectWithTag("FlowManager")?.GetComponent <FlowManager>(); Debug.Assert(_flowRef != null, "Didn't manage to find a FlowManager."); }
void Start() { _moverRef = GetComponent <ActorMovement>(); Debug.Assert(_moverRef != null, "Didn't manage to find a ActorMovement."); _actionRef = GetComponent <ActionManager>(); Debug.Assert(_moverRef != null, "Didn't manage to find a ActionManager."); _pathfinder = GameObject.FindObjectOfType <PathfinderManager>(); Debug.Assert(_pathfinder != null, "Didn't manage to find a PathfinderManager."); _statsRef = GetComponent <ActorStats>(); Debug.Assert(_statsRef != null, "Didn't manage to find a ActorStats."); }
protected void Start() { movement = transform.GetComponent<ActorMovement>(); this.inventory = new Inventory(); this.inventory.size = inventorySize; //animator = GetComponent<Animator>(); int startState = Random.Range(0, 2); //randomly decide if enemy starts in sleeping or wandering state //if (startState == 0) CurrentState = EnemyState.Sleeping; //else CurrentState = EnemyState.Wandering; GameManager.Instance.AddNPCToList(this); }
void HandleJoinConnectedPlayInstanceRes(SFMessage message) { UpdateButtonState(); var result = message.GetValue <Result>("Result"); if (result.IsFailed) { return; } var playInstanceUID = message.GetValue <UInt64>("PlayInstanceUID"); var playerID = message.GetValue <UInt64>("PlayerID"); var movement = message.GetValue <ActorMovement>("Movement"); m_MyMove = movement; // player join process has finished }
private float GetActorMovementCost(ActorData actor, out float lastStepCost) { float movementCost = 0; lastStepCost = 0; ActorMovement actorMovement = actor.GetActorMovement(); LineData.LineInstance movementLine = actor.TeamSensitiveData_authority.MovementLine; if (movementLine != null) { GridPos prevPos = actor.InitialMoveStartSquare.GetGridPosition(); foreach (var curPos in movementLine.m_positions) { lastStepCost = actorMovement.BuildPathTo(Board.Get().GetSquare(prevPos), Board.Get().GetSquare(curPos)).next?.moveCost ?? 0f; // TODO optimize this atrocity movementCost += lastStepCost; prevPos = curPos; } } return(movementCost); }
private BoardSquarePathInfo ResolveMovement(ActorData actor) { ActorTeamSensitiveData atsd = actor.TeamSensitiveData_authority; ActorMovement actorMovement = actor.GetActorMovement(); BoardSquare start = actor.InitialMoveStartSquare; BoardSquare end = actor.MoveFromBoardSquare; BoardSquarePathInfo path; if (atsd.MovementLine != null) { path = BuildPathAlongMovementLine(actor); } else { path = actorMovement.BuildPathTo(start, end); } if (path == null) { path = actorMovement.BuildPathTo(start, start); } for (var pathNode = path; pathNode.next != null; pathNode = pathNode.next) { pathNode.m_unskippable = true; // so that aestetic path is not optimized (see CreateRunAndVaultAesteticPath) } var path2 = path; while (path2.next != null) { Log.Info($"FINAL PATH {path2.square.GetGridPosition()}"); path2 = path2.next; } Log.Info($"FINAL PATH {path2.square.GetGridPosition()}"); return(path); }
void Awake() { movement = GetComponent <ActorMovement>(); input = GetComponent <ActorInput>(); combat = GetComponent <ActorCombat>(); animation = GetComponent <Animation>(); TextMesh[] textMeshes = GetComponentsInChildren <TextMesh>(); foreach (TextMesh textMesh in textMeshes) { if (textMesh.transform.name == "DebugText") { debugTextMesh = textMesh; } if (textMesh.transform.name == "LifeCounter") { lifeCounterTextMesh = textMesh; } } }
private static BoardSquarePathInfo BuildPathAlongMovementLine(ActorData actor) { ActorTeamSensitiveData atsd = actor.TeamSensitiveData_authority; ActorMovement actorMovement = actor.GetActorMovement(); BoardSquare start = actor.InitialMoveStartSquare; BoardSquare end = actor.MoveFromBoardSquare; // TODO refactor this atrocity BoardSquarePathInfo path = actorMovement.BuildPathTo(start, start); BoardSquarePathInfo node = path; foreach (var curPos in atsd.MovementLine.m_positions) { node.next = actorMovement.BuildPathTo(node.square, Board.Get().GetSquare(curPos)).next; if (node.next == null) { continue; } node.next.moveCost += node.moveCost; node.next.prev = node; node = node.next; } return(path); }
private void RefreshMovementCache() { LastUpdatedMovementData = DateTime.Now; //These vars are used to accuratly predict what the bot is doing (Melee Movement/Combat) using (ZetaDia.Memory.AcquireFrame()) { // If we aren't in the game of a world is loading, don't do anything yet if (!ZetaDia.IsInGame || ZetaDia.IsLoadingWorld) { return; } try { ActorMovement botMovement = ZetaDia.Me.Movement; isMoving = botMovement.IsMoving; curMoveState = botMovement.MovementState; stuckflags = botMovement.StuckFlags; } catch { } } }
void Start() { animator = this.GetComponent<Animator>(); actorMovement = this.GetComponent<ActorMovement>(); actorAttack = this.GetComponent<ActorAttack>(); }
void Start() { enemyAttack = transform.parent.GetComponent <EnemyAttack>(); actorMovement = transform.parent.GetComponent <ActorMovement>(); }
void Awake( ) { actor = FindComponent <Actor>( ); movement = FindComponent <ActorMovement>( ); }
private void TriggerVisuals() { if (_triggered) { return; } if (GetComponent <ActorStats>().Infected) { GameManager.InfectedCellDies(); } GetComponent <Animator>()?.SetTrigger("Death"); foreach (Component component in gameObject.GetComponents <Component>()) { ActorMovement av = component as ActorMovement; ActionManager am = component as ActionManager; PlayerController pc = component as PlayerController; ActorStats ac = component as ActorStats; AIController ai = component as AIController; if (av != null) { av.enabled = false; } if (am != null) { am.enabled = false; } if (pc != null) { pc.enabled = false; } if (ac != null) { ac.enabled = false; ac.Active = false; } if (ai != null) { ai.enabled = false; } } Collider2D cl = gameObject.GetComponent <Collider2D>(); if (cl != null) { Destroy(cl); } DeceaseFx fx = gameObject.GetComponent <DeceaseFx>(); if (fx != null) { fx.Trigger(FxDone); } else { FxDone(); } this.GetComponent <CharacterAudio>()?.PlayDeathSound(); _triggered = true; }
//private Methods private void AddActorComponents() { m_Abilities = (gameObject.GetComponent <ActorAbilities>() == null ? gameObject.AddComponent <ActorAbilities>() : gameObject.GetComponent <ActorAbilities>()); m_Movement = (gameObject.GetComponent <ActorMovement>() == null ? gameObject.AddComponent <ActorMovement>() : gameObject.GetComponent <ActorMovement>()); m_Inventory = (gameObject.GetComponent <ActorInventory>() == null ? gameObject.AddComponent <ActorInventory>() : gameObject.GetComponent <ActorInventory>()); }
protected virtual void StopMovingActor() { activeActorMovement = ActorMovement.None; moveTimer = 0; moveTimerSpeed = 0; }
void Start() { enemyAttack = transform.parent.GetComponent<EnemyAttack>(); actorMovement = transform.parent.GetComponent<ActorMovement>(); }
// private/protected actions protected virtual void MoveActorRight() { activeActorMovement = ActorMovement.Right; }
public void CmdSetSquare(ActorTurnSM actorTurnSM, int x, int y, bool setWaypoint) { ActorData actor = actorTurnSM.gameObject.GetComponent <ActorData>(); if (!GameFlowData.Get().IsInDecisionState()) { Log.Info($"Recieved CmdSetSquare not in desicion state! {actor.DisplayName} [{x}, {y}] (setWaypoint = {setWaypoint})"); actorTurnSM.CallRpcTurnMessage((int)TurnMessage.MOVEMENT_REJECTED, 0); return; } Log.Info($"CmdSetSquare {actor.DisplayName} [{x}, {y}] (setWaypoint = {setWaypoint})"); BoardSquare boardSquare = Board.Get().GetSquare(x, y); ActorMovement actorMovement = actor.GetActorMovement(); if (!setWaypoint) { ClearMovementRequest(actor, false); } actorMovement.UpdateSquaresCanMoveTo(); if (!actor.CanMoveToBoardSquare(boardSquare)) { boardSquare = actorMovement.GetClosestMoveableSquareTo(boardSquare, false); } if (actor.TeamSensitiveData_authority.MovementLine == null) { actor.TeamSensitiveData_authority.MovementLine = new LineData.LineInstance(); } if (actor.TeamSensitiveData_authority.MovementLine.m_positions.Count == 0) { actor.TeamSensitiveData_authority.MovementLine.m_positions.Add(actor.InitialMoveStartSquare.GetGridPosition()); } BoardSquarePathInfo path = actorMovement.BuildPathTo(actor.TeamSensitiveData_authority.MoveFromBoardSquare, boardSquare); if (path == null) // TODO check cost { Log.Info($"CmdSetSquare: Movement rejected"); UpdatePlayerRemainingMovement(actor); // TODO updating because we cancelled movement - perhaps we should not cancel in this case actorTurnSM.CallRpcTurnMessage((int)TurnMessage.MOVEMENT_REJECTED, 0); return; } //List<GridPos> posList = path.ToGridPosPath(); List <GridPos> posList = new List <GridPos>(); for (var pathNode = path; pathNode.next != null; pathNode = pathNode.next) { posList.Add(pathNode.next.square.GetGridPosition()); // TODO why doesnt path.ToGridPosPath() work? } actor.TeamSensitiveData_authority.MovementLine.m_positions.AddRange(posList); actor.TeamSensitiveData_authority.MoveFromBoardSquare = boardSquare; actor.MoveFromBoardSquare = boardSquare; UpdatePlayerRemainingMovement(actor); actorTurnSM.CallRpcTurnMessage((int)TurnMessage.MOVEMENT_ACCEPTED, 0); }
protected virtual void MoveActorLeft() { activeActorMovement = ActorMovement.Left; }
void Start() { actorMovement = this.GetComponent<ActorMovement>(); }
// ///<summary> ///Adds/Updates CacheObjects inside collection by Iteration of RactorList ///This is the method that caches all live data about an object! ///</summary> internal static bool UpdateCacheObjectCollection() { //Update Character (just incase it wasnt called before..) FunkyGame.Hero.Update(false, true); Obstacles.AttemptToClearEntries(); HashSet <int> hashDoneThisRactor = new HashSet <int>(); using (ZetaDia.Memory.AcquireFrame(true)) { if (!ZetaDia.IsInGame || ZetaDia.IsLoadingWorld || !ZetaDia.Me.IsValid) { return(false); } foreach (Actor thisActor in ZetaDia.Actors.RActorList) { int tmp_raGUID; DiaObject thisObj; if (!thisActor.IsValid) { continue; } //Convert to DiaObject thisObj = (DiaObject)thisActor; tmp_raGUID = thisObj.RActorGuid; // See if we've already checked this ractor, this loop if (hashDoneThisRactor.Contains(tmp_raGUID)) { continue; } hashDoneThisRactor.Add(tmp_raGUID); //Update RactorGUID and check blacklisting.. if (BlacklistCache.IsRAGUIDBlacklisted(tmp_raGUID)) { continue; } CacheObject tmp_CachedObj; if (!Objects.TryGetValue(tmp_raGUID, out tmp_CachedObj)) { ActorType Actortype; Vector3 tmp_position; int tmp_acdguid; int tmp_SNOID; #region SNO //Lookup SNO try { tmp_SNOID = thisObj.ActorSNO; } catch (Exception ex) { Logger.Write(LogLevel.Cache, "Safely handled getting SNO for {0}", tmp_raGUID); //Logger.DBLog.InfoFormat("Failure to get SNO from object! RaGUID: {0}", tmp_raGUID); continue; } #endregion //check our SNO blacklist (exclude pets?) if (BlacklistCache.IsSNOIDBlacklisted(tmp_SNOID)) { continue; } #region Position try { tmp_position = thisObj.Position; } catch (Exception ex) { Logger.Write(LogLevel.Cache, "Safely handled getting Position for {0}", tmp_SNOID); continue; } #endregion #region AcdGUID try { tmp_acdguid = thisObj.ACDGuid; } catch (Exception ex) { Logger.Write(LogLevel.Cache, "Safely handled getting ACDGuid for {0}", tmp_SNOID); continue; } #endregion tmp_CachedObj = new CacheObject(tmp_SNOID, tmp_raGUID, tmp_acdguid, tmp_position); } else { //Reset unseen var tmp_CachedObj.LoopsUnseen = 0; } ////Validate (ignore special object SNO Ids) //if (!CacheIDLookup.hashSNOSkipCommonDataCheck.Contains(tmp_CachedObj.SNOID)) //{ // try // { // if (thisObj.CommonData == null) // { // Logger.Write(LogLevel.Cache, "CommonData is no longer valid! {0}", tmp_CachedObj.DebugStringSimple); // //BlacklistCache.AddObjectToBlacklist(tmp_CachedObj.RAGUID, BlacklistType.Temporary); // continue; // } // if (thisObj.CommonData.ACDGuid != thisObj.ACDGuid) // { // Logger.Write(LogLevel.Cache, "ACDGuid Mismatched! {0}", tmp_CachedObj.DebugStringSimple); // //BlacklistCache.AddObjectToBlacklist(tmp_CachedObj.RAGUID, BlacklistType.Temporary); // continue; // } // } // catch (Exception ex) // { // //Logger.Write(LogLevel.Cache, "Object is no longer valid! (Exception) SNOID {0}", tmp_CachedObj.DebugStringSimple); // //BlacklistCache.AddObjectToBlacklist(tmp_CachedObj.RAGUID, BlacklistType.Temporary); // continue; // } //} //Update any SNO Data. #region SNO_Cache_Update if (tmp_CachedObj.ref_DiaObject == null || tmp_CachedObj.ContainsNullValues()) { if (!tmp_CachedObj.UpdateData(thisObj, tmp_CachedObj.RAGUID)) { continue; } } else if (!tmp_CachedObj.IsFinalized) { //Finalize this data by recreating it and updating the Sno cache with a new finalized entry, this also clears our all Sno cache dictionaries since we no longer need them! cacheSnoCollection.FinalizeEntry(tmp_CachedObj.SNOID); } #endregion //Check if this object is a summoned unit by a player... #region SummonedUnits if (tmp_CachedObj.IsSummonedPet && CacheIDLookup.hashSNOSkipCommonDataCheck.Contains(tmp_CachedObj.SNOID)) { PetTypes PetType = (PetTypes)TheCache.ObjectIDCache.UnitPetEntries[tmp_CachedObj.SNOID].ObjectType; if (PetType == PetTypes.WIZARD_ArcaneOrbs) { FunkyGame.Targeting.Cache.Environment.HeroPets.WizardArcaneOrbs++; tmp_CachedObj.NeedsRemoved = true; continue; } } #endregion //Special Cache for Interactable Server Objects if (CheckFlag(tmp_CachedObj.targetType.Value, TargetType.ServerInteractable)) { if (!InteractableObjectCache.ContainsKey(tmp_CachedObj.RAGUID)) { InteractableObjectCache.Add(tmp_CachedObj.RAGUID, tmp_CachedObj); //Adventure Mode -- Rifting we add Exit to LOS movement! //if (FunkyGame.AdventureMode && FunkyGame.Bounty.IsInRiftWorld && FunkyBaseExtension.Settings.AdventureMode.EnableAdventuringMode) //{ // if (tmp_CachedObj.InternalName.Contains("Exit")) // { // int index = FunkyGame.Bounty.CurrentBountyMapMarkers.Count; // FunkyGame.Bounty.CurrentBountyMapMarkers.Add(index, new BountyCache.BountyMapMarker(tmp_CachedObj.Position, FunkyGame.Hero.CurrentWorldDynamicID, index)); // } //} } //Whymsdal Portal! if (tmp_CachedObj.SNOID == 405590) { GoblinBehavior.Portal = tmp_CachedObj; } else if (tmp_CachedObj.SNOID == 393030) { GoblinBehavior.Portal = tmp_CachedObj; } //Do not add to main cache! continue; } //Objects with static positions already cached don't need to be updated here. if (!tmp_CachedObj.NeedsUpdate) { continue; } //Obstacles -- (Not an actual object we add to targeting.) if (CheckFlag(tmp_CachedObj.targetType.Value, TargetType.Avoidance) || tmp_CachedObj.IsObstacle || tmp_CachedObj.HandleAsAvoidanceObject) { #region Obstacles CacheObstacle thisObstacle; //Do we have this cached? if (!Obstacles.TryGetValue(tmp_CachedObj.RAGUID, out thisObstacle)) { AvoidanceType AvoidanceType = AvoidanceType.None; if (tmp_CachedObj.IsAvoidance) { AvoidanceType = AvoidanceCache.FindAvoidanceUsingSNOID(tmp_CachedObj.SNOID); if (AvoidanceType == AvoidanceType.None) { AvoidanceType = AvoidanceCache.FindAvoidanceUsingName(tmp_CachedObj.InternalName); if (AvoidanceType == AvoidanceType.None) { continue; } } } if (tmp_CachedObj.IsAvoidance && tmp_CachedObj.IsProjectileAvoidance) { //Ranged Projectiles require more than simple bounding points.. so we create it as avoidance zone to cache it with properties. //Check for intersection.. try { ActorMovement thisMovement = thisObj.Movement; Vector2 Direction = thisMovement.DirectionVector; Ray R = new Ray(tmp_CachedObj.Position, Direction.ToVector3()); double Speed; //Lookup Cached Speed, or add new entry. if (!dictProjectileSpeed.TryGetValue(tmp_CachedObj.SNOID, out Speed)) { Speed = thisMovement.DesiredSpeed; dictProjectileSpeed.Add(tmp_CachedObj.SNOID, Speed); } thisObstacle = new CacheAvoidance(tmp_CachedObj, AvoidanceType, R, Speed); Obstacles.Add(thisObstacle); } catch { Logger.Write(LogLevel.Cache, "Failed to create projectile avoidance with rotation and speed. {0}", tmp_CachedObj.InternalName); } } else if (tmp_CachedObj.IsAvoidance) { //Poison Gas Can Be Friendly... if (AvoidanceType == AvoidanceType.PoisonGas) { int TeamID = 0; try { TeamID = thisObj.CommonData.GetAttribute <int>(ActorAttributeType.TeamID); } catch { Logger.Write(LogLevel.Cache, "Failed to retrieve TeamID attribute for object {0}", tmp_CachedObj.InternalName); } //ID of 1 means its non-hostile! (-1?) 2?? //if (TeamID==1||TeamID==-1) if (TeamID != 10) { //Logger.Write(LogLevel.None, "Ignoring Avoidance {0} due to Friendly TeamID match!", tmp_CachedObj.InternalName); BlacklistCache.AddObjectToBlacklist(tmp_CachedObj.RAGUID, BlacklistType.Permanent); continue; } } thisObstacle = new CacheAvoidance(tmp_CachedObj, AvoidanceType); Obstacles.Add(thisObstacle); } else { //Obstacles. thisObstacle = new CacheServerObject(tmp_CachedObj); Obstacles.Add(thisObstacle); } } continue; #endregion } if (tmp_CachedObj.ObjectShouldBeRecreated) { //This is where we create the real object after its done with SNO Update. //Specific updates if (tmp_CachedObj.Actortype.Value == ActorType.Item) { tmp_CachedObj = new CacheItem(tmp_CachedObj); } else if (tmp_CachedObj.Actortype.Value == ActorType.Monster) { if (!tmp_CachedObj.IsSummonedPet) { tmp_CachedObj = new CacheUnit(tmp_CachedObj); } else { PetTypes PetType = (PetTypes)TheCache.ObjectIDCache.UnitPetEntries[tmp_CachedObj.SNOID].ObjectType; #region Summoner ID Check // Get the summoned-by info, cached if possible if (!tmp_CachedObj.SummonerID.HasValue) { try { tmp_CachedObj.SummonerID = thisObj.CommonData.GetAttribute <int>(ActorAttributeType.SummonedByACDID); } catch (Exception ex) { //Logger.DBLog.InfoFormat("[Funky] Safely handled exception getting summoned-by info [" + tmp_CachedObj.SNOID.ToString(CultureInfo.InvariantCulture) + "]"); //Logger.DBLog.DebugFormat(ex.ToString()); continue; } } if (FunkyGame.Hero.iMyDynamicID != tmp_CachedObj.SummonerID.Value) { BlacklistCache.IgnoreThisObject(tmp_CachedObj, false, false); tmp_CachedObj.NeedsRemoved = true; continue; } #endregion tmp_CachedObj = new CachePet(tmp_CachedObj, PetType); } } else if (tmp_CachedObj.Actortype.Value == ActorType.Gizmo) { if (CheckFlag(tmp_CachedObj.targetType.Value, TargetType.Interactables)) { tmp_CachedObj = new CacheInteractable(tmp_CachedObj); } else { tmp_CachedObj = new CacheDestructable(tmp_CachedObj); } } //Update Properties (currently only for units) try { tmp_CachedObj.UpdateProperties(); } catch { Logger.Write(LogLevel.Cache, "Failed to update properties for {0}", tmp_CachedObj.DebugStringSimple); } } if (!tmp_CachedObj.UpdateData()) { //Logger.Write(LogLevel.Cache, "Update Failed for {0}", tmp_CachedObj.DebugStringSimple); if (!tmp_CachedObj.IsStillValid()) { tmp_CachedObj.NeedsRemoved = true; } continue; } //Obstacle cache if (tmp_CachedObj.Obstacletype.Value != ObstacleType.None && (CheckFlag(tmp_CachedObj.targetType.Value, TargetType.ServerObjects))) { CacheObstacle thisObstacleObj; if (!Obstacles.TryGetValue(tmp_CachedObj.RAGUID, out thisObstacleObj)) { CacheServerObject newobj = new CacheServerObject(tmp_CachedObj); Obstacles.Add(tmp_CachedObj.RAGUID, newobj); //Add nearby objects to our collection (used in navblock/obstaclecheck methods to reduce queries) if (CacheIDLookup.hashSNONavigationObstacles.Contains(newobj.SNOID)) { Navigation.Navigation.MGP.AddCellWeightingObstacle(newobj.SNOID, newobj.Radius); } } else { if (thisObstacleObj.targetType.Value == TargetType.Unit) { //Since units position requires updating, we update using the CacheObject thisObstacleObj.Position = tmp_CachedObj.Position; Obstacles[tmp_CachedObj.RAGUID] = thisObstacleObj; } } } //cache it if (Objects.ContainsKey(tmp_CachedObj.RAGUID)) { Objects[tmp_CachedObj.RAGUID] = tmp_CachedObj; } else { Objects.Add(tmp_CachedObj.RAGUID, tmp_CachedObj); } } //End of Loop } // End of Framelock //Tally up unseen objects. var UnseenObjects = Objects.Keys.Where(O => !hashDoneThisRactor.Contains(O)).ToList(); if (UnseenObjects.Any()) { for (int i = 0; i < UnseenObjects.Count(); i++) { Objects[UnseenObjects[i]].LoopsUnseen++; } } //Trim our collection every 5th refresh. UpdateLoopCounter++; if (UpdateLoopCounter > 4) { UpdateLoopCounter = 0; //Now flag any objects not seen for 5 loops. Gold/Globe only 1 loop. foreach (var item in Objects.Values.Where(CO => (CO.LoopsUnseen >= 5 || //5 loops max.. (CO.targetType.HasValue && (CheckFlag(CO.targetType.Value, TargetType.Gold | TargetType.Globe)) && CO.LoopsUnseen > 0)))) //gold/globe only 1 loop! { item.NeedsRemoved = true; } } CheckForCacheRemoval(); _lastUpdatedCacheCollection = DateTime.Now; return(true); }
void Start() { actorMovement = this.GetComponent <ActorMovement>(); }
// Start is called before the first frame update void Awake() { ActorMovement = GetComponent <ActorMovement>(); ActorWeapon = GetComponent <ActorWeapon>(); }
//private Methods private void AddActorComponents() { m_Abilities = (gameObject.GetComponent<ActorAbilities>() == null ? gameObject.AddComponent<ActorAbilities>() : gameObject.GetComponent<ActorAbilities>()); m_Movement = (gameObject.GetComponent<ActorMovement>() == null ? gameObject.AddComponent<ActorMovement>() : gameObject.GetComponent<ActorMovement>()); m_Inventory = (gameObject.GetComponent<ActorInventory>() == null ? gameObject.AddComponent<ActorInventory>() : gameObject.GetComponent<ActorInventory>()); }