Esempio n. 1
0
        public override bool UpdateData()
        {
            if (this.ref_Gizmo == null)
            {
                try
                {
                    this.ref_Gizmo = (DiaGizmo)base.ref_DiaObject;
                }
                catch
                {
                    Logger.Write(LogLevel.Cache, "Failure to convert obj to DiaItem!");


                    NeedsRemoved = true;
                    return(false);
                }
            }

            //Destructibles are not important unless they are close.. 40f is minimum range!
            //if ((this.targetType.Value == TargetType.Destructible || this.targetType.Value == TargetType.Barricade) && this.CentreDistance > 40f)
            //{
            //	if (Bot.Settings.Debug.FunkyLogFlags.HasFlag(LogLevel.Cache))
            //		Logger.Write(LogLevel.Cache, "Removing Destructible/Barricade {0} out of range!", InternalName);

            //	this.BlacklistLoops = 12;
            //	return false;
            //}

            if ((ObjectCache.CheckTargetTypeFlag(targetType.Value, TargetType.Interactables)) &&
                (!this.GizmoHasBeenUsed.HasValue || !this.GizmoHasBeenUsed.Value))
            {
                try
                {
                    if (base.Gizmotype.Value == GizmoType.PowerUp)
                    {
                        //this.HandleAsAvoidanceObject = true;
                        GizmoShrine gizmoShrine = this.ref_Gizmo as GizmoShrine;
                        this.GizmoHasBeenUsed = gizmoShrine.GizmoState == 1;
                    }
                    else if (base.Gizmotype.Value == GizmoType.HealingWell)
                    {
                        //this.HandleAsAvoidanceObject = true;
                        GizmoHealthwell gizmoHealthWell = this.ref_Gizmo as GizmoHealthwell;
                        this.GizmoHasBeenUsed = gizmoHealthWell.HasBeenOperated;
                    }
                    else if (base.Gizmotype.Value == GizmoType.Door)
                    {
                        GizmoDoor gizmoDoor = this.ref_Gizmo as GizmoDoor;
                        this.GizmoHasBeenUsed = gizmoDoor.HasBeenOperated;
                        //this.HandleAsAvoidanceObject = true;
                    }
                    else if (base.Gizmotype.Value == GizmoType.Chest)
                    {
                        //if (this.IsChestContainer)
                        //this.HandleAsAvoidanceObject = true;

                        GizmoLootContainer gizmoContainer = this.ref_Gizmo as GizmoLootContainer;
                        this.GizmoHasBeenUsed = gizmoContainer.IsOpen;
                    }
                    else if (Gizmotype.Value == GizmoType.Switch)
                    {
                        this.GizmoHasBeenUsed = this.ref_Gizmo.HasBeenOperated;
                    }
                }
                catch
                {
                    Logger.Write(LogLevel.Cache, "Safely handled getting attribute GizmoHasBeenOperated gizmo {0}", this.InternalName);
                    return(false);
                }

                //Blacklist used gizmos.
                //if (this.GizmoHasBeenUsed.HasValue && this.GizmoHasBeenUsed.Value)
                //{
                //	Logger.Write(LogLevel.Cache, "Removing {0} Has Been Used!", InternalName);

                //	this.BlacklistFlag = BlacklistType.Permanent;
                //	this.NeedsRemoved = true;
                //	return false;
                //}
            }

            //only shrines and "chests" would have set this value true.. so if no value than we set it false!
            //if (this.HandleAsAvoidanceObject) base.Obstacletype = ObstacleType.ServerObject;

            //PhysicsSNO -- (continiously updated) excluding shrines/interactables
            //if (ObjectCache.CheckTargetTypeFlag(targetType.Value, TargetType.Destructible | TargetType.Barricade | TargetType.Container))
            //{
            //	try
            //	{
            //		this.PhysicsSNO = base.ref_DiaObject.PhysicsSNO;
            //	}
            //	catch
            //	{
            //		Logger.Write(LogLevel.Cache, "Safely handled exception getting physics SNO for object " + this.InternalName + " [" + this.SNOID + "]");
            //		return false;
            //	}
            //}

            ////Update SNOAnim
            if (ObjectCache.CheckTargetTypeFlag(targetType.Value, TargetType.Destructible | TargetType.Barricade))
            {
                try
                {
                    UpdateAnimationState();
                    UpdateSNOAnim();
                }
                catch
                {
                    Logger.Write(LogLevel.Cache, "Exception occured attempting to update AnimState for object {0}", InternalName);
                    //AnimState=AnimationState.Invalid;
                }
            }

            if (ObjectCache.CheckTargetTypeFlag(targetType.Value, TargetType.Destructible | TargetType.Barricade | TargetType.Interactable))
            {
                if (this.IsBarricade.HasValue && this.IsBarricade.Value && !this.targetType.Value.HasFlag(TargetType.Barricade))
                {
                    //Logger.DBLog.InfoFormat("Changing Gizmo {0} target type from {1} to Barricade!", this.InternalName, this.targetType.Value.ToString());
                    //Change "barricade" attribute gizmos into barricade targeting!
                    this.targetType = TargetType.Barricade;
                }
            }

            if (this.Radius == 0f)
            {
                if (base.ActorSphereRadius.HasValue)
                {
                    this.Radius = base.ActorSphereRadius.Value;

                    this.Radius *= 0.80f;

                    if (this.Radius < 0f)
                    {
                        this.Radius = 0f;
                    }
                }
            }

            return(true);
        }
Esempio n. 2
0
        public override bool UpdateData()
        {
            if (ref_Gizmo == null)
            {
                try
                {
                    ref_Gizmo = (DiaGizmo)ref_DiaObject;
                }
                catch
                {
                    Logger.Write(LogLevel.Cache, "Failure to convert obj to DiaGizmo {0}", DebugStringSimple);


                    NeedsRemoved = true;
                    return(false);
                }
            }

            if (!IsStillValid())
            {
                //Logger.Write(LogLevel.Cache, "ref object not valid for {0}", DebugStringSimple);
                NeedsRemoved = true;
                return(false);
            }

            //Destructibles are not important unless they are close.. 40f is minimum range!
            //if ((this.targetType.Value == TargetType.Destructible || this.targetType.Value == TargetType.Barricade) && this.CentreDistance > 40f)
            //{
            //	if (FunkyBaseExtension.Settings.Debugging.FunkyLogFlags.HasFlag(LogLevel.Cache))
            //		Logger.Write(LogLevel.Cache, "Removing Destructible/Barricade {0} out of range!", InternalName);

            //	this.BlacklistLoops = 12;
            //	return false;
            //}

            if ((ObjectCache.CheckFlag(targetType.Value, TargetType.Interactables)) &&
                (!GizmoHasBeenUsed.HasValue || !GizmoHasBeenUsed.Value))
            {
                try
                {
                    bool updatedProperty = false;
                    if (Gizmotype.Value == GizmoType.PowerUp)
                    {
                        try
                        {
                            GizmoShrine gizmoShrine = ref_Gizmo as GizmoShrine;
                            GizmoHasBeenUsed = gizmoShrine.GizmoState == 1;
                            updatedProperty  = true;
                        }
                        catch (NullReferenceException ex)
                        {
                        }
                    }
                    else if (Gizmotype.Value == GizmoType.HealingWell)
                    {
                        try
                        {
                            GizmoHealthwell gizmoHealthWell = ref_Gizmo as GizmoHealthwell;
                            GizmoHasBeenUsed = gizmoHealthWell.HasBeenOperated;
                            updatedProperty  = true;
                        }
                        catch (NullReferenceException ex)
                        {
                        }
                    }
                    else if (Gizmotype.Value == GizmoType.Door)
                    {
                        try
                        {
                            GizmoDoor gizmoDoor = ref_Gizmo as GizmoDoor;
                            GizmoHasBeenUsed = gizmoDoor.HasBeenOperated;
                            updatedProperty  = true;
                        }
                        catch (NullReferenceException ex)
                        {
                        }
                    }
                    else if (Gizmotype.Value == GizmoType.Chest)
                    {
                        try
                        {
                            GizmoLootContainer gizmoContainer = ref_Gizmo as GizmoLootContainer;
                            GizmoHasBeenUsed = gizmoContainer.IsOpen;
                            updatedProperty  = true;
                        }
                        catch (NullReferenceException ex)
                        {
                        }
                    }

                    if (!updatedProperty)
                    {
                        GizmoHasBeenUsed = ref_Gizmo.HasBeenOperated;
                    }
                }
                catch
                {
                    Logger.Write(LogLevel.Cache, "Exception GizmoHasBeenOperated {0}", DebugStringSimple);
                    BlacklistFlag  = BlacklistType.Temporary;
                    BlacklistLoops = 100;
                    NeedsRemoved   = true;
                    return(false);
                }

                //Used Doors we remove from obstacle cache!
                if (Gizmotype.Value == GizmoType.Door && GizmoHasBeenUsed.Value && ObjectCache.Obstacles.ContainsKey(RAGUID))
                {
                    ObjectCache.Obstacles.Remove(RAGUID);
                    Obstacletype = ObstacleType.None;
                }
            }

            ////Update SNOAnim
            if (ObjectCache.CheckFlag(targetType.Value, TargetType.Destructible | TargetType.Barricade))
            {
                try
                {
                    UpdateAnimationState();
                    UpdateSNOAnim();
                }
                catch
                {
                    Logger.Write(LogLevel.Cache, "Exception occured attempting to update AnimState for object {0}", DebugStringSimple);
                    //AnimState=AnimationState.Invalid;
                }
            }


            //DisabledByScript Check
            if ((!GizmoDisabledByScript.HasValue || GizmoDisabledByScript.Value) && ObjectCache.CheckFlag(targetType.Value, TargetType.Interactables))
            {
                try
                {
                    GizmoDisabledByScript = ref_Gizmo.CommonData.GetAttribute <int>(ActorAttributeType.GizmoDisabledByScript) > 0;
                }
                catch
                {
                    Logger.Write(LogLevel.Cache, "Handled GizmoDisabledByScript for gizmo {0}", DebugStringSimple);
                    GizmoDisabledByScript = false;
                }
            }

            //Update Quest Monster?
            if (FunkyGame.Game.QuestMode)
            {
                try
                {
                    QuestMonster = ref_Gizmo.CommonData.GetAttribute <int>(ActorAttributeType.QuestMonster) != 0;
                }
                catch (Exception)
                {
                    QuestMonster = false;
                }
            }

            if (ObjectCache.CheckFlag(targetType.Value, TargetType.Destructible | TargetType.Barricade | TargetType.Interactable))
            {
                if (this.IsBarricade.HasValue && this.IsBarricade.Value && !this.targetType.Value.HasFlag(TargetType.Barricade))
                {
                    //Logger.DBLog.InfoFormat("Changing Gizmo {0} target type from {1} to Barricade!", this.InternalName, this.targetType.Value.ToString());
                    //Change "barricade" attribute gizmos into barricade targeting!
                    this.targetType = TargetType.Barricade;
                }
            }

            if (this.Radius == 0f)
            {
                if (base.ActorSphereRadius.HasValue)
                {
                    this.Radius = base.ActorSphereRadius.Value;

                    this.Radius *= 0.80f;

                    if (this.Radius < 0f)
                    {
                        this.Radius = 0f;
                    }
                }
            }

            return(true);
        }