Ejemplo n.º 1
0
        public System.Collections.Generic.List <byte> __encode()
        {
            var data = new System.Collections.Generic.List <byte>();

            data.AddRange(Proto4z.BaseProtoObject.encodeUI64(this.refresh));
            data.AddRange(Proto4z.BaseProtoObject.encodeUI64(this.groupID));
            if (this.baseInfo == null)
            {
                this.baseInfo = new EntityBase();
            }
            data.AddRange(this.baseInfo.__encode());
            if (this.fixedProps == null)
            {
                this.fixedProps = new EntityProp();
            }
            data.AddRange(this.fixedProps.__encode());
            if (this.growthProps == null)
            {
                this.growthProps = new EntityProp();
            }
            data.AddRange(this.growthProps.__encode());
            if (this.growths == null)
            {
                this.growths = new EntityProp();
            }
            data.AddRange(this.growths.__encode());
            return(data);
        }
Ejemplo n.º 2
0
        public override bool CanActivate(MobUpdateContext context)
        {
            MobAIPerceptionState perception = context.mob.AIState.perception_data;
            EntityProp           prop       = perception.GetPlayerTargetProp();
            bool canActivate = (prop != null && prop.propStatus == EntityProp.ePropStatus.orphaned);

            return(canActivate);
        }
Ejemplo n.º 3
0
 public SceneServerJoinGroupIns(ulong refresh, ulong groupID, EntityBase baseInfo, EntityProp fixedProps, EntityProp growthProps, EntityProp growths)
 {
     this.refresh     = refresh;
     this.groupID     = groupID;
     this.baseInfo    = baseInfo;
     this.fixedProps  = fixedProps;
     this.growthProps = growthProps;
     this.growths     = growths;
 }
Ejemplo n.º 4
0
 public EntityProp growths;     //成长系数
 public SceneServerJoinGroupIns()
 {
     refresh     = 0;
     groupID     = 0;
     baseInfo    = new EntityBase();
     fixedProps  = new EntityProp();
     growthProps = new EntityProp();
     growths     = new EntityProp();
 }
Ejemplo n.º 5
0
 public static byte[] EntityProperty(byte entityID, EntityProp prop, int value)
 {
     byte[] buffer = new byte[7];
     buffer[0] = Opcode.CpeSetEntityProperty;
     buffer[1] = entityID;
     buffer[2] = (byte)prop;
     NetUtils.WriteI32(value, buffer, 3);
     return(buffer);
 }
Ejemplo n.º 6
0
        public static Packet MakeEntityProperty(sbyte id, EntityProp prop, int value)
        {
            Packet packet = new Packet(OpCode.SetEntityProperty);

            packet.Bytes[1] = (byte)id;
            packet.Bytes[2] = (byte)prop;
            WriteI32(value, packet.Bytes, 3);
            return(packet);
        }
Ejemplo n.º 7
0
        public override bool CanActivate(MobUpdateContext context)
        {
            EntityProp energyTankProp = context.mob.AIState.perception_data.GetEnergyTankTargetProp();

            return
                (energyTankProp != null &&
                 energyTankProp.propStatus >= EntityProp.ePropStatus.assumed &&
                 energyTankProp.faction != GameConstants.eFaction.ai &&
                 energyTankProp.energy > 0);
        }
Ejemplo n.º 8
0
        public override void Perform(MobUpdateContext context)
        {
            MobAIPerceptionState perception = context.mob.AIState.perception_data;
            EntityProp           prop       = perception.GetPlayerTargetProp();

            if (prop.distance >= WorldConstants.ROOM_TILE_SIZE)
            {
                context.MobPostDialog("I though I saw someone over here");
                context.MoveMob(prop.GetPosition());
            }
        }
Ejemplo n.º 9
0
        public override bool CanActivate(MobUpdateContext context)
        {
            EntityProp energyTankProp = context.mob.AIState.perception_data.GetEnergyTankTargetProp();

            return
                (energyTankProp != null &&
                 context.mob.MobType.Abilities.energy_tank_drain_per_turn > 0 &&
                 // Even if we can't use the energy, we can deny the player from having it
                 //energyTankProp.energy < context.mob.MobType.MaxEnergy &&
                 energyTankProp.propStatus >= EntityProp.ePropStatus.assumed &&
                 energyTankProp.faction == GameConstants.eFaction.ai &&
                 energyTankProp.energy > 0);
        }
Ejemplo n.º 10
0
        static void SendModelScale(Player pl, byte id, EntityProp axis, float value)
        {
            if (value == 0)
            {
                return;
            }
            int packed = (int)(value * 1000);

            if (packed == 0)
            {
                return;
            }
            pl.Send(Packet.EntityProperty(id, axis, packed));
        }
Ejemplo n.º 11
0
 public int __decode(byte[] binData, ref int pos)
 {
     this.refresh  = Proto4z.BaseProtoObject.decodeUI64(binData, ref pos);
     this.groupID  = Proto4z.BaseProtoObject.decodeUI64(binData, ref pos);
     this.baseInfo = new EntityBase();
     this.baseInfo.__decode(binData, ref pos);
     this.fixedProps = new EntityProp();
     this.fixedProps.__decode(binData, ref pos);
     this.growthProps = new EntityProp();
     this.growthProps.__decode(binData, ref pos);
     this.growths = new EntityProp();
     this.growths.__decode(binData, ref pos);
     return(pos);
 }
Ejemplo n.º 12
0
        static void SendModelScale(Player dst, byte id, EntityProp axis, float value, float max)
        {
            if (value == 0)
            {
                return;
            }
            value = Math.Min(value, max);

            int packed = (int)(value * 1000);

            if (packed == 0)
            {
                return;
            }
            dst.Send(Packet.EntityProperty(id, axis, packed));
        }
Ejemplo n.º 13
0
    protected override ModelMetadata CreateMetadata(IEnumerable <Attribute> attributes, Type containerType, Func <object> modelAccessor, Type modelType, string propertyName)
    {
        EntityProp eprop = modelAccessor();
        DataAnnotationsModelMetadata result;

        if (propertyName == null)
        {
            // You have the main object
            return(base.CreateMetadata(attributes, containerType, modelAccessor, modelType, propertyName));
        }
        else
        {
            // You have here the property object
            result            = new DataAnnotationsModelMetadata(this, containerType, () => eprop.Value, modelType, propertyName, null);
            result.IsRequired = eprop.IsRequired;
        }
        return(result);
    }
Ejemplo n.º 14
0
        public static void UpdateEntityProp(Entity entity, EntityProp prop, int value)
        {
            Player[] players = PlayerInfo.Online.Items;
            Level    lvl     = entity.Level;

            Orientation rot   = entity.Rot;
            byte        angle = Orientation.DegreesToPacked(value);

            if (prop == EntityProp.RotX)
            {
                rot.RotX = angle;
            }
            if (prop == EntityProp.RotY)
            {
                rot.RotY = angle;
            }
            if (prop == EntityProp.RotZ)
            {
                rot.RotZ = angle;
            }

            entity.Rot = rot;
            if (prop == EntityProp.RotY)
            {
                entity.SetYawPitch(rot.RotY, rot.HeadX);
            }

            foreach (Player pl in players)
            {
                if (pl.level != lvl || !pl.Supports(CpeExt.EntityProperty))
                {
                    continue;
                }
                if (!pl.CanSeeEntity(entity))
                {
                    continue;
                }

                byte id = (pl == entity) ? Entities.SelfID : entity.EntityID;
                pl.Send(Packet.EntityProperty(id, prop,
                                              Orientation.PackedToDegrees(angle)));
            }
        }
Ejemplo n.º 15
0
        public override void Perform(MobUpdateContext context)
        {
            EntityProp energyTankProp = context.mob.AIState.perception_data.GetEnergyTankTargetProp();
            EnergyTank energyTank     = context.moveRequest.EnergyTanks.Find(e => e.ID == energyTankProp.target_object_id);

            if (energyTank.Faction == GameConstants.eFaction.ai)
            {
                // We can only drain up to what we can take and whats left in the energy tank
                int drainAmount =
                    Math.Min(energyTank.Energy, context.mob.MobType.Abilities.energy_tank_drain_per_turn);

                context.MobDrainEnergyTank(energyTank, drainAmount);
                context.MobPostDialog("Sweet Sweet Energy...");
            }
            else
            {
                context.MoveMob(energyTank.Position);
                context.MobPostDialog("What?! Someone hacked this! Grrr...");
            }

            // Update the energy on the prop
            energyTankProp.energy = energyTank.Energy;
        }
Ejemplo n.º 16
0
        public override void Perform(MobUpdateContext context)
        {
            EntityProp energyTankProp = context.mob.AIState.perception_data.GetEnergyTankTargetProp();
            EnergyTank energyTank     = context.moveRequest.EnergyTanks.Find(e => e.ID == energyTankProp.target_object_id);

            if (energyTank.Faction == GameConstants.eFaction.player)
            {
                context.MobHackEnergyTank(energyTank);
                context.MobPostDialog("Which team owns one less energy tank? Team Player!");
            }
            else if (energyTank.Faction == GameConstants.eFaction.neutral)
            {
                context.MobHackEnergyTank(energyTank);
                context.MobPostDialog("Energy Tank claimed for the AI Team!");
            }
            else if (energyTank.Faction == GameConstants.eFaction.ai)
            {
                context.MobHackEnergyTank(energyTank);
                context.MobPostDialog("Oh! I guess we already owned this energy tank");
            }

            // Update the faction on the prop
            energyTankProp.faction = energyTank.Faction;
        }