Ejemplo n.º 1
0
 public int GetObjectPriority(Appearances.ObjectInstance objectInstance)
 {
     Appearances.AppearanceType appearanceType = objectInstance.Type;
     if (appearanceType.IsGround)
     {
         return(0);
     }
     else if (appearanceType.IsGroundBorder)
     {
         return(1);
     }
     else if (appearanceType.IsBottom)
     {
         return(2);
     }
     else if (appearanceType.IsTop)
     {
         return(3);
     }
     else if (objectInstance.Id == Appearances.AppearanceInstance.Creature)
     {
         return(4);
     }
     else
     {
         return(5);
     }
 }
Ejemplo n.º 2
0
        protected void Init(Vector3Int absolutePosition, Appearances.AppearanceType appearanceType, int stackPosition)
        {
            m_AppearanceType = appearanceType;
            if (!m_AppearanceType)
            {
                throw new System.ArgumentException("LookActionImpl.LookActionImpl: Invalid type: " + appearanceType);
            }

            m_AbsolutePosition = absolutePosition;
            m_StackPosition    = stackPosition;
        }
Ejemplo n.º 3
0
        public void UpdateMiniMap()
        {
            if (!MiniMapDirty)
            {
                return;
            }

            MiniMapDirty = false;
            UpdateObjectsCache();
            MiniMapColor = 0;
            MiniMapCost  = Constants.PathCostMax;

            bool obstacle = ObjectsCount == 0 || !ObjectsRenderer[0].Type.IsGround; // no objects or no ground

            for (int i = 0; i < ObjectsCount; i++)
            {
                Appearances.AppearanceType appearanceType = ObjectsRenderer[i].Type;
                if (!obstacle)
                {
                    if (appearanceType.IsBlockPath || appearanceType.IsUnpassable)
                    {
                        obstacle = true;
                    }
                    else if (appearanceType.IsGround)
                    {
                        MiniMapCost = (int)System.Math.Min(Constants.PathCostMax, appearanceType.GroundSpeed);
                    }
                }

                if (appearanceType.IsAutomap)
                {
                    MiniMapColor = Colors.ARGBFrom8Bit(appearanceType.AutomapColor);
                }
            }

            if (obstacle)
            {
                MiniMapCost = Constants.PathCostObstacle;
            }
        }
Ejemplo n.º 4
0
        protected void Init(Vector3Int absolutePosition, Appearances.AppearanceType appearanceType, int stackPosOrData, Vector3Int targetAbsolute, Appearances.ObjectInstance targetObject, int targetStackPosOrData, UseActionTarget useTarget)
        {
            _appearanceType = appearanceType;
            if (!_appearanceType)
            {
                throw new System.ArgumentException("UseActionImpl.UseActionImpl: Invalid type: " + appearanceType);
            }

            _absolutePosition = absolutePosition;
            if (_absolutePosition.x == 65535 && _absolutePosition.y == 0)
            {
                _stackPosOrData = stackPosOrData;
            }
            else if (_absolutePosition.x == 65535 && _absolutePosition.y != 0)
            {
                _stackPosOrData = _absolutePosition.z;
            }
            else
            {
                _stackPosOrData = stackPosOrData;
            }

            _targetObject           = targetObject;
            _targetAbsolutePosition = targetAbsolute;
            if (_targetAbsolutePosition.x == 65535 && _targetAbsolutePosition.y == 0)
            {
                _targetStackPosOrData = targetStackPosOrData;
            }
            else if (_targetAbsolutePosition.x == 65535 && _targetAbsolutePosition.y != 0)
            {
                _targetStackPosOrData = _targetAbsolutePosition.z;
            }
            else
            {
                _targetStackPosOrData = targetStackPosOrData;
            }

            _useActionTarget = useTarget;
        }
Ejemplo n.º 5
0
        internal MoveActionImpl(UnityEngine.Vector3Int sourseAbsolute, Appearances.ObjectInstance @object, int stackPos, UnityEngine.Vector3Int destAbsolute, int moveAmount)
        {
            m_SourceAbsolute = sourseAbsolute;
            m_ObjectType     = @object.Type;
            m_StackPos       = stackPos;
            m_DestAbsolute   = destAbsolute;

            if (m_ObjectType.IsStackable)
            {
                m_ObjectAmount = (int)@object.Data;
            }
            else
            {
                m_ObjectAmount = 1;
            }

            if (moveAmount < MoveActionImpl.MoveAll || moveAmount > 100)
            {
                throw new System.ArgumentException("MoveActionImpl.MoveActionImpl: Invalid amount.");
            }

            m_MoveAmount = moveAmount;
        }
Ejemplo n.º 6
0
        protected void Init(Vector3Int absolutePosition, Appearances.AppearanceType type, int positionOrData, UseActionTarget useTarget)
        {
            m_AppearanceType = type;
            if (!m_AppearanceType)
            {
                throw new System.ArgumentException("UseActionImpl.UseActionImpl: Invalid type: " + type);
            }

            m_AbsolutePosition = absolutePosition;
            if (m_AbsolutePosition.x == 65535 && m_AbsolutePosition.y == 0)
            {
                m_PositionOrData = positionOrData;
            }
            else if (m_AbsolutePosition.x == 65535 && m_AbsolutePosition.y != 0)
            {
                m_PositionOrData = m_AbsolutePosition.z;
            }
            else
            {
                m_PositionOrData = positionOrData;
            }

            m_UseActionTarget = useTarget;
        }
Ejemplo n.º 7
0
 public UseActionImpl(Vector3Int absolutePosition, Appearances.AppearanceType appearanceType, int stackPosOrData, Vector3Int targetAbsolute, Appearances.ObjectInstance targetObject, int targetPosition, UseActionTarget useTarget)
 {
     Init(absolutePosition, appearanceType, stackPosOrData, targetAbsolute, targetObject, targetPosition, useTarget);
 }
Ejemplo n.º 8
0
        public void UpdateObjectsCache()
        {
            if (!CacheObjectsDirty)
            {
                return;
            }

            CacheObjectsDirty = false;

            int index = 0;

            if (ObjectsCount > 0)
            {
                // ground, borders, bottom items
                for (int i = 0; i < ObjectsCount; i++)
                {
                    var @object = ObjectsNetwork[i];
                    var type    = @object.Type;
                    if (type.IsGround || type.IsGroundBorder || type.IsBottom)
                    {
                        ObjectsRenderer[index++] = @object;
                    }
                }

                // common items
                for (int i = ObjectsCount - 1; i >= 0; i--)
                {
                    var @object = ObjectsNetwork[i];
                    var type    = @object.Type;
                    if (!type.IsGround && !type.IsGroundBorder && !type.IsBottom && !type.IsTop && !type.IsCreature)
                    {
                        ObjectsRenderer[index++] = @object;
                    }
                }

                // creatures
                for (int i = ObjectsCount - 1; i >= 0; i--)
                {
                    var @object = ObjectsNetwork[i];
                    var type    = @object.Type;
                    if (@object.IsCreature)
                    {
                        ObjectsRenderer[index++] = @object;
                    }
                }

                // top items
                for (int i = 0; i < ObjectsCount; i++)
                {
                    var @object = ObjectsNetwork[i];
                    var type    = @object.Type;
                    if (type.IsTop)
                    {
                        ObjectsRenderer[index++] = @object;
                    }
                }
            }

            while (index < Constants.MapSizeW)
            {
                ObjectsRenderer[index++] = null;
            }


            CacheTranslucent = false;
            CacheUnsight     = false;

            Appearances.ObjectInstance hangableObject = null;
            Appearances.AppearanceType hookType       = null;

            for (int i = 0; i < ObjectsCount; i++)
            {
                Appearances.AppearanceType tmpType = ObjectsNetwork[i].Type;
                CacheTranslucent = CacheTranslucent || tmpType.IsTranslucent;
                CacheUnsight     = CacheUnsight || tmpType.IsUnsight;

                if (tmpType.IsHangable)
                {
                    hangableObject = ObjectsNetwork[i];
                }
                else if (tmpType.IsHookEast || tmpType.IsHookSouth)
                {
                    hookType = tmpType;
                }
            }

            if (hangableObject)
            {
                if (!!hookType && hookType.IsHookEast)
                {
                    hangableObject.Hang = Appearances.AppearanceInstance.HookEast;
                }
                else if (hookType)
                {
                    hangableObject.Hang = Appearances.AppearanceInstance.HookSouth;
                }
                else
                {
                    hangableObject.Hang = 0;
                }
            }

            OpenTibiaUnity.WorldMapStorage.CacheUnsight = OpenTibiaUnity.WorldMapStorage.CacheUnsight && !CacheUnsight;
        }
Ejemplo n.º 9
0
 public ToggleWrapStateActionImpl(UnityEngine.Vector3Int absolute, Appearances.ObjectInstance @object, int stackPos)
 {
     _absolute       = absolute;
     _appearanceType = @object?.Type ?? throw new System.ArgumentNullException("ToggleWrapStateActionImpl.ToggleWrapStateActionImpl: Invalid object.");
     _stackPos       = stackPos;
 }
Ejemplo n.º 10
0
 public LookActionImpl(Vector3Int absolutePosition, Appearances.AppearanceType appearnceType, int stackPosition)
 {
     Init(absolutePosition, appearnceType, stackPosition);
 }
Ejemplo n.º 11
0
 public UseActionImpl(Vector3Int absolutePosition, Appearances.AppearanceType appearnceType, int positionOrData, UseActionTarget useTarget)
 {
     Init(absolutePosition, appearnceType, positionOrData, useTarget);
 }
Ejemplo n.º 12
0
        public void UpdateObjectsCache()
        {
            int index        = 0;
            int objectsCount = ObjectsCount;

            Appearances.AppearanceType tmpType = null;

            while (index < ObjectsCount && ((tmpType = ObjectsNetwork[index].Type).IsBank || tmpType.IsClip || tmpType.IsBottom))
            {
                ObjectsRenderer[index] = ObjectsNetwork[index];
                index++;
            }

            while (index < ObjectsCount)
            {
                ObjectsRenderer[index] = ObjectsNetwork[--objectsCount];
                index++;
            }

            while (index < Constants.MapSizeW)
            {
                ObjectsRenderer[index] = null;
                index++;
            }

            Appearances.ObjectInstance hangableObject = null;
            Appearances.AppearanceType hookType       = null;

            CacheTranslucent = false;
            CacheUnsight     = false;

            for (int i = 0; i < ObjectsCount; i++)
            {
                tmpType          = ObjectsNetwork[i].Type;
                CacheTranslucent = CacheTranslucent || tmpType.IsTranslucent;
                CacheUnsight     = CacheUnsight || tmpType.IsUnsight;

                if (tmpType.IsHangable)
                {
                    hangableObject = ObjectsNetwork[i];
                }
                else if (tmpType.IsHookEast || tmpType.IsHookSouth)
                {
                    hookType = tmpType;
                }
            }

            if (hangableObject)
            {
                if (!!tmpType && tmpType.IsHookEast)
                {
                    hangableObject.Hang = Appearances.AppearanceInstance.HookEast;
                }
                else if (tmpType)
                {
                    hangableObject.Hang = Appearances.AppearanceInstance.HookSouth;
                }
                else
                {
                    hangableObject.Hang = 0;
                }
            }
        }