Inheritance: MonoBehaviour, IDamageable
Example #1
0
        protected override void DropItems(EntityBase who, StructBlock block, List<ItemInventory> overridedLoot = null)
        {
            var world = block.World;
            var server = world.Server;

            overridedLoot = new List<ItemInventory>();
            // TODO: Fully grown drops 1 Wheat & 0-3 Seeds. 0 seeds - very rarely
            if (block.MetaData == 7)
            {
                ItemInventory item = ItemHelper.GetInstance((short) BlockData.Items.Wheat);
                item.Count = 1;
                overridedLoot.Add(item);
                sbyte seeds = (sbyte)server.Rand.Next(3);
                if (seeds > 0)
                {
                    item = ItemHelper.GetInstance((short) BlockData.Items.Seeds);
                    item.Count = seeds;
                    overridedLoot.Add(item);
                }
            }
            else if (block.MetaData >= 5)
            {
                var seeds = (sbyte)server.Rand.Next(3);
                if (seeds > 0)
                {
                    ItemInventory item = ItemHelper.GetInstance((short) BlockData.Items.Seeds);
                    item.Count = seeds;
                    overridedLoot.Add(item);
                }
            }
            base.DropItems(who, block, overridedLoot);
        }
Example #2
0
 public void SendDestroyEntity(EntityBase entity)
 {
     SendPacket(new DestroyEntityPacket
     {
         EntityId = entity.EntityId
     });
 }
Example #3
0
 protected override void DoDeath(EntityBase killedBy)
 {
     var killedByMob = killedBy as Mob;
     UniversalCoords coords = UniversalCoords.FromAbsWorld(Position.X, Position.Y, Position.Z);
     if (killedByMob != null && killedByMob.Type == MobType.Skeleton)
     {
         // If killed by a skeleton drop a music disc
         sbyte count = 1;
         short item;
         if (Server.Rand.Next(2) > 1)
         {
             item = (short)BlockData.Items.Disc13;
         }
         else
         {
             item = (short)BlockData.Items.DiscCat;
         }
         Server.DropItem(World, coords, new Interfaces.ItemStack(item, count, 0));
     }
     else
     {
         sbyte count = (sbyte)Server.Rand.Next(2);
         if (count > 0)
             Server.DropItem(World, coords, new Interfaces.ItemStack((short)BlockData.Items.Gunpowder, count, 0));
     }
     base.DoDeath(killedBy);
 }
        public override void Place(EntityBase entity, StructBlock block, StructBlock targetBlock, BlockFace face)
        {
            Player player = (entity as Player);
            if (player == null)
                return;
            if (face == BlockFace.Down)
                return;

            switch (face)
            {
                case BlockFace.Down: return;
                case BlockFace.Up: block.MetaData = (byte)MetaData.Torch.Standing;
                    break;
                case BlockFace.West: block.MetaData = (byte)MetaData.Torch.West;
                    break;
                case BlockFace.East: block.MetaData = (byte)MetaData.Torch.East;
                    break;
                case BlockFace.North: block.MetaData = (byte)MetaData.Torch.North;
                    break;
                case BlockFace.South: block.MetaData = (byte)MetaData.Torch.South;
                    break;
            }

            base.Place(entity, block, targetBlock, face);
        }
    void Awake() {
        mEnt = GetComponent<EntityBase>();
        mEnt.spawnCallback += OnEntitySpawn;
        mEnt.setStateCallback += OnEntityState;

        mTimeWarp = GetComponent<TimeWarp>();
    }
Example #6
0
 internal void SendEntity(EntityBase entity)
 {
     PacketHandler.SendPacket(new CreateEntityPacket
     {
         EntityId = entity.EntityId
     });
 }
Example #7
0
        public void SendCreateEntity(EntityBase entity)
        {
            Packet packet;
            if ((packet = Server.GetSpawnPacket(Server, entity)) != null)
            {
                if (packet is NamedEntitySpawnPacket)
                {
                    SendPacket(packet);
                    for (short i = 0; i < 5; i++)
                    {
                        SendPacket(new EntityEquipmentPacket
                        {
                            EntityId = entity.EntityId,
                            Slot = i,
                            ItemId = -1,
                            Durability = 0
                        });
                    }
                }
            }
            else if (entity is TileEntity)
            {

            }
            else
            {
                SendEntity(entity);
                SendTeleportTo(entity);
            }
        }
Example #8
0
 protected override void DoDeath(EntityBase killedBy)
 {
     sbyte count = (sbyte)Server.Rand.Next(2);
     if (count > 0)
         Server.DropItem(World, (int)this.Position.X, (int)this.Position.Y, (int)this.Position.Z, new Interfaces.ItemStack((short)Chraft.World.BlockData.Items.Pork, count, 0));
     // TODO: if death by fire drop cooked pork
 }
        public void ShouldInitWithDynamicData()
        {
            entity = new EntityBase(JsonConvert.DeserializeObject("{\"id\":1,\"name\":\"General\"}".Replace("'", "\"")));

            Assert.That(entity.GetDynamicProperty<int>("id"), Is.EqualTo(1));
            Assert.That(entity.GetDynamicProperty<string>("name"), Is.EqualTo("General"));
        }
Example #10
0
        public override void Place(EntityBase entity, StructBlock block, StructBlock targetBlock, BlockFace face)
        {
            // Load the blocks surrounding the position (NSEW) not diagonals
            BlockData.Blocks[] nsewBlocks = new BlockData.Blocks[4];
            UniversalCoords[] nsewBlockPositions = new UniversalCoords[4];
            int nsewCount = 0;
            block.Chunk.ForNSEW(block.Coords, (uc) =>
            {
                nsewBlocks[nsewCount] = (BlockData.Blocks)block.World.GetBlockId(uc);
                nsewBlockPositions[nsewCount] = uc;
                nsewCount++;
            });

            // Count chests in list
            if (nsewBlocks.Where((b) => b == BlockData.Blocks.Chest).Count() > 1)
            {
                // Cannot place next to two chests
                return;
            }

            for (int i = 0; i < 4; i++)
            {
                UniversalCoords p = nsewBlockPositions[i];
                if (nsewBlocks[i] == BlockData.Blocks.Chest && block.Chunk.IsNSEWTo(p, (byte)BlockData.Blocks.Chest))
                {
                    // Cannot place next to a double chest
                    return;
                }
            }
            base.Place(entity, block, targetBlock, face);
        }
Example #11
0
    // Update is called once per frame
    public override void AIUpdate()
    {
        // loop through every watchmen
        foreach (WatchmanEntity watchmanEntity in EntityManager.GetWatchmen()) {
            var tile = watchmanEntity.GetTile();
            var goblinLocation = Vector2.zero;

            if(tile.IsOnFire()) {
                // Die!
                // We're now dead.
                EntityManager.DestroyWatcham(watchmanEntity);
            } else if(IsGoblinAdjacent(tile.Position, out goblinLocation)) {
                // Attack a goblin!
                Messenger.Broadcast ("playBillyBeat");
                EntityManager.DestroyGoblin(EntityManager.GetGoblins().First (g => g.GetTile ().Position == goblinLocation));
            } else if(_chasingGoblin != null) {
                // Move closer to this goblin.
                _lastMovedOnTick = GetTicks();
                var path = _pathfinder.Navigate(tile.Position, _chasingGoblin.GetTile().Position);
                if(path.Length < 2) {
                    _chasingGoblin = null;
                } else {
                    EntityManager.MoveEntityTo(watchmanEntity, path[0]);
                }
            } else if(IsGoblinNearby(tile.Position, WatchmanSightRange, out _chasingGoblin)) { // Look for a goblin

            } else { // Wander...
                _lastMovedOnTick = GetTicks();
                var legalMoves = EntityManager.getLegalMoves(tile.Position);
                EntityManager.MoveEntityTo(watchmanEntity,
                                           legalMoves.OrderBy (x => System.Guid.NewGuid()).First ());
            }
        }
    }
Example #12
0
        protected override void DoDeath(EntityBase killedBy)
        {
            var killedByMob = killedBy as Mob;
            UniversalCoords coords = UniversalCoords.FromAbsWorld(Position.X, Position.Y, Position.Z);
            ItemInventory item;
            if (killedByMob != null && killedByMob.Type == MobType.Skeleton)
            {
                // If killed by a skeleton drop a music disc
                sbyte count = 1;

                if (Server.Rand.Next(2) > 1)
                    item = ItemHelper.GetInstance(BlockData.Items.Disc13);
                else
                    item = ItemHelper.GetInstance(BlockData.Items.DiscCat);
                item.Count = count;
                item.Durability = 0;
                Server.DropItem(World, coords, item);
            }
            else
            {
                sbyte count = (sbyte)Server.Rand.Next(2);
                if (count > 0)
                {
                    item = ItemHelper.GetInstance(BlockData.Items.Gunpowder);
                    item.Count = count;
                    Server.DropItem(World, coords, item);
                }
            }
            base.DoDeath(killedBy);
        }
    void Awake() {
        Renderer[] renders = GetComponentsInChildren<Renderer>(true);
        if(renders.Length > 0) {
            List<Renderer> validRenders = new List<Renderer>(renders.Length);
            foreach(Renderer r in renders) {
                if(r.sharedMaterial.HasProperty(modProperty)) {
                    validRenders.Add(r);
                }
            }

            mRenderers = new Renderer[validRenders.Count];
            mBlinkMats = new Material[validRenders.Count];

            for(int i = 0, max = mBlinkMats.Length; i < max; i++) {
                mRenderers[i] = validRenders[i];

                validRenders[i].sharedMaterial = mBlinkMats[i] = new Material(validRenders[i].sharedMaterial);
                mBlinkMats[i].SetFloat(modProperty, 0.0f);
            }
        }

        mEnt = GetComponent<EntityBase>();
        if(mEnt)
            mEnt.setBlinkCallback += OnEntityBlink;

        mStats = GetComponent<Stats>();
        if(mStats)
            mStats.changeHPCallback += OnStatsHPChange;

        tk2dBaseSprite[] sprites = GetComponentsInChildren<tk2dBaseSprite>(true);
        foreach(tk2dBaseSprite spr in sprites) {
            spr.SpriteChanged += OnSpriteChanged;
        }
    }
Example #14
0
 /// <summary>
 /// Initializes a new instance of the ValidationError class.
 /// </summary>
 /// <param name="errorMessage">The error message.</param>
 /// <param name="entity">The invalid entity.</param>
 /// <param name="property">The invalid property.</param>
 /// <param name="validationGroup">The validation group this error violates.</param>
 public ValidationError(string errorMessage, EntityBase entity, string propertyName, string validationGroup)
 {
     _errorMessage = errorMessage;
     _entity = entity;
     _propertyName = propertyName;
     _validationGroup = validationGroup;
 }
Example #15
0
 protected override void DropItems(EntityBase entity, StructBlock block)
 {
     LootTable = new List<ItemStack>();
     if (block.World.Server.Rand.Next(5) == 0)
         LootTable.Add(new ItemStack((short)BlockData.Blocks.Sapling, 1));
     base.DropItems(entity, block);
 }
        public override void Place(EntityBase entity, StructBlock block, StructBlock targetBlock, BlockFace targetSide)
        {
            Player player = entity as Player;
            if (player == null)
                return;

            // TODO: Bugged - should depend on the player's Yaw/Pitch
            switch (player.Client.FacingDirection(4))
            {
                case "N":
                    block.MetaData = (byte)MetaData.Stairs.South;
                    break;
                case "E":
                    block.MetaData = (byte)MetaData.Stairs.West;
                    break;
                case "S":
                    block.MetaData = (byte)MetaData.Stairs.North;
                    break;
                case "W":
                    block.MetaData = (byte)MetaData.Stairs.East;
                    break;
                default:
                    return;
            }
            base.Place(entity, block, targetBlock, targetSide);
        }
Example #17
0
        /// <summary>
        /// Returns client validation rule to help client validation libraries.
        /// </summary>
        /// <param name="propertyName">Property name reference to get the client validation rules.</param>
        /// <returns><see cref="ClientValidationRule"/></returns>
        public IEnumerable<ClientValidationRule> GetClientValidationData(string propertyName, EntityBase entity)
        {
            var predicates = Assertions
                .Where(a => a.AccessorMemberNames.Contains(propertyName) && a.WhenAssertion == null)
                    .SelectMany(a => a.BasePredicates)
                        .Where(p => p.ClienteValidationRule != null);

            foreach (var predicate in predicates)
            {
                predicate.ClienteValidationRule.ErrorMessage = string.Format(predicate.ValidationMessage, ValidationHelper.ResourceManager.GetString(propertyName));
                yield return predicate.ClienteValidationRule;
            }

            var assertionsWithWhen = Assertions
                .Where(a => a.AccessorMemberNames.Contains(propertyName) && a.WhenAssertion != null && a.BasePredicates.Any(p => p.ClienteValidationRule != null));

            foreach (var assertion in assertionsWithWhen)
            {
                if (assertion.WhenAssertion.Evaluate(entity, null))
                {
                    var predicatesWithWhen = assertion.BasePredicates.Where(p => p.ClienteValidationRule != null);

                    foreach (var predicate in predicatesWithWhen)
                    {
                        predicate.ClienteValidationRule.ErrorMessage = string.Format(predicate.ValidationMessage, ValidationHelper.ResourceManager.GetString(propertyName));
                        yield return predicate.ClienteValidationRule;
                    }
                }
            }
        }
Example #18
0
 public StreamFetcher(DataServiceContextWrapper context, EntityBase entity, string propertyName, Client.DataServiceStreamLink link)
 {
     _context = context;
     _entity = entity;
     _link = link;
     _propertyName = propertyName;
 }
Example #19
0
 public void Activate(Type type, EntityBase ent)
 {
     animSprite.Play(mTypeClips[(int)type]);
     mEnt = ent;
     mState = State.Activate;
     mCurDelay = 0;
 }
Example #20
0
 protected override void DoDeath(EntityBase killedBy)
 {
     sbyte count = (sbyte)Server.Rand.Next(3);
     if (count > 0)
         Server.DropItem(World, UniversalCoords.FromAbsWorld(Position.X, Position.Y, Position.Z), new Interfaces.ItemStack((short)Chraft.World.BlockData.Items.Grilled_Pork, count, 0));
     base.DoDeath(killedBy);
 }
 public void ComponentRemovedFromEntity(EntityBase entity, Type componentClass)
 {
     if (_components.ContainsKey(componentClass))
     {
         RemoveIfMatch(entity);
     }
 }
        public static bool EntityPropertyEquals(EntityBase entity1, EntityBase entity2, string property)
        {
            if (!entity1.GetType().Equals(entity2.GetType()))
            {
                throw new TechnicalException("Type:" + entity1.GetType() +" of Entity1 is not as same as Type:" + entity2.GetType() + " of Entity2");
            }

            object value1 = entity1;
            object value2 = entity2;
            string[] fieldArray = property.Split('.');
            foreach (string singleField in fieldArray)
            {
                if (value1 == null && value2 == null)
                {
                    return true;
                }

                PropertyInfo singlePropInfo = getPropertyInfo(value1, singleField);
                value1 = singlePropInfo.GetValue(value1, null);
                value2 = singlePropInfo.GetValue(value2, null);

                if ((value1 != null && value1.Equals(value2)) || value2 != null)
                {
                    return false;
                }
            }

            return true;
        }
Example #23
0
        protected override bool CanBePlacedOn(EntityBase who, StructBlock block, StructBlock targetBlock, BlockFace targetSide)
        {
            Chunk chunk = GetBlockChunk(block);
            if (chunk == null)
                return false;

            bool isDoubleChestNearby = false;
            int chestCount = 0;
            chunk.ForNSEW(block.Coords, uc =>
            {
                byte? nearbyBlockId = block.World.GetBlockId(uc);

                if (nearbyBlockId == null)
                    return;

                // Cannot place next to a double chest
                if (nearbyBlockId == (byte)BlockData.Blocks.Chest)
                {
                    chestCount++;
                     if (chunk.IsNSEWTo(uc, (byte)BlockData.Blocks.Chest))
                        isDoubleChestNearby = true;
                }
            });

            if (isDoubleChestNearby || chestCount > 1)
                return false;
            return base.CanBePlacedOn(who, block, targetBlock, targetSide);
        }
 public EntityDamageEventArgs(EntityBase entity, short damage, Client damagedBy, DamageCause cause)
     : base(entity)
 {
     Damage = damage;
     DamagedBy = damagedBy;
     Cause = cause;
 }
Example #25
0
        protected override bool CanBePlacedOn(EntityBase who, StructBlock block, StructBlock targetBlock, BlockFace targetSide)
        {
            if (targetBlock.Type == (byte)BlockData.Blocks.Reed && targetSide == BlockFace.Up)
                return true;

            if ((targetBlock.Type != (byte)BlockData.Blocks.Sand &&
                targetBlock.Type != (byte)BlockData.Blocks.Dirt &&
                targetBlock.Type != (byte)BlockData.Blocks.Grass &&
                targetBlock.Type != (byte)BlockData.Blocks.Soil) || targetSide != BlockFace.Up)
                return false;

            bool isWater = false;

            var chunk = GetBlockChunk(block);

            if (chunk == null)
                return false;

            chunk.ForNSEW(targetBlock.Coords,
                delegate(UniversalCoords uc)
                {
                    byte? blockId = block.World.GetBlockId(uc);
                    if (blockId != null && (blockId == (byte)BlockData.Blocks.Water || blockId == (byte)BlockData.Blocks.Still_Water))
                        isWater = true;
                });

            if (!isWater)
                return false;

            return base.CanBePlacedOn(who, block, targetBlock, targetSide);
        }
Example #26
0
        protected override bool CanBePlacedOn(EntityBase who, StructBlock block, StructBlock targetBlock, BlockFace targetSide)
        {
            // Cactus can only be placed on the top of the sand block or on the top of the other cactus
            if ((targetBlock.Type != (byte)BlockData.Blocks.Sand && targetBlock.Type != (byte)BlockData.Blocks.Cactus) || targetSide != BlockFace.Up)
                return false;
            // Can be placed only if North/West/East/South is clear
            bool isAir = true;

            Chunk chunk = GetBlockChunk(block);

            if (chunk == null)
                return false;

            chunk.ForNSEW(block.Coords,
                delegate(UniversalCoords uc)
                {
                    byte? blockId = block.World.GetBlockId(uc);
                    if (blockId == null || blockId != (byte)BlockData.Blocks.Air)
                        isAir = false;
                });
            if (!isAir)
                return false;

            return base.CanBePlacedOn(who, block, targetBlock, targetSide);
        }
 public FieldEntityReference(FieldType Type, FieldBase Base, EntityBase Entity, Db.IDbContext ctx = null)
     : base(Type, Base, Entity, ctx)
 {
     if (Type.DataType != DataType.EntityReference)
     {
         throw new ArgumentOutOfRangeException("Cannot create an entity reference field from a non-entity-reference type.");
     }
 }
Example #28
0
    protected override void OnProjRelease(EntityBase ent) {
        if(mLastClone == ent) {
            mLastClone = null;
            activeGO.SetActive(false);
        }

        base.OnProjRelease(ent);
    }
Example #29
0
 public override void NotifyDestroy(EntityBase entity, StructBlock sourceBlock, StructBlock targetBlock)
 {
     if ((targetBlock.Coords.WorldY - sourceBlock.Coords.WorldY) == 1 &&
         targetBlock.Coords.WorldX == sourceBlock.Coords.WorldX &&
         targetBlock.Coords.WorldZ == sourceBlock.Coords.WorldZ)
         Destroy(targetBlock);
     base.NotifyDestroy(entity, sourceBlock, targetBlock);
 }
 public FieldLazyBinary(FieldType Type, FieldBase Base, EntityBase Entity, Db.IDbContext ctx = null)
     : base(Type, Base, Entity, ctx)
 {
     if (Type.DataType != DataType.Binary)
     {
         throw new ArgumentOutOfRangeException("Cannot create a binary field from a non-binary type.");
     }
 }
Example #31
0
 public void CreateCommandTest()
 {
     Assert.IsNotNull(EntityBase.CreateCommand());
 }
Example #32
0
 void OnCreatePickle(EntityBase pickle)
 {
 }
Example #33
0
 public AIMove1031(EntityBase entity, float flytime = -1f) : base(entity)
 {
     this.peradd  = 1f;
     this.maxadd  = 50f;
     this.flytime = flytime;
 }
Example #34
0
 public void Enter(EntityBase entity, params object[] args)
 {
     entity.currentAniState = AniState.Attack;
     entity.curSkillData    = ResSvc.Instance.GetSkillCfg((int)args[0]);
     //PECommon.Log("Enter Attack");
 }
Example #35
0
 public abstract void Record(int frame, EntityBase entity);
Example #36
0
        /// <summary>
        /// Updates a Contract_Divide into the data store based on the primitive properties. This can be used as the
        /// update method for an ObjectDataSource.
        /// </summary>
        /// <param name="iD">iD</param>
        /// <param name="contractID">contractID</param>
        /// <param name="rentName">rentName</param>
        /// <param name="writeDate">writeDate</param>
        /// <param name="startTime">startTime</param>
        /// <param name="endTime">endTime</param>
        /// <param name="divideType">divideType</param>
        /// <param name="remark">remark</param>
        /// <param name="sellCost">sellCost</param>
        /// <param name="addTime">addTime</param>
        /// <param name="chargeStatus">chargeStatus</param>
        /// <param name="chargeID">chargeID</param>
        /// <param name="helper">helper</param>
        internal static void UpdateContract_Divide(int @iD, int @contractID, string @rentName, DateTime @writeDate, DateTime @startTime, DateTime @endTime, string @divideType, string @remark, decimal @sellCost, DateTime @addTime, int @chargeStatus, int @chargeID, SqlHelper @helper)
        {
            string commandText = @"
DECLARE @table TABLE(
	[ID] int,
	[ContractID] int,
	[RentName] nvarchar(100),
	[WriteDate] datetime,
	[StartTime] datetime,
	[EndTime] datetime,
	[DivideType] nvarchar(100),
	[Remark] ntext,
	[SellCost] decimal(18, 2),
	[AddTime] datetime,
	[ChargeStatus] int,
	[ChargeID] int
);

UPDATE [dbo].[Contract_Divide] SET 
	[Contract_Divide].[ContractID] = @ContractID,
	[Contract_Divide].[RentName] = @RentName,
	[Contract_Divide].[WriteDate] = @WriteDate,
	[Contract_Divide].[StartTime] = @StartTime,
	[Contract_Divide].[EndTime] = @EndTime,
	[Contract_Divide].[DivideType] = @DivideType,
	[Contract_Divide].[Remark] = @Remark,
	[Contract_Divide].[SellCost] = @SellCost,
	[Contract_Divide].[AddTime] = @AddTime,
	[Contract_Divide].[ChargeStatus] = @ChargeStatus,
	[Contract_Divide].[ChargeID] = @ChargeID 
output 
	INSERTED.[ID],
	INSERTED.[ContractID],
	INSERTED.[RentName],
	INSERTED.[WriteDate],
	INSERTED.[StartTime],
	INSERTED.[EndTime],
	INSERTED.[DivideType],
	INSERTED.[Remark],
	INSERTED.[SellCost],
	INSERTED.[AddTime],
	INSERTED.[ChargeStatus],
	INSERTED.[ChargeID]
into @table
WHERE 
	[Contract_Divide].[ID] = @ID

SELECT 
	[ID],
	[ContractID],
	[RentName],
	[WriteDate],
	[StartTime],
	[EndTime],
	[DivideType],
	[Remark],
	[SellCost],
	[AddTime],
	[ChargeStatus],
	[ChargeID] 
FROM @table;
";

            System.Collections.Generic.List <SqlParameter> parameters = new System.Collections.Generic.List <SqlParameter>();
            parameters.Add(new SqlParameter("@ID", EntityBase.GetDatabaseValue(@iD)));
            parameters.Add(new SqlParameter("@ContractID", EntityBase.GetDatabaseValue(@contractID)));
            parameters.Add(new SqlParameter("@RentName", EntityBase.GetDatabaseValue(@rentName)));
            parameters.Add(new SqlParameter("@WriteDate", EntityBase.GetDatabaseValue(@writeDate)));
            parameters.Add(new SqlParameter("@StartTime", EntityBase.GetDatabaseValue(@startTime)));
            parameters.Add(new SqlParameter("@EndTime", EntityBase.GetDatabaseValue(@endTime)));
            parameters.Add(new SqlParameter("@DivideType", EntityBase.GetDatabaseValue(@divideType)));
            parameters.Add(new SqlParameter("@Remark", EntityBase.GetDatabaseValue(@remark)));
            parameters.Add(new SqlParameter("@SellCost", EntityBase.GetDatabaseValue(@sellCost)));
            parameters.Add(new SqlParameter("@AddTime", EntityBase.GetDatabaseValue(@addTime)));
            parameters.Add(new SqlParameter("@ChargeStatus", EntityBase.GetDatabaseValue(@chargeStatus)));
            parameters.Add(new SqlParameter("@ChargeID", EntityBase.GetDatabaseValue(@chargeID)));

            @helper.Execute(commandText, CommandType.Text, parameters);
        }
Example #37
0
        public IList <MenuEntity> GetMenuItems(int RoleId)
        {
            var parameters = new object[] { RoleId };

            return(EntityBase.FillCollection <MenuEntity>("GetMenuByRole", parameters));
        }
    bool IsGoblinNearby(Vector2 location, int distance, out EntityBase goblin)
    {
        goblin = EntityManager.GetClosestGoblin(location, distance);

        return(goblin != null);
    }
Example #39
0
 public void PersistDeletedItem(EntityBase item)
 {
     this.PersistDeletedItem((T)item);
 }
Example #40
0
 public void PersistNewItem(EntityBase item)
 {
     this.PersistNewItem((T)item);
 }
Example #41
0
        /// <summary>
        /// Insert a CustomerService_Material into the data store based on the primitive properties. This can be used as the
        /// insert method for an ObjectDataSource.
        /// </summary>
        /// <param name="customerServiceID">customerServiceID</param>
        /// <param name="materalName">materalName</param>
        /// <param name="totalCount">totalCount</param>
        /// <param name="unitPrice">unitPrice</param>
        /// <param name="totalCost">totalCost</param>
        /// <param name="gUID">gUID</param>
        /// <param name="addTime">addTime</param>
        /// <param name="helper">helper</param>
        internal static void InsertCustomerService_Material(int @customerServiceID, string @materalName, int @totalCount, decimal @unitPrice, decimal @totalCost, string @gUID, DateTime @addTime, SqlHelper @helper)
        {
            string commandText = @"
DECLARE @table TABLE(
	[ID] int,
	[CustomerServiceID] int,
	[MateralName] nvarchar(100),
	[TotalCount] int,
	[UnitPrice] decimal(18, 2),
	[TotalCost] decimal(18, 2),
	[GUID] nvarchar(500),
	[AddTime] datetime
);

INSERT INTO [dbo].[CustomerService_Material] (
	[CustomerService_Material].[CustomerServiceID],
	[CustomerService_Material].[MateralName],
	[CustomerService_Material].[TotalCount],
	[CustomerService_Material].[UnitPrice],
	[CustomerService_Material].[TotalCost],
	[CustomerService_Material].[GUID],
	[CustomerService_Material].[AddTime]
) 
output 
	INSERTED.[ID],
	INSERTED.[CustomerServiceID],
	INSERTED.[MateralName],
	INSERTED.[TotalCount],
	INSERTED.[UnitPrice],
	INSERTED.[TotalCost],
	INSERTED.[GUID],
	INSERTED.[AddTime]
into @table
VALUES ( 
	@CustomerServiceID,
	@MateralName,
	@TotalCount,
	@UnitPrice,
	@TotalCost,
	@GUID,
	@AddTime 
); 

SELECT 
	[ID],
	[CustomerServiceID],
	[MateralName],
	[TotalCount],
	[UnitPrice],
	[TotalCost],
	[GUID],
	[AddTime] 
FROM @table;
";

            System.Collections.Generic.List <SqlParameter> parameters = new System.Collections.Generic.List <SqlParameter>();
            parameters.Add(new SqlParameter("@CustomerServiceID", EntityBase.GetDatabaseValue(@customerServiceID)));
            parameters.Add(new SqlParameter("@MateralName", EntityBase.GetDatabaseValue(@materalName)));
            parameters.Add(new SqlParameter("@TotalCount", EntityBase.GetDatabaseValue(@totalCount)));
            parameters.Add(new SqlParameter("@UnitPrice", EntityBase.GetDatabaseValue(@unitPrice)));
            parameters.Add(new SqlParameter("@TotalCost", EntityBase.GetDatabaseValue(@totalCost)));
            parameters.Add(new SqlParameter("@GUID", EntityBase.GetDatabaseValue(@gUID)));
            parameters.Add(new SqlParameter("@AddTime", EntityBase.GetDatabaseValue(@addTime)));

            @helper.Execute(commandText, CommandType.Text, parameters);
        }
Example #42
0
 public void Enter(EntityBase entity, params object[] args)
 {
     entity.CurrentAniState = AniState.Born;
 }
Example #43
0
 public void Enter(EntityBase entity, params object[] args)
 {
     entity.currentAniState = AniState.Move;
     //PECommon.Log("Enter StateMove");
 }
Example #44
0
 public AIMove1042(EntityBase entity, int range) : base(entity)
 {
     this.perdis = 1.5f;
     this.range  = range;
 }
Example #45
0
        public override void Fertilize(EntityBase entity, StructBlock block)
        {
            Chunk chunk = GetBlockChunk(block);

            if (chunk == null)
            {
                return;
            }

            BlockData.Blocks blockBelow = chunk.GetType(block.Coords.BlockX, block.Coords.BlockY - 1,
                                                        block.Coords.BlockZ);

            if (blockBelow != BlockData.Blocks.Dirt && blockBelow != BlockData.Blocks.Grass && blockBelow != BlockData.Blocks.Mycelium)
            {
                return;
            }

            int stemHeight = block.World.Server.Rand.Next(3) + 4;
            int capY       = block.Coords.WorldY + stemHeight + 1;

            if (capY > 127)
            {
                return;
            }

            for (int dY = block.Coords.WorldY + 1; dY < capY - 1; dY++)
            {
                BlockData.Blocks blockUp = chunk.GetType(block.Coords.BlockX, dY, block.Coords.BlockZ);

                if (blockUp != BlockData.Blocks.Air && blockUp != BlockData.Blocks.Leaves)
                {
                    return;
                }
            }

            int  absdX, absdZ;
            byte?blockId;

            for (int dX = -3; dX < 4; dX++)
            {
                for (int dZ = -3; dZ < 4; dZ++)
                {
                    absdX = Math.Abs(dX);
                    absdZ = Math.Abs(dZ);
                    if (absdX == 3 && absdZ == 3)
                    {
                        continue;
                    }
                    blockId = block.World.GetBlockId(block.Coords.WorldX + dX, capY, block.Coords.WorldZ + dZ);
                    if (blockId == null || (blockId != (byte)BlockData.Blocks.Air && blockId != (byte)BlockData.Blocks.Leaves))
                    {
                        return;
                    }
                }
            }


            byte metaData = (byte)MetaData.HugeMushroom.NorthWeastSouthEast;

            for (int dY = block.Coords.WorldY; dY < capY; dY++)
            {
                if (chunk.GetType(block.Coords.BlockX, dY, block.Coords.BlockZ) != BlockData.Blocks.Leaves)
                {
                    chunk.SetBlockAndData(block.Coords.BlockX, dY, block.Coords.BlockZ, (byte)BlockData.Blocks.BrownMushroomCap, metaData);
                }
            }

            for (int dX = -3; dX < 4; dX++)
            {
                for (int dZ = -3; dZ < 4; dZ++)
                {
                    Chunk currentChunk = block.World.GetChunkFromWorld(block.Coords.WorldX + dX, block.Coords.WorldZ + dZ) as Chunk;
                    if (currentChunk == null)
                    {
                        continue;
                    }

                    absdX = Math.Abs(dX);
                    absdZ = Math.Abs(dZ);
                    if (absdX == 3 && absdZ == 3)
                    {
                        continue;
                    }

                    BlockData.Blocks nearbyBlockId = currentChunk.GetType(block.Coords.BlockX + dX, capY, block.Coords.BlockZ + dZ);
                    if (nearbyBlockId == BlockData.Blocks.Leaves)
                    {
                        continue;
                    }

                    if (absdX < 3 && absdZ < 3)
                    {
                        metaData = (byte)MetaData.HugeMushroom.Top;
                    }
                    else if ((dX == -3 && dZ == -2) || (dZ == -3 && dX == -2))
                    {
                        metaData = (byte)MetaData.HugeMushroom.TopNorthWest;
                    }
                    else if ((dX == -3 && dZ == 2) || (dZ == 3 && dX == -2))
                    {
                        metaData = (byte)MetaData.HugeMushroom.TopSouthWest;
                    }
                    else if ((dX == 3 && dZ == -2) || (dZ == -3 && dX == 2))
                    {
                        metaData = (byte)MetaData.HugeMushroom.TopNorthEast;
                    }
                    else if ((dX == 3 && dZ == 2) || (dZ == 3 && dX == 2))
                    {
                        metaData = (byte)MetaData.HugeMushroom.TopSouthEast;
                    }
                    else if (dX == -3 && absdZ < 2)
                    {
                        metaData = (byte)MetaData.HugeMushroom.TopWest;
                    }
                    else if (dX == 3 && absdZ < 2)
                    {
                        metaData = (byte)MetaData.HugeMushroom.TopEast;
                    }
                    else if (dZ == -3 && absdX < 2)
                    {
                        metaData = (byte)MetaData.HugeMushroom.TopNorth;
                    }
                    else if (dZ == 3 && absdX < 2)
                    {
                        metaData = (byte)MetaData.HugeMushroom.TopSouth;
                    }

                    currentChunk.SetBlockAndData(block.Coords.BlockX + dX, capY, block.Coords.BlockZ + dZ, (byte)BlockData.Blocks.BrownMushroomCap, metaData);
                }
            }
        }
Example #46
0
 public void Enter(EntityBase entity, params object[] objs)
 {
     entity.currentAnimState = AniState.Die;
 }
Example #47
0
 public MES_BD_GX(EntityBase entityBase)
     : this()
 {
     this.Data = entityBase.Data;
 }
Example #48
0
 public void Exit(EntityBase entity, params object[] objs)
 {
 }
Example #49
0
        /// <summary>
        /// Updates a Mall_BusinessDiscountRequest into the data store based on the primitive properties. This can be used as the
        /// update method for an ObjectDataSource.
        /// </summary>
        /// <param name="iD">iD</param>
        /// <param name="businessID">businessID</param>
        /// <param name="userID">userID</param>
        /// <param name="requestContent">requestContent</param>
        /// <param name="addTime">addTime</param>
        /// <param name="addUserMan">addUserMan</param>
        /// <param name="status">status</param>
        /// <param name="approveUserMan">approveUserMan</param>
        /// <param name="approveTime">approveTime</param>
        /// <param name="approveRemark">approveRemark</param>
        /// <param name="startTime">startTime</param>
        /// <param name="endTime">endTime</param>
        /// <param name="isActive">isActive</param>
        /// <param name="helper">helper</param>
        internal static void UpdateMall_BusinessDiscountRequest(int @iD, int @businessID, int @userID, string @requestContent, DateTime @addTime, string @addUserMan, int @status, string @approveUserMan, DateTime @approveTime, string @approveRemark, DateTime @startTime, DateTime @endTime, bool @isActive, SqlHelper @helper)
        {
            string commandText = @"
DECLARE @table TABLE(
	[ID] int,
	[BusinessID] int,
	[UserID] int,
	[RequestContent] nvarchar(1000),
	[AddTime] datetime,
	[AddUserMan] nvarchar(100),
	[Status] int,
	[ApproveUserMan] nvarchar(200),
	[ApproveTime] datetime,
	[ApproveRemark] nvarchar(1000),
	[StartTime] datetime,
	[EndTime] datetime,
	[IsActive] bit
);

UPDATE [dbo].[Mall_BusinessDiscountRequest] SET 
	[Mall_BusinessDiscountRequest].[BusinessID] = @BusinessID,
	[Mall_BusinessDiscountRequest].[UserID] = @UserID,
	[Mall_BusinessDiscountRequest].[RequestContent] = @RequestContent,
	[Mall_BusinessDiscountRequest].[AddTime] = @AddTime,
	[Mall_BusinessDiscountRequest].[AddUserMan] = @AddUserMan,
	[Mall_BusinessDiscountRequest].[Status] = @Status,
	[Mall_BusinessDiscountRequest].[ApproveUserMan] = @ApproveUserMan,
	[Mall_BusinessDiscountRequest].[ApproveTime] = @ApproveTime,
	[Mall_BusinessDiscountRequest].[ApproveRemark] = @ApproveRemark,
	[Mall_BusinessDiscountRequest].[StartTime] = @StartTime,
	[Mall_BusinessDiscountRequest].[EndTime] = @EndTime,
	[Mall_BusinessDiscountRequest].[IsActive] = @IsActive 
output 
	INSERTED.[ID],
	INSERTED.[BusinessID],
	INSERTED.[UserID],
	INSERTED.[RequestContent],
	INSERTED.[AddTime],
	INSERTED.[AddUserMan],
	INSERTED.[Status],
	INSERTED.[ApproveUserMan],
	INSERTED.[ApproveTime],
	INSERTED.[ApproveRemark],
	INSERTED.[StartTime],
	INSERTED.[EndTime],
	INSERTED.[IsActive]
into @table
WHERE 
	[Mall_BusinessDiscountRequest].[ID] = @ID

SELECT 
	[ID],
	[BusinessID],
	[UserID],
	[RequestContent],
	[AddTime],
	[AddUserMan],
	[Status],
	[ApproveUserMan],
	[ApproveTime],
	[ApproveRemark],
	[StartTime],
	[EndTime],
	[IsActive] 
FROM @table;
";

            System.Collections.Generic.List <SqlParameter> parameters = new System.Collections.Generic.List <SqlParameter>();
            parameters.Add(new SqlParameter("@ID", EntityBase.GetDatabaseValue(@iD)));
            parameters.Add(new SqlParameter("@BusinessID", EntityBase.GetDatabaseValue(@businessID)));
            parameters.Add(new SqlParameter("@UserID", EntityBase.GetDatabaseValue(@userID)));
            parameters.Add(new SqlParameter("@RequestContent", EntityBase.GetDatabaseValue(@requestContent)));
            parameters.Add(new SqlParameter("@AddTime", EntityBase.GetDatabaseValue(@addTime)));
            parameters.Add(new SqlParameter("@AddUserMan", EntityBase.GetDatabaseValue(@addUserMan)));
            parameters.Add(new SqlParameter("@Status", EntityBase.GetDatabaseValue(@status)));
            parameters.Add(new SqlParameter("@ApproveUserMan", EntityBase.GetDatabaseValue(@approveUserMan)));
            parameters.Add(new SqlParameter("@ApproveTime", EntityBase.GetDatabaseValue(@approveTime)));
            parameters.Add(new SqlParameter("@ApproveRemark", EntityBase.GetDatabaseValue(@approveRemark)));
            parameters.Add(new SqlParameter("@StartTime", EntityBase.GetDatabaseValue(@startTime)));
            parameters.Add(new SqlParameter("@EndTime", EntityBase.GetDatabaseValue(@endTime)));
            parameters.Add(new SqlParameter("@IsActive", @isActive));

            @helper.Execute(commandText, CommandType.Text, parameters);
        }
Example #50
0
 public SearchResult Search(BLLContext context, Paging paging, EntityBase queryEntity)
 {
     return(dal.Search(context, paging, queryEntity));
 }
Example #51
0
 public void Exit(EntityBase entity, params object[] args)
 {
     entity.ExitCurAtkState();
     //PECommon.Log("Exit Attack");
 }
Example #52
0
        public List <T> LoadAll <T>() where T : EntityBase
        {
            if (!_compiled)
            {
                Compile();
            }

            ObjectDescription od = ClassFactory.GetObjectDescription(ReflectedType, _ps);


            if (od.IsAggregated)
            {
                throw new Exception("Cannot load aggregated types");
            }
            //return _ps.GetEntities(ReflectedType);

            List <T> list = new List <T>(UnderlyngDataSet.Tables[Mapper.TableName].Rows.Count);

            foreach (DataRow row in UnderlyngDataSet.Tables[Mapper.TableName].Rows)
            {
                if (row.RowState == DataRowState.Deleted)
                {
                    continue;
                }
                TableAttribute tableAttr = od.DbTableAttribute;
                if (tableAttr != null && tableAttr.Conditional)
                {
                    if (!tableAttr.CheckConditions(row))
                    {
                        continue;
                    }
                }

                T entity = od.CreateObject() as T;
                entity.BeginLoad();
                entity.CreatorPs        = this._ps;
                entity[od.IdField.Name] = row[Mapper[od.IdField.Name]];
                entity.SourceRow        = row;

                EntityCache cache = _ps.Caches[entity.GetType()];
                if (!cache.Contains(entity.ID))
                {
                    cache.Add(entity);
                }
                else
                {
                    //throw new Exception();
                    entity = (T)cache[entity.ID];
                }

                list.Add(entity);
            }
            foreach (T entity in list)
            {
                ObjectDescription ods = ClassFactory.GetObjectDescription(entity.GetType(), _ps);
                if (!ods.IsWrapped)
                {
                    ReloadEntity(entity);                    // this is a reference type.... (I hate them!!!!)
                }
                else
                {
                    EntityBase e = null;                    //(EntityBase)ClassFactory.CreateObject(od.WrappedClass, _ps);//( entity as IWrapObject ).WrappedObject;
                    //e.BeginLoad();
                    //e.Ps = _ps;
                    //e.SourceRow = entity.SourceRow;
                    e = _ps.GetEntityById(od.WrappedClass, entity.ID);
                    (entity as IWrapObject).WrappedObject = e;
                    e.EndLoad();
                    //ReloadEntity(e);
                    //( entity as IWrapObject ).WrappedObject = e;
                }
                entity.EndLoad();
            }
            return(list);
        }
Example #53
0
    void OnPlayerReconnect(EntityBase entity, params object[] objs)
    {
        ConnectionComponent comp = entity.GetComp <ConnectionComponent>();

        comp.m_isWaitPushReconnect = true;
    }
Example #54
0
 protected virtual void OnProjRelease(EntityBase ent)
 {
     mCurProjCount        = Mathf.Clamp(mCurProjCount - 1, 0, projMax);
     ent.releaseCallback -= OnProjRelease;
 }
Example #55
0
        protected override IDbDataParameter[] CreateSelectParameters(EntityBase anEntity)
        {
            M_COMPLITION_DETAIL     theEntity = (M_COMPLITION_DETAIL)anEntity;
            List <IDbDataParameter> cmdParams = new List <IDbDataParameter>();

            if (!string.IsNullOrEmpty(theEntity.PK_ID))
            {
                cmdParams.Add(DataAccessFactory.CreateDataParameter("VAR_PK_ID", theEntity.PK_ID));
            }

            if (!string.IsNullOrEmpty(theEntity.M_COMPLITION_ID))
            {
                cmdParams.Add(DataAccessFactory.CreateDataParameter("VAR_M_COMPLITION_ID", theEntity.M_COMPLITION_ID));
            }

            if (!string.IsNullOrEmpty(theEntity.SNO))
            {
                cmdParams.Add(DataAccessFactory.CreateDataParameter("VAR_SNO", theEntity.SNO));
            }

            if (!string.IsNullOrEmpty(theEntity.PARTS_LABOUR))
            {
                cmdParams.Add(DataAccessFactory.CreateDataParameter("VAR_PARTS_LABOUR", theEntity.PARTS_LABOUR));
            }

            if (!string.IsNullOrEmpty(theEntity.PARTS_LABOUR_ID))
            {
                cmdParams.Add(DataAccessFactory.CreateDataParameter("VAR_PARTS_LABOUR_ID", theEntity.PARTS_LABOUR_ID));
            }

            if (!string.IsNullOrEmpty(theEntity.QTY))
            {
                cmdParams.Add(DataAccessFactory.CreateDataParameter("VAR_QTY", theEntity.QTY));
            }

            if (!string.IsNullOrEmpty(theEntity.RATE_PER_UNIT))
            {
                cmdParams.Add(DataAccessFactory.CreateDataParameter("VAR_RATE_PER_UNIT", theEntity.RATE_PER_UNIT));
            }

            if (!string.IsNullOrEmpty(theEntity.TOTAL_COST))
            {
                cmdParams.Add(DataAccessFactory.CreateDataParameter("VAR_TOTAL_COST", theEntity.TOTAL_COST));
            }

            if (!string.IsNullOrEmpty(theEntity.SUPPLIER_ID))
            {
                cmdParams.Add(DataAccessFactory.CreateDataParameter("VAR_SUPPLIER_ID", theEntity.SUPPLIER_ID));
            }

            if (!string.IsNullOrEmpty(theEntity.SUPPLY_DATE))
            {
                cmdParams.Add(DataAccessFactory.CreateDataParameter("VAR_SUPPLY_DATE", theEntity.SUPPLY_DATE));
            }

            if (!string.IsNullOrEmpty(theEntity.INVOICE_NO))
            {
                cmdParams.Add(DataAccessFactory.CreateDataParameter("VAR_INVOICE_NO", theEntity.INVOICE_NO));
            }

            if (!string.IsNullOrEmpty(theEntity.REMARKS))
            {
                cmdParams.Add(DataAccessFactory.CreateDataParameter("VAR_REMARKS", theEntity.REMARKS));
            }

            cmdParams.Add(DataAccessFactory.CreateDataParameter("Result", ""));

            return(cmdParams.ToArray());
        }
Example #56
0
        /// <summary>
        /// Gets a parameter for the IsActive property of an entity.
        /// </summary>
        /// <param name="entity">Entity to be updated.</param>
        /// <returns>SqlParameter for the IsActive property.</returns>
        protected virtual SqlParameter GetIsActiveParameter(EntityBase entity)
        {
            SqlParameter parameter = this.DataManager.GetParameter("isActive", DbType.Boolean, DataConverter.ConvertToDb(entity.IsActive));

            return(parameter);
        }
Example #57
0
 public void Process(EntityBase entity, params object[] args)
 {
     //PECommon.Log("Process StateMove");
     entity.SetBlend(Constants.BlendMove);
 }
Example #58
0
 public void Exit(EntityBase entity, params object[] args)
 {
     //PECommon.Log("Exit StateMove");
 }
Example #59
0
        /// <summary>
        /// Updates a Mall_BalanceRule into the data store based on the primitive properties. This can be used as the
        /// update method for an ObjectDataSource.
        /// </summary>
        /// <param name="iD">iD</param>
        /// <param name="title">title</param>
        /// <param name="backPercent">backPercent</param>
        /// <param name="backAmount">backAmount</param>
        /// <param name="remark">remark</param>
        /// <param name="addTime">addTime</param>
        /// <param name="addUserName">addUserName</param>
        /// <param name="isActive">isActive</param>
        /// <param name="backBalanceType">backBalanceType</param>
        /// <param name="ruleType">ruleType</param>
        /// <param name="helper">helper</param>
        internal static void UpdateMall_BalanceRule(int @iD, string @title, decimal @backPercent, decimal @backAmount, string @remark, DateTime @addTime, string @addUserName, bool @isActive, int @backBalanceType, int @ruleType, SqlHelper @helper)
        {
            string commandText = @"
DECLARE @table TABLE(
	[ID] int,
	[Title] nvarchar(200),
	[BackPercent] decimal(18, 2),
	[BackAmount] decimal(18, 2),
	[Remark] ntext,
	[AddTime] datetime,
	[AddUserName] nvarchar(200),
	[IsActive] bit,
	[BackBalanceType] int,
	[RuleType] int
);

UPDATE [dbo].[Mall_BalanceRule] SET 
	[Mall_BalanceRule].[Title] = @Title,
	[Mall_BalanceRule].[BackPercent] = @BackPercent,
	[Mall_BalanceRule].[BackAmount] = @BackAmount,
	[Mall_BalanceRule].[Remark] = @Remark,
	[Mall_BalanceRule].[AddTime] = @AddTime,
	[Mall_BalanceRule].[AddUserName] = @AddUserName,
	[Mall_BalanceRule].[IsActive] = @IsActive,
	[Mall_BalanceRule].[BackBalanceType] = @BackBalanceType,
	[Mall_BalanceRule].[RuleType] = @RuleType 
output 
	INSERTED.[ID],
	INSERTED.[Title],
	INSERTED.[BackPercent],
	INSERTED.[BackAmount],
	INSERTED.[Remark],
	INSERTED.[AddTime],
	INSERTED.[AddUserName],
	INSERTED.[IsActive],
	INSERTED.[BackBalanceType],
	INSERTED.[RuleType]
into @table
WHERE 
	[Mall_BalanceRule].[ID] = @ID

SELECT 
	[ID],
	[Title],
	[BackPercent],
	[BackAmount],
	[Remark],
	[AddTime],
	[AddUserName],
	[IsActive],
	[BackBalanceType],
	[RuleType] 
FROM @table;
";

            System.Collections.Generic.List <SqlParameter> parameters = new System.Collections.Generic.List <SqlParameter>();
            parameters.Add(new SqlParameter("@ID", EntityBase.GetDatabaseValue(@iD)));
            parameters.Add(new SqlParameter("@Title", EntityBase.GetDatabaseValue(@title)));
            parameters.Add(new SqlParameter("@BackPercent", EntityBase.GetDatabaseValue(@backPercent)));
            parameters.Add(new SqlParameter("@BackAmount", EntityBase.GetDatabaseValue(@backAmount)));
            parameters.Add(new SqlParameter("@Remark", EntityBase.GetDatabaseValue(@remark)));
            parameters.Add(new SqlParameter("@AddTime", EntityBase.GetDatabaseValue(@addTime)));
            parameters.Add(new SqlParameter("@AddUserName", EntityBase.GetDatabaseValue(@addUserName)));
            parameters.Add(new SqlParameter("@IsActive", @isActive));
            parameters.Add(new SqlParameter("@BackBalanceType", EntityBase.GetDatabaseValue(@backBalanceType)));
            parameters.Add(new SqlParameter("@RuleType", EntityBase.GetDatabaseValue(@ruleType)));

            @helper.Execute(commandText, CommandType.Text, parameters);
        }
Example #60
0
        private List <SensedEntity> doObjectSensor(SensorInfo ts)
        {
            List <EntityBase>   Entities;
            List <SensedEntity> sensedEntities = new List <SensedEntity>();

            // If this is an object sense by key try to get it directly
            // rather than getting a list to scan through
            if (ts.keyID != UUID.Zero)
            {
                EntityBase e = null;
                m_CmdManager.m_ScriptEngine.World.Entities.TryGetValue(ts.keyID, out e);
                if (e == null)
                {
                    return(sensedEntities);
                }
                Entities = new List <EntityBase>();
                Entities.Add(e);
            }
            else
            {
                Entities = new List <EntityBase>(m_CmdManager.m_ScriptEngine.World.GetEntities());
            }
            SceneObjectPart SensePoint = ts.host;

            Vector3 fromRegionPos = SensePoint.GetWorldPosition();

            // pre define some things to avoid repeated definitions in the loop body
            Vector3         toRegionPos;
            double          dis;
            int             objtype;
            SceneObjectPart part;
            float           dx;
            float           dy;
            float           dz;

//            Quaternion q = SensePoint.RotationOffset;
            Quaternion q = SensePoint.GetWorldRotation();               // non-attached prim Sensor *always* uses World rotation!

            if (SensePoint.ParentGroup.IsAttachment)
            {
                // In attachments, rotate the sensor cone with the
                // avatar rotation. This may include a nonzero elevation if
                // in mouselook.
                // This will not include the rotation and position of the
                // attachment point (e.g. your head when a sensor is in your
                // hair attached to your scull. Your hair  will turn with
                // your head but the sensor will stay with your (global)
                // avatar rotation and position.
                // Position of a sensor in a child prim attached to an avatar
                // will be still wrong.
                ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar);

                // Don't proceed if the avatar for this attachment has since been removed from the scene.
                if (avatar == null)
                {
                    return(sensedEntities);
                }

                fromRegionPos = avatar.AbsolutePosition;
                q             = avatar.Rotation;
            }

            LSL_Types.Quaternion r           = new LSL_Types.Quaternion(q);
            LSL_Types.Vector3    forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
            double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);

            Vector3 ZeroVector = new Vector3(0, 0, 0);

            bool nameSearch = !string.IsNullOrEmpty(ts.name);

            foreach (EntityBase ent in Entities)
            {
                bool keep = true;

                if (nameSearch && ent.Name != ts.name) // Wrong name and it is a named search
                {
                    continue;
                }

                if (ent.IsDeleted) // taken so long to do this it has gone from the scene
                {
                    continue;
                }

                if (!(ent is SceneObjectGroup)) // dont bother if it is a pesky avatar
                {
                    continue;
                }
                toRegionPos = ent.AbsolutePosition;

                // Calculation is in line for speed
                dx = toRegionPos.X - fromRegionPos.X;
                dy = toRegionPos.Y - fromRegionPos.Y;
                dz = toRegionPos.Z - fromRegionPos.Z;

                // Weed out those that will not fit in a cube the size of the range
                // no point calculating if they are within a sphere the size of the range
                // if they arent even in the cube
                if (Math.Abs(dx) > ts.range || Math.Abs(dy) > ts.range || Math.Abs(dz) > ts.range)
                {
                    dis = ts.range + 1.0;
                }
                else
                {
                    dis = Math.Sqrt(dx * dx + dy * dy + dz * dz);
                }

                if (keep && dis <= ts.range && ts.host.UUID != ent.UUID)
                {
                    // In Range and not the object containing the script, is it the right Type ?
                    objtype = 0;

                    part = ((SceneObjectGroup)ent).RootPart;
                    if (part.ParentGroup.RootPart.Shape.PCode != (byte)PCode.Tree &&
                        part.ParentGroup.RootPart.Shape.PCode != (byte)PCode.NewTree &&
                        part.ParentGroup.AttachmentPoint != 0) // Attached so ignore
                    {
                        continue;
                    }

                    if (part.Inventory.ContainsScripts())
                    {
                        objtype |= ACTIVE | SCRIPTED; // Scripted and active. It COULD have one hidden ...
                    }
                    else
                    {
                        if (ent.Velocity.Equals(ZeroVector))
                        {
                            objtype |= PASSIVE; // Passive non-moving
                        }
                        else
                        {
                            objtype |= ACTIVE; // moving so active
                        }
                    }

                    // If any of the objects attributes match any in the requested scan type
                    if (((ts.type & objtype) != 0))
                    {
                        // Right type too, what about the other params , key and name ?
                        if (ts.arc < Math.PI)
                        {
                            // not omni-directional. Can you see it ?
                            // vec forward_dir = llRot2Fwd(llGetRot())
                            // vec obj_dir = toRegionPos-fromRegionPos
                            // dot=dot(forward_dir,obj_dir)
                            // mag_fwd = mag(forward_dir)
                            // mag_obj = mag(obj_dir)
                            // ang = acos(dot /(mag_fwd*mag_obj))
                            double ang_obj = 0;
                            try
                            {
                                Vector3 diff    = toRegionPos - fromRegionPos;
                                double  dot     = LSL_Types.Vector3.Dot(forward_dir, diff);
                                double  mag_obj = LSL_Types.Vector3.Mag(diff);
                                ang_obj = Math.Acos(dot / (mag_fwd * mag_obj));
                            }
                            catch
                            {
                            }

                            if (ang_obj > ts.arc)
                            {
                                keep = false;
                            }
                        }

                        if (keep == true)
                        {
                            // add distance for sorting purposes later
                            sensedEntities.Add(new SensedEntity(dis, ent.UUID));
                        }
                    }
                }
            }
            return(sensedEntities);
        }