本文整理汇总了C#中NetGore.IO.BitStream.ReadMapEntityIndex方法的典型用法代码示例。如果您正苦于以下问题:C# BitStream.ReadMapEntityIndex方法的具体用法?C# BitStream.ReadMapEntityIndex怎么用?C# BitStream.ReadMapEntityIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetGore.IO.BitStream
的用法示例。
在下文中一共展示了BitStream.ReadMapEntityIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecvUpdateVelocityAndPosition
void RecvUpdateVelocityAndPosition(IIPSocket conn, BitStream r)
{
var mapEntityIndex = r.ReadMapEntityIndex();
DynamicEntity dynamicEntity = null;
// Grab the DynamicEntity
// The map can be null if the spatial updates come very early (which isn't uncommon)
if (Map != null)
dynamicEntity = _objGrabber.GetDynamicEntity<DynamicEntity>(mapEntityIndex);
// Deserialize
if (dynamicEntity != null)
{
// Read the value into the DynamicEntity
dynamicEntity.DeserializePositionAndVelocity(r);
}
else
{
// DynamicEntity was null, so just flush the values from the reader
DynamicEntity.FlushPositionAndVelocity(r);
}
}
示例2: RecvStartShopping
void RecvStartShopping(IIPSocket conn, BitStream r)
{
var entityIndex = r.ReadMapEntityIndex();
User user;
Map map;
if (!TryGetMap(conn, out user, out map))
return;
if (user.IsPeerTrading)
return;
var shopkeeper = map.GetDynamicEntity<Character>(entityIndex);
if (shopkeeper == null)
return;
user.ShoppingState.TryStartShopping(shopkeeper);
}
示例3: RecvUseWorld
void RecvUseWorld(IIPSocket conn, BitStream r)
{
var useEntityIndex = r.ReadMapEntityIndex();
// Get the map and user
User user;
Map map;
if (!TryGetMap(conn, out user, out map))
return;
if (user.IsPeerTrading)
return;
if (!user.IsAlive)
{
const string errmsg = "User `{0}` tried to use world entity while dead.";
if (log.IsInfoEnabled)
log.InfoFormat(errmsg, user);
return;
}
// Grab the DynamicEntity to use
var useEntity = map.GetDynamicEntity(useEntityIndex);
if (useEntity == null)
{
const string errmsg = "UseEntity received but usedEntityIndex `{0}` is not a valid DynamicEntity.";
Debug.Fail(string.Format(errmsg, useEntityIndex));
if (log.IsErrorEnabled)
log.ErrorFormat(errmsg, useEntityIndex);
return;
}
// Ensure the used DynamicEntity is even usable
var asUsable = useEntity as IUsableEntity;
if (asUsable == null)
{
const string errmsg =
"UseEntity received but useByIndex `{0}` refers to DynamicEntity `{1}` which does " +
"not implement IUsableEntity.";
Debug.Fail(string.Format(errmsg, useEntityIndex, useEntity));
if (log.IsErrorEnabled)
log.WarnFormat(errmsg, useEntityIndex, useEntity);
return;
}
// Use it
if (asUsable.Use(user))
{
// Notify everyone in the map it was used
if (asUsable.NotifyClientsOfUsage)
{
using (var pw = ServerPacket.UseEntity(useEntity.MapEntityIndex, user.MapEntityIndex))
{
map.Send(pw, ServerMessageType.Map);
}
}
}
}
示例4: RecvAttack
void RecvAttack(IIPSocket conn, BitStream r)
{
User user;
MapEntityIndex? targetIndex = null;
var hasTarget = r.ReadBool();
if (hasTarget)
targetIndex = r.ReadMapEntityIndex();
if ((user = TryGetUser(conn)) != null)
{
if (user.IsPeerTrading)
return;
user.Attack(GetTargetCharacter(user, targetIndex));
}
}
示例5: RecvRequestMapEntityIndex
void RecvRequestMapEntityIndex(IIPSocket conn, BitStream r)
{
var index = r.ReadMapEntityIndex();
// Get the user and their map
User user;
if ((user = TryGetUser(conn)) == null)
return;
Map map;
if (!TryGetMap(user, out map))
return;
// Get the DynamicEntity
var de = map.GetDynamicEntity(index);
if (de == null)
{
// The DynamicEntity for the index was null, so tell the client to delete whatever is at that index
using (var pw = ServerPacket.RemoveDynamicEntity(index))
{
conn.Send(pw, ServerMessageType.Map);
}
}
else
{
// A DynamicEntity does exist at that index, so tell the client to create it
using (var pw = ServerPacket.CreateDynamicEntity(de))
{
conn.Send(pw, ServerMessageType.Map);
}
}
}
示例6: RecvSkillStopCasting_ToMap
void RecvSkillStopCasting_ToMap(IIPSocket conn, BitStream r)
{
var casterEntityIndex = r.ReadMapEntityIndex();
// Get the entity
var casterEntity = _objGrabber.GetDynamicEntity<Character>(casterEntityIndex);
if (casterEntity == null)
return;
// Set the entity as not casting
casterEntity.IsCastingSkill = false;
}
示例7: RecvStartChatDialog
void RecvStartChatDialog(IIPSocket conn, BitStream r)
{
#pragma warning disable 168
var npcIndex = r.ReadMapEntityIndex();
#pragma warning restore 168
var dialogIndex = r.ReadNPCChatDialogID();
var dialog = ClientNPCChatManager.Instance[dialogIndex];
GameplayScreen.ChatDialogForm.StartDialog(dialog);
}
示例8: RecvSynchronizeDynamicEntity
void RecvSynchronizeDynamicEntity(IIPSocket conn, BitStream r)
{
var mapEntityIndex = r.ReadMapEntityIndex();
DynamicEntity e = Map.GetDynamicEntity(mapEntityIndex);
e.Deserialize(r);
}
示例9: RecvEmote
void RecvEmote(IIPSocket conn, BitStream r)
{
var mapEntityIndex = r.ReadMapEntityIndex();
var emoticon = r.ReadEnum<Emoticon>();
var entity = Map.GetDynamicEntity(mapEntityIndex);
if (entity == null)
return;
EmoticonDisplayManager.Instance.Add(entity, emoticon, GetTime());
}
示例10: RecvChatSay
void RecvChatSay(IIPSocket conn, BitStream r)
{
var name = r.ReadString(GameData.MaxServerSayNameLength);
var mapEntityIndex = r.ReadMapEntityIndex();
var text = r.ReadString(GameData.MaxServerSayLength);
var chatText = CreateChatText(name, text);
GameplayScreen.AppendToChatOutput(chatText);
var entity = Map.GetDynamicEntity(mapEntityIndex);
if (entity == null)
return;
GameplayScreen.AddChatBubble(entity, text);
}
示例11: RecvCreateDynamicEntity
void RecvCreateDynamicEntity(IIPSocket conn, BitStream r)
{
var mapEntityIndex = r.ReadMapEntityIndex();
var dynamicEntity = _dynamicEntityFactory.Read(r);
Map.AddDynamicEntity(dynamicEntity, mapEntityIndex);
var character = dynamicEntity as Character;
if (character != null)
{
// HACK: Having to call this .Initialize() and pass these parameters seems hacky
character.Initialize(Map, GameplayScreen.SkeletonManager);
}
if (log.IsInfoEnabled)
log.InfoFormat("Created DynamicEntity with index `{0}` of type `{1}`", dynamicEntity.MapEntityIndex,
dynamicEntity.GetType());
}
示例12: RecvCharDamage
void RecvCharDamage(IIPSocket conn, BitStream r)
{
var mapCharIndex = r.ReadMapEntityIndex();
var damage = r.ReadInt();
var chr = _objGrabber.GetDynamicEntity<Character>(mapCharIndex);
if (chr == null)
return;
GameplayScreen.DamageTextPool.Create(damage, chr, GetTime());
}
示例13: RecvCharAttack
void RecvCharAttack(IIPSocket conn, BitStream r)
{
// Read the values
var attackerID = r.ReadMapEntityIndex();
MapEntityIndex? attackedID;
if (r.ReadBool())
attackedID = r.ReadMapEntityIndex();
else
attackedID = null;
ActionDisplayID? actionDisplayIDNullable;
if (r.ReadBool())
actionDisplayIDNullable = r.ReadActionDisplayID();
else
actionDisplayIDNullable = null;
// Get the object references using the IDs provided
var attacker = _objGrabber.GetDynamicEntity<Character>(attackerID);
if (attacker == null)
return;
DynamicEntity attacked = attackedID.HasValue ? Map.GetDynamicEntity(attackedID.Value) : null;
// Use the default ActionDisplayID if we were provided with a null value
ActionDisplayID actionDisplayID = !actionDisplayIDNullable.HasValue ? GameData.DefaultActionDisplayID : actionDisplayIDNullable.Value;
// Get the ActionDisplay to use and, if valid, execute it
var actionDisplay = ActionDisplayScripts.ActionDisplays[actionDisplayID];
if (actionDisplay != null)
actionDisplay.Execute(Map, attacker, attacked);
}
示例14: RecvUseEntity
void RecvUseEntity(IIPSocket conn, BitStream r)
{
var usedEntityIndex = r.ReadMapEntityIndex();
var usedByIndex = r.ReadMapEntityIndex();
// Grab the used DynamicEntity
var usedEntity = _objGrabber.GetDynamicEntity<IUsableEntity>(usedEntityIndex);
if (usedEntity == null)
return;
// Grab the one who used this DynamicEntity (we can still use it, we'll just pass null)
var usedBy = Map.GetDynamicEntity(usedByIndex);
if (usedBy == null)
return;
// Use it
usedEntity.Use(usedBy);
}
示例15: RecvCreateActionDisplayAtEntity
void RecvCreateActionDisplayAtEntity(IIPSocket conn, BitStream r)
{
ActionDisplayID actionDisplayId = r.ReadActionDisplayID();
MapEntityIndex sourceEntityIndex = r.ReadMapEntityIndex();
bool hasTarget = r.ReadBool();
MapEntityIndex? targetEntityIndex = hasTarget ? r.ReadMapEntityIndex() : (MapEntityIndex?)null;
// Get the entities
var sourceEntity = _objGrabber.GetDynamicEntity<Character>(sourceEntityIndex);
if (sourceEntity == null)
return;
var targetEntity = targetEntityIndex.HasValue ? _objGrabber.GetDynamicEntity<Character>(targetEntityIndex.Value) : null;
// Get the action display
var ad = ActionDisplayScripts.ActionDisplays[actionDisplayId];
if (ad == null)
return;
// Create
ad.Execute(Map, sourceEntity, targetEntity);
}