public static void CreateDropItem(PlayerEntity player, int cat, int id, int count, ISceneObjectEntityFactory factory) { var dropPos = player.position.Value + player.characterContoller.Value.transform.forward * 2; if (player != null) { RaycastHit hit; Vector3 throwPos = player.GetHandWeaponPosition(); Ray ray = new Ray(throwPos, dropPos - throwPos); if (Physics.Raycast(ray, out hit, Vector3.Distance(throwPos, dropPos) - 0.01f, UnityLayers.PickupObstacleLayerMask)) { RaycastHit vhit; if (Physics.Raycast(hit.point + new Vector3(0, 0.1f, 0), Vector3.down, out vhit, 100, UnityLayers.PickupObstacleLayerMask)) { dropPos = vhit.point; } else { dropPos = hit.point; } } else { RaycastHit vhit; if (Physics.Raycast(dropPos + new Vector3(0, 0.1f, 0), Vector3.down, out vhit, 100, UnityLayers.PickupObstacleLayerMask)) { dropPos = vhit.point; } } } factory.CreateSimpleObjectEntity((ECategory)cat, id, count, dropPos, count); }
public static void ProcessSceneObjectCommand(DebugCommand message, SceneObjectContext context, ISceneObjectEntityFactory sceneObjectEntityFactory, PlayerEntity player) { switch (message.Command) { case DebugCommands.CreateSceneObject: int category; int id; if (int.TryParse(message.Args[0], out category) && int.TryParse(message.Args[1], out id)) { sceneObjectEntityFactory.CreateSimpleObjectEntity((Assets.XmlConfig.ECategory)category, id, 1, player.position.Value); } break; case DebugCommands.ClearSceneObject: context.DestroyAllEntities(); break; } }